Add a few tests

This commit is contained in:
Andras Schmelczer 2025-01-03 11:35:00 +00:00
parent 5178cb6381
commit d9c2c5b2a1
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
7 changed files with 3462 additions and 3 deletions

View file

@ -0,0 +1,27 @@
import { isEqualBytes } from "./is-equal-bytes";
describe("isEqualBytes", () => {
it("should return true for equal byte arrays", () => {
const bytes1 = new Uint8Array([1, 2, 3, 4]);
const bytes2 = new Uint8Array([1, 2, 3, 4]);
expect(isEqualBytes(bytes1, bytes2)).toBe(true);
});
it("should return false for byte arrays of different lengths", () => {
const bytes1 = new Uint8Array([1, 2, 3, 4]);
const bytes2 = new Uint8Array([1, 2, 3]);
expect(isEqualBytes(bytes1, bytes2)).toBe(false);
});
it("should return true for empty byte arrays", () => {
const bytes1 = new Uint8Array([]);
const bytes2 = new Uint8Array([]);
expect(isEqualBytes(bytes1, bytes2)).toBe(true);
});
it("should return false for byte arrays with same length but different content", () => {
const bytes1 = new Uint8Array([1, 2, 3, 4]);
const bytes2 = new Uint8Array([4, 3, 2, 1]);
expect(isEqualBytes(bytes1, bytes2)).toBe(false);
});
});