2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-04-29 02:57:30 +00:00
|
|
|
import { assert } from "@std/assert";
|
2022-11-29 06:01:21 +00:00
|
|
|
import { endsWith } from "./ends_with.ts";
|
|
|
|
|
2024-10-31 14:22:19 +00:00
|
|
|
Deno.test("endsWith()", async (t) => {
|
|
|
|
await t.step("`true` where `source` and `suffix` are identical", () => {
|
|
|
|
assert(endsWith(
|
|
|
|
new Uint8Array([0, 1, 2, 3]),
|
|
|
|
new Uint8Array([0, 1, 2, 3]),
|
|
|
|
));
|
|
|
|
});
|
|
|
|
await t.step("`true` where `source` ends with `suffix`", () => {
|
|
|
|
assert(endsWith(
|
|
|
|
new Uint8Array([0, 1, 2]),
|
|
|
|
new Uint8Array([1, 2]),
|
|
|
|
));
|
|
|
|
});
|
|
|
|
await t.step("`false` with a common but only partial suffix", () => {
|
|
|
|
assert(
|
|
|
|
!endsWith(
|
|
|
|
new Uint8Array([0, 1, 2]),
|
|
|
|
new Uint8Array([0, 2]),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
await t.step("`false` where `suffix` is longer", () => {
|
|
|
|
assert(
|
|
|
|
!endsWith(
|
|
|
|
new Uint8Array([0, 1, 2]),
|
|
|
|
new Uint8Array([0, 2, 3, 4]),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
await t.step("`false` where `suffix` ends with `source`", () => {
|
|
|
|
assert(
|
|
|
|
!endsWith(
|
|
|
|
new Uint8Array([1, 2]),
|
|
|
|
new Uint8Array([0, 1, 2]),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
2022-11-29 06:01:21 +00:00
|
|
|
});
|