Suite of AT Protocol TypeScript libraries built on web standards
21
fork

Configure Feed

Select the types of activity you want to include in your feed.

at lex 39 lines 938 B view raw
1/* eslint-env mocha */ 2 3import { alloc, allocUnsafe } from "../alloc.ts"; 4import { assert, assertEquals } from "@std/assert"; 5 6Deno.test("can alloc memory", () => { 7 const size = 10; 8 9 assertEquals(alloc(size).byteLength, size); 10}); 11 12Deno.test("can alloc memory", () => { 13 const size = 10; 14 const buf = alloc(size); 15 16 assert(buf.every((value) => value === 0)); 17}); 18 19Deno.test("can alloc memory unsafely", () => { 20 const size = 10; 21 22 assertEquals(allocUnsafe(size).byteLength, size); 23}); 24 25Deno.test("alloc returns Uint8Array", () => { 26 const a = alloc(10); 27 const slice = a.slice(); 28 29 // node slice is a copy operation, Uint8Array slice is a no-copy operation 30 assert(slice.buffer !== a.buffer); 31}); 32 33Deno.test("allocUnsafe returns Uint8Array", () => { 34 const a = allocUnsafe(10); 35 const slice = a.slice(); 36 37 // node slice is a copy operation, Uint8Array slice is a no-copy operation 38 assert(slice.buffer !== a.buffer); 39});