diff --git a/test/core/codec_test.dart b/test/core/codec_test.dart index 7cd9f066..005f4d38 100644 --- a/test/core/codec_test.dart +++ b/test/core/codec_test.dart @@ -6,12 +6,13 @@ import 'dart:convert'; +import 'package:dart_wot/scripting_api.dart'; import 'package:dart_wot/src/core/codecs/text_codec.dart'; import 'package:test/test.dart'; void main() { - group('TextCodec', () { - test('should convert bytes to values and back', () { + group('TextCodec should', () { + test('convert bytes to values and back', () { final textCodec = TextCodec(); const testValue = 'foo'; @@ -25,4 +26,24 @@ void main() { expect(convertedBytes, testInput); }); }); + + test('reject unknown charsets', () { + final textCodec = TextCodec(); + + const charsetParameters = {'charset': 'foobar'}; + + expect( + () => textCodec.bytesToValue(utf8.encode('foo'), null, charsetParameters), + throwsFormatException, + ); + + expect( + () => textCodec.valueToBytes( + DataSchemaValue.fromNull(), + null, + charsetParameters, + ), + throwsFormatException, + ); + }); }