add half-working client

This commit is contained in:
2025-05-05 00:15:12 +02:00
parent 776ee8d637
commit bfa0ba8edf
13 changed files with 782 additions and 38 deletions

View File

@@ -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);
});