finish implementing sudoku-solver.js and writing unit test

This commit is contained in:
StevanFreeborn
2022-05-26 19:38:45 -05:00
parent f99db6a4a5
commit 44295dc22c
5 changed files with 254 additions and 87 deletions
+30 -1
View File
@@ -51,7 +51,7 @@ suite('UnitTests', () => {
const input = puzzlesAndSolutions[0][0];
const row = 'A';
const column = '2';
const value = '8';
const value = '1';
assert.equal(solver.checkRowPlacement(input, row, column, value), false);
done();
@@ -106,5 +106,34 @@ suite('UnitTests', () => {
});
test('solve(puzzleString) valid puzzle string', (done) => {
const puzzle = puzzlesAndSolutions[0][0];
const solution = puzzlesAndSolutions[0][1];
assert.equal(solver.solve(puzzle), solution);
done();
});
test('solve(puzzleString) invalid puzzle string', (done) => {
const puzzle = puzzlesAndSolutions[0][0]+'0';
assert.equal(solver.solve(puzzle), false);
done();
});
test('solve(puzzleString) uncomplete puzzle yields expected solution', (done) => {
const puzzle = puzzlesAndSolutions[0][0];
const solution = puzzlesAndSolutions[0][1];
assert.equal(solver.solve(puzzle), solution);
done();
});
});