2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2022-11-29 06:01:21 +00:00
|
|
|
import { includesNeedle } from "./includes_needle.ts";
|
2024-04-29 02:57:30 +00:00
|
|
|
import { assert } from "@std/assert";
|
2022-11-29 06:01:21 +00:00
|
|
|
|
2023-12-19 01:16:10 +00:00
|
|
|
Deno.test("includesNeedle()", () => {
|
2022-11-29 06:01:21 +00:00
|
|
|
const encoder = new TextEncoder();
|
|
|
|
const source = encoder.encode("deno.land");
|
|
|
|
const pattern = encoder.encode("deno");
|
|
|
|
|
|
|
|
assert(includesNeedle(source, pattern));
|
|
|
|
assert(includesNeedle(new Uint8Array([0, 1, 2, 3]), new Uint8Array([2, 3])));
|
|
|
|
|
|
|
|
assert(includesNeedle(source, pattern, -10));
|
|
|
|
assert(!includesNeedle(source, pattern, -1));
|
|
|
|
});
|