23 lines
712 B
TypeScript
23 lines
712 B
TypeScript
import { expect, test } from "bun:test";
|
|
import { uint_bytes_to_num, utf8_decode } from "./tools";
|
|
|
|
test("parse_uint - 0xFF", () => {
|
|
expect(uint_bytes_to_num(new Uint8Array([0x0, 0x0, 0x0, 0xFF]))).toBe(0xFF);
|
|
});
|
|
|
|
test("parse_uint - 0xFF00", () => {
|
|
expect(uint_bytes_to_num(new Uint8Array([0x0, 0x0, 0xFF, 0x0]))).toBe(0xFF00);
|
|
});
|
|
|
|
test("parse_uint - 0xFF0000", () => {
|
|
expect(uint_bytes_to_num(new Uint8Array([0x0, 0xFF, 0x0, 0x0]))).toBe(0xFF0000);
|
|
});
|
|
|
|
test("parse_uint - 0xFF000000", () => {
|
|
expect(uint_bytes_to_num(new Uint8Array([0xFF, 0x0, 0x0, 0x0]))).toBe(0xFF000000);
|
|
});
|
|
|
|
test("decode_utf8 - \"test\"", () => {
|
|
expect(utf8_decode(new Uint8Array([0x74, 0x65, 0x73, 0x74]))).toBe("test");
|
|
});
|