From 757b98fb30e75d7698a0986184d0303224db156c Mon Sep 17 00:00:00 2001
From: Prefetch
Date: Tue, 26 Mar 2024 21:41:32 +0100
Subject: Publish days 6-10
---
09/test.scm | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
create mode 100644 09/test.scm
(limited to '09/test.scm')
diff --git a/09/test.scm b/09/test.scm
new file mode 100644
index 0000000..6d232da
--- /dev/null
+++ b/09/test.scm
@@ -0,0 +1,68 @@
+(import (chezscheme))
+
+; Where the magic happens
+(import (lib))
+
+; My quick-and-dirty unit testing framework (copied for each day)
+(define (run-test name proc input expected)
+ (let ((result (proc input)))
+ (if (equal? result expected)
+ (printf "\x1b;[32;1mPASS\x1b;[0m: ~a\n"
+ name)
+ (printf "\x1b;[31;1mFAIL\x1b;[0m: ~a: got ~a, expected ~a\n"
+ name result expected))))
+
+(printf "Part 1 tests:\n")
+
+(define (test-part1 name input expected)
+ (run-test name solve-part1 input expected))
+
+(test-part1 "part 1 example 1"
+ "{}" 1)
+
+(test-part1 "part 1 example 2"
+ "{{{}}}" 6)
+
+(test-part1 "part 1 example 3"
+ "{{},{}}" 5)
+
+(test-part1 "part 1 example 4"
+ "{{{},{},{{}}}}" 16)
+
+(test-part1 "part 1 example 5"
+ "{,,,}" 1)
+
+(test-part1 "part 1 example 6"
+ "{{},{},{},{}}" 9)
+
+(test-part1 "part 1 example 7"
+ "{{},{},{},{}}" 9)
+
+(test-part1 "part 1 example 8"
+ "{{},{},{},{}}" 3)
+
+(printf "Part 2 tests:\n")
+
+(define (test-part2 name input expected)
+ (run-test name solve-part2 input expected))
+
+(test-part2 "part 2 example 1"
+ "{<>}" 0)
+
+(test-part2 "part 2 example 2"
+ "{}" 17)
+
+(test-part2 "part 2 example 3"
+ "{<<<<>}" 3)
+
+(test-part2 "part 2 example 4"
+ "{<{!>}>}" 2)
+
+(test-part2 "part 2 example 5"
+ "{}" 0)
+
+(test-part2 "part 2 example 6"
+ "{>}" 0)
+
+(test-part2 "part 2 example 7"
+ "{<{o\"i!a,<{i}" 10)
--
cgit v1.2.3