blob: f09a92c2303a09a7ef205729cc1333192631adbe (
plain)
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
29
30
31
32
33
34
35
36
37
|
;(add-to-load-path "2024/")
(use-modules (aoc-utils)
(srfi srfi-64))
(test-begin "aoc-utils")
(test-group "matrix"
(define test-lst '((1 2 3)
(4 5 6)
(7 8 9)))
(test-equal (list-flatten test-lst) '(1 2 3 4 5 6 7 8 9))
(define m (make-matrix test-lst))
(test-equal (matrix-inner m) (list-flatten test-lst))
(test-equal (matrix-width m) 3)
(test-equal (matrix-height m) 3)
(test-equal (matrix-ref m 0 0) 1)
(test-equal (matrix-ref m 1 1) 5)
(test-equal (matrix-ref m 2 2) 9)
(test-assert (matrix-valid-x? m 0))
(test-assert (matrix-valid-x? m 1))
(test-assert (matrix-valid-x? m 2))
(test-assert (not (matrix-valid-x? m 3)))
(test-assert (not (matrix-valid-x? m -1)))
(test-assert (matrix-valid-y? m 0))
(test-assert (matrix-valid-y? m 1))
(test-assert (matrix-valid-y? m 2))
(test-assert (not (matrix-valid-y? m 3)))
(test-assert (not (matrix-valid-y? m -1)))
)
(test-end "aoc-utils")
|