aboutsummaryrefslogtreecommitdiff
path: root/2024/tests.scm
diff options
context:
space:
mode:
Diffstat (limited to '2024/tests.scm')
-rw-r--r--2024/tests.scm37
1 files changed, 37 insertions, 0 deletions
diff --git a/2024/tests.scm b/2024/tests.scm
new file mode 100644
index 0000000..f09a92c
--- /dev/null
+++ b/2024/tests.scm
@@ -0,0 +1,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")