test(bytes): add test for negative start index for indexOfNeedle() (#4768)

tests(bytes): add test for negative `start` index for `indexOfNeedle()`
This commit is contained in:
Asher Gomez 2024-05-20 17:16:27 +10:00 committed by GitHub
parent 2fd7126cea
commit 2cc21194aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -62,3 +62,22 @@ Deno.test("indexOfNeedle() handles start index less than 0", () => {
-1,
);
});
Deno.test("indexOfNeedle() handles negative start index", () => {
assertEquals(
indexOfNeedle(
new Uint8Array([0, 1, 2, 0, 1, 2]),
new Uint8Array([0, 1]),
-3,
),
3,
);
assertEquals(
indexOfNeedle(
new Uint8Array([0, 1, 2, 1, 1, 2]),
new Uint8Array([0, 1]),
-3,
),
-1,
);
});