summaryrefslogtreecommitdiff
path: root/03/test.scm
diff options
context:
space:
mode:
Diffstat (limited to '03/test.scm')
-rw-r--r--03/test.scm42
1 files changed, 42 insertions, 0 deletions
diff --git a/03/test.scm b/03/test.scm
new file mode 100644
index 0000000..0f7817c
--- /dev/null
+++ b/03/test.scm
@@ -0,0 +1,42 @@
+(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 (= 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 0)
+(test-part1 "part 1 example 2"
+ 12 3)
+(test-part1 "part 1 example 3"
+ 23 2)
+(test-part1 "part 1 example 4"
+ 1024 31)
+
+(printf "Part 2 tests:\n")
+
+(define (test-part2 name input expected)
+ (run-test name solve-part2 input expected))
+
+(test-part2 "part 2 example 1"
+ 1 2)
+(test-part2 "part 2 example 2"
+ 23 25)
+(test-part2 "part 2 example 3"
+ 133 142)
+(test-part2 "part 2 example 4"
+ 747 806)
+