diff options
Diffstat (limited to 'std/bytes/test.ts')
-rw-r--r-- | std/bytes/test.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/std/bytes/test.ts b/std/bytes/test.ts index 13ac7a1fd..8b03de926 100644 --- a/std/bytes/test.ts +++ b/std/bytes/test.ts @@ -5,8 +5,10 @@ import { findLastIndex, equal, hasPrefix, + hasSuffix, repeat, concat, + contains, } from "./mod.ts"; import { assertEquals, assertThrows, assert } from "../testing/asserts.ts"; import { encode, decode } from "../encoding/utf8.ts"; @@ -24,6 +26,11 @@ Deno.test("[bytes] findIndex2", () => { assertEquals(i, 1); }); +Deno.test("[bytes] findIndex3", () => { + const i = findIndex(encode("Deno"), encode("D")); + assertEquals(i, 0); +}); + Deno.test("[bytes] findLastIndex1", () => { const i = findLastIndex( new Uint8Array([0, 1, 2, 0, 1, 2, 0, 1, 3]), @@ -47,6 +54,11 @@ Deno.test("[bytes] hasPrefix", () => { assertEquals(v, true); }); +Deno.test("[bytes] hasSuffix", () => { + const v = hasSuffix(new Uint8Array([0, 1, 2]), new Uint8Array([1, 2])); + assertEquals(v, true); +}); + Deno.test("[bytes] repeat", () => { // input / output / count / error message const repeatTestCase = [ @@ -97,3 +109,11 @@ Deno.test("[bytes] concat empty arrays", () => { assert(u1 !== joined); assert(u2 !== joined); }); + +Deno.test("[bytes] contain", () => { + const source = encode("deno.land"); + const pattern = encode("deno"); + assert(contains(source, pattern)); + + assert(contains(new Uint8Array([0, 1, 2, 3]), new Uint8Array([2, 3]))); +}); |