Something went wrong. Try again.
Suite of AT Protocol TypeScript libraries built on web standards
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940/* eslint-env mocha */
import { alloc, allocUnsafe } from "../alloc.ts";import { assert, assertEquals } from "@std/assert";
Deno.test("can alloc memory", () => { const size = 10;
assertEquals(alloc(size).byteLength, size);});
Deno.test("can alloc memory", () => { const size = 10; const buf = alloc(size);
assert(buf.every((value) => value === 0));});
Deno.test("can alloc memory unsafely", () => { const size = 10;
assertEquals(allocUnsafe(size).byteLength, size);});
Deno.test("alloc returns Uint8Array", () => { const a = alloc(10); const slice = a.slice();
// node slice is a copy operation, Uint8Array slice is a no-copy operation assert(slice.buffer !== a.buffer);});
Deno.test("allocUnsafe returns Uint8Array", () => { const a = allocUnsafe(10); const slice = a.slice();
// node slice is a copy operation, Uint8Array slice is a no-copy operation assert(slice.buffer !== a.buffer);});