Skip to content

Commit

Permalink
commit test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Jan 19, 2024
1 parent 5f9ff95 commit d7b59b1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,24 @@ test('reconstructs an index from array buffer', () => {

test('throws an error when reconstructing an index from array buffer if not 8-byte aligned', () => {
const index = createIndex();
const newArrayBuffer = new ArrayBuffer(index.data.byteLength + 10);
const newView = new Uint8Array(newArrayBuffer, 10);
const byteOffset = 12;
const newArrayBuffer = new ArrayBuffer(index.data.byteLength + byteOffset);
const newView = new Uint8Array(newArrayBuffer, byteOffset);
newView.set(new Uint8Array(index.data));

assert.throws(() => {
Flatbush.from(newView);
Flatbush.from(newArrayBuffer, byteOffset);
});
});

test('reconstructs an index from a Uint8Array', () => {
const index = createIndex();
const newArrayBuffer = new ArrayBuffer(index.data.byteLength + 16);
const newView = new Uint8Array(newArrayBuffer, 16);
const byteOffset = 16;
const newArrayBuffer = new ArrayBuffer(index.data.byteLength + byteOffset);
const newView = new Uint8Array(newArrayBuffer, byteOffset);
newView.set(new Uint8Array(index.data));

const index2 = Flatbush.from(newView);
const index2 = Flatbush.from(newArrayBuffer, byteOffset);

assert.deepEqual(index._boxes, index2._boxes);
assert.deepEqual(index._indices, index2._indices);
Expand Down

0 comments on commit d7b59b1

Please sign in to comment.