From 3aa9a29fd38161ec8940d19e1724068c67aab91b Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Sat, 30 Dec 2023 03:22:03 +0100 Subject: [PATCH] fixup! test: add tests for codecs --- test/core/codec_test.dart | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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, + ); + }); }