Skip to content

Commit

Permalink
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 a4eee07 commit c2813f1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/core/codec_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2023 Contributors to the Eclipse Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// SPDX-License-Identifier: BSD-3-Clause

import 'dart:convert';

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', () {
final textCodec = TextCodec();

const testValue = 'foo';
final testInput = utf8.encode(testValue);

final convertedValue = textCodec.bytesToValue(testInput, null, {});
expect(convertedValue?.value, testValue);

final convertedBytes = textCodec.valueToBytes(convertedValue, null, {});

expect(convertedBytes, testInput);
});
});
}

0 comments on commit c2813f1

Please sign in to comment.