-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.lisp
28 lines (23 loc) · 1.35 KB
/
tests.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(in-package :wfc)
(clunit:defsuite logic ())
(clunit:deftest test/make-slices (logic)
(let ((img (make-array '(4 3) :initial-contents '((1 0 1) (0 1 0) (0 0 1) (0 0 0)))))
(clunit:assert-eql 4 (generic-cl:length (make-slices img 2 2)))
(clunit:assert-eql 1 (generic-cl:length (make-slices img (nrows img) (ncols img))))))
(clunit:deftest test/window (logic)
(let ((img (make-array '(3 3) :initial-contents '((1 2 3) (4 5 6) (7 8 9))))
(slice (make-array '(2 2) :initial-contents '((2 3) (5 6)))))
(clunit:assert-equalp slice (2d-window img 0 1 2 2))
(clunit:assert-condition sb-int:invalid-array-index-error (2d-window img 0 2 2 2))))
(clunit:deftest test/get-offsets (logic)
(let ((img1 (make-array '(3 3) :initial-contents '((1 2 3) (4 5 6) (7 8 9))))
(img2 (make-array '(2 2) :initial-contents '((1 0) (0 1)))))
(clunit:assert-equal '((0 0)) (allowable-offsets img1 img1))
(clunit:assert-equal 5 (generic-cl:length (allowable-offsets img2 img2)))))
(clunit:deftest test/randomness (logic)
(let* ((percent-tol 1)
(num-trials 2000)
(source-img (make-array '(1 2) :initial-contents '((1 0))))
(wfc (wave-function-collapse source-img 1 1 (list 1 num-trials))))
(clunit:assert-true (< (abs (- (* 1/2 num-trials) (generic-cl:count 0 wfc)))
(* percent-tol 2/100 num-trials)))))