diff options
author | Prefetch | 2024-03-02 19:36:12 +0100 |
---|---|---|
committer | Prefetch | 2024-03-02 19:36:12 +0100 |
commit | 1fbb07c54523c7a576bfff1cb689e155dd55f15a (patch) | |
tree | 7aa9f92a7d99ae9203b538803b7efefd846b67e0 /01/test.scm | |
parent | af589b238c1d51960d8af3b36041aca2bad7855b (diff) |
Add first five days
Diffstat (limited to '01/test.scm')
-rw-r--r-- | 01/test.scm | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/01/test.scm b/01/test.scm new file mode 100644 index 0000000..6dbff81 --- /dev/null +++ b/01/test.scm @@ -0,0 +1,43 @@ +(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" + "1122" 3) +(test-part1 "part 1 example 2" + "1111" 4) +(test-part1 "part 1 example 3" + "1234" 0) +(test-part1 "part 1 example 4" + "91212129" 9) + +(printf "Part 2 tests:\n") + +(define (test-part2 name input expected) + (run-test name solve-part2 input expected)) + +(test-part2 "part 2 example 1" + "1212" 6) +(test-part2 "part 2 example 2" + "1221" 0) +(test-part2 "part 2 example 3" + "123425" 4) +(test-part2 "part 2 example 4" + "123123" 12) +(test-part2 "part 2 example 5" + "12131415" 4) |