feat(DataView, ConstDataView)

This commit is contained in:
2025-08-04 15:33:12 +03:00
parent 72f6102f0c
commit 504bfbeae8
11 changed files with 179 additions and 37 deletions

View File

@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import { ConstString, parse, serialize, sizeofHead } from "../src";
import { filledDataView, sizedDataView } from ".";
import { expectDataViewEqual, filledDataView, sizedDataView } from ".";
describe(ConstString.name, () => {
test('serialize', () => {
@ -11,14 +11,14 @@ describe(ConstString.name, () => {
dv = sizedDataView(5)
serialize(dv, 'hello', ConstString(3))
expect(dv).toEqual(expected)
expectDataViewEqual(dv, expected)
})
test('parse', () => {
const expected = 'hel'
const dv = filledDataView([0x68, 0x65, 0x6C, 0x6C, 0x6F])
const actual = parse(dv, ConstString(3))
expect(actual).toEqual(expected)
expectDataViewEqual(actual, expected)
})
test('sizeof', () => {