fix: test

This commit is contained in:
cha0s 2021-04-19 12:11:02 -05:00
parent 20d3daebc3
commit 119f141002

View File

@ -8,19 +8,19 @@ describe('Floodwalk', () => {
it('can walk', () => { it('can walk', () => {
const data = [ const data = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,
]; ];
let correct = data.reduce((r, v, i) => r.concat(v ? [+i] : []), []); let correct = data.reduce((r, v, i) => r.concat(v ? [+i] : []), []);
expect( expect(
floodwalk(data, [1, 1], 8, 4) floodwalk(new Set([1]), data, [1, 1, 8, 4])
.sort((l, r) => l < r ? -1 : 1) .sort((l, r) => l < r ? -1 : 1)
).to.deep.equal(correct); ).to.deep.equal(correct);
data[12] = 0; data[12] = 0;
correct = [9, 10, 16, 17, 18, 19]; correct = [9, 10, 11, 16, 17, 18, 19];
expect( expect(
floodwalk(data, [1, 1], 8, 4) floodwalk(new Set([1]), data, [1, 1, 8, 4])
.sort((l, r) => l < r ? -1 : 1) .sort((l, r) => l < r ? -1 : 1)
).to.deep.equal(correct); ).to.deep.equal(correct);
}); });