add half-working client
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { uint_bytes_to_num, utf8_decode } from "./tools";
|
||||
import { uint_bytes_to_num, utf8_decode, utf8_encode } from "./tools";
|
||||
|
||||
test("parse_uint - 0xFF", () => {
|
||||
expect(uint_bytes_to_num(new Uint8Array([0x0, 0x0, 0x0, 0xFF]))).toBe(0xFF);
|
||||
@@ -20,3 +20,12 @@ test("parse_uint - 0xFF000000", () => {
|
||||
test("decode_utf8 - \"test\"", () => {
|
||||
expect(utf8_decode(new Uint8Array([0x74, 0x65, 0x73, 0x74]))).toBe("test");
|
||||
});
|
||||
|
||||
test("encode_utf8 - \"test\"", () => {
|
||||
expect(utf8_encode("test")).toMatchObject(new Uint8Array([0x74, 0x65, 0x73, 0x74]));
|
||||
});
|
||||
|
||||
test("encode_decode_utf8 - \"Hello, world!\"", () => {
|
||||
const text = "Hello, world!";
|
||||
expect(utf8_decode(utf8_encode(text))).toBe(text);
|
||||
});
|
||||
|
Reference in New Issue
Block a user