Skip to content

Commit c7d37fc

Browse files
authored
Merge pull request #47 from UBC-MDS/Add_4_tests
Add 4 tests
2 parents 24c8602 + 348bc1e commit c7d37fc

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'''
2+
Add 4 unit test to trigger checks
3+
'''
4+
import pytest
5+
from sudoku_validation.row_validation import row_validation
6+
7+
def test_validate_rows_valid():
8+
board = [
9+
[1,2,3,4,5,6,7,8,9],
10+
[4,5,6,7,8,9,1,2,3],
11+
[7,8,9,1,2,3,4,5,6],
12+
[2,3,4,5,6,7,8,9,1],
13+
[5,6,7,8,9,1,2,3,4],
14+
[8,9,1,2,3,4,5,6,7],
15+
[3,4,5,6,7,8,9,1,2],
16+
[6,7,8,9,1,2,3,4,5],
17+
[9,1,2,3,4,5,6,7,8],
18+
]
19+
assert row_validation(board)
20+
21+
def test_validate_rows_duplicate():
22+
board = [
23+
[1,1,3,4,5,6,7,8,9], # duplicate 1
24+
] + [[0]*9 for _ in range(8)]
25+
assert not row_validation(board)
26+
27+
def test_validate_rows_non_numeric():
28+
board = [
29+
["a",2,3,4,5,6,7,8,9],
30+
] + [[0]*9 for _ in range(8)]
31+
with pytest.raises(ValueError):
32+
row_validation(board)
33+
34+
def test_validate_rows_short_row():
35+
board = [
36+
[1,2,3], # too short
37+
] + [[0]*9 for _ in range(8)]
38+
with pytest.raises(ValueError):
39+
row_validation(board)

0 commit comments

Comments
 (0)