Skip to content

Commit

Permalink
fixup! test: add tests for codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Dec 30, 2023
1 parent cf48381 commit 3aa9a29
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions test/core/codec_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
);
});
}

0 comments on commit 3aa9a29

Please sign in to comment.