Skip to content

Commit 7101725

Browse files
committed
add regression test
1 parent 4db4e4f commit 7101725

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,32 @@ test('reconstructs an index from SharedArrayBuffer', () => {
222222
assert.deepEqual(index, index2);
223223
});
224224

225+
test('quicksort should work with an inbalanced dataset', () => {
226+
const n = 15000
227+
const index = new Flatbush(2*n);
228+
229+
function linspace(start, stop, num, endpoint = true) {
230+
const div = endpoint ? (num - 1) : num;
231+
const step = (stop - start) / div;
232+
return Array.from({length: num}, (_, i) => start + step * i);
233+
}
234+
235+
const items = linspace(0, 1000, n)
236+
const items2 = linspace(0, 1000, n)
237+
238+
for (const p of items) {
239+
index.add(p, 0, p, 0);
240+
}
241+
242+
for (const p of items2) {
243+
index.add(p, 0, p, 0);
244+
}
245+
246+
index.finish();
247+
248+
assert.doesNotThrow(() => {
249+
index.search(-100, -1, 15000, 1);
250+
});
251+
});
252+
225253
function compare(a, b) { return a - b; }

0 commit comments

Comments
 (0)