From de23f2f8aa505af99ebf0cdf42d7fa96185b7bdd Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 1 May 2022 04:36:17 -0700 Subject: Buffer.compare & Buffer.equal --- integration/bunjs-only-snippets/buffer.test.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'integration/bunjs-only-snippets') diff --git a/integration/bunjs-only-snippets/buffer.test.js b/integration/bunjs-only-snippets/buffer.test.js index c934f872d..ba325adc9 100644 --- a/integration/bunjs-only-snippets/buffer.test.js +++ b/integration/bunjs-only-snippets/buffer.test.js @@ -147,6 +147,31 @@ it("Buffer.from", () => { gc(); }); +it("Buffer.equals", () => { + var a = new Uint8Array(10); + a[2] = 1; + var b = new Uint8Array(10); + b[2] = 1; + Buffer.toBuffer(a); + Buffer.toBuffer(b); + expect(a.equals(b)).toBe(true); + b[2] = 0; + expect(a.equals(b)).toBe(false); +}); + +it("Buffer.compare", () => { + var a = new Uint8Array(10); + a[2] = 1; + var b = new Uint8Array(10); + b[2] = 1; + Buffer.toBuffer(a); + Buffer.toBuffer(b); + expect(a.compare(b)).toBe(0); + b[2] = 0; + expect(a.compare(b)).toBe(1); + expect(b.compare(a)).toBe(-1); +}); + it("Buffer.copy", () => { var array1 = new Uint8Array(128); array1.fill(100); -- cgit v1.2.3