Skip to content

Commit dc2a34b

Browse files
committed
v1.1
Fixed tests
1 parent 98e91bc commit dc2a34b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/musab/sudoku_test.clj

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns musab.sudoku-test
22
(:require [clojure.test :refer :all]
3-
[musab.sudoku :refer [solve solve-new]]))
3+
[musab.sudoku :refer [format-board search parse-board-state]]
4+
[musab.brute-force :refer [solve]]))
45

56
(def default-boards
67
{:1 {:board [[0 0 0 1 0 6 0 0 0]
@@ -50,11 +51,22 @@
5051
[3 4 5 2 8 6 1 7 9]]}})
5152

5253
(deftest a-test
53-
(testing "Tests two examples."
54+
(testing "Tests both algorithms."
55+
;; Test bruteforce
5456
(is (=
55-
(mapv vec (first (solve-new (get-in default-boards [:1 :board]))))
57+
(mapv vec (first (solve (get-in default-boards [:1 :board]))))
5658
(get-in default-boards [:1 :solution])))
5759

5860
(is (=
59-
(mapv vec (first (solve-new (get-in default-boards [:2 :board]))))
61+
(mapv vec (first (solve (get-in default-boards [:2 :board]))))
62+
(get-in default-boards [:2 :solution])))
63+
;; Test Norvig CP
64+
(is (=
65+
(format-board (search
66+
(parse-board-state (get-in default-boards [:1 :board]))))
67+
(get-in default-boards [:1 :solution])))
68+
69+
(is (=
70+
(format-board (search
71+
(parse-board-state (get-in default-boards [:2 :board]))))
6072
(get-in default-boards [:2 :solution])))))

0 commit comments

Comments
 (0)