21 lines
636 B
TypeScript
21 lines
636 B
TypeScript
import { splitUint8Array } from "@termos/util/concat";
|
|
import { expect, test } from "vitest";
|
|
|
|
test("divide to chunks", () => {
|
|
const data: Uint8Array = new Uint8Array(2048);
|
|
const result = splitUint8Array(data, 1024);
|
|
expect(result.length).toEqual(2);
|
|
});
|
|
|
|
test("divide to chunks", () => {
|
|
const data: Uint8Array = new Uint8Array(2049);
|
|
const result = splitUint8Array(data, 1024);
|
|
expect(result.length).toEqual(3);
|
|
});
|
|
|
|
test("divide to chunks", () => {
|
|
const data: Uint8Array = new Uint8Array(2048);
|
|
const result = splitUint8Array(data, 53);
|
|
expect(result.length).toEqual(Math.ceil(2048 / 53));
|
|
});
|