From 1a81d370510a01b482aae8033704d1a0523d11b7 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Thu, 5 Dec 2024 08:57:25 -0300 Subject: Add day 04 of 2024 --- 2024/tests.scm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 2024/tests.scm (limited to '2024/tests.scm') 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") -- cgit v1.2.3-70-g09d2