From 1fbb07c54523c7a576bfff1cb689e155dd55f15a Mon Sep 17 00:00:00 2001 From: Prefetch Date: Sat, 2 Mar 2024 19:36:12 +0100 Subject: Add first five days --- 04/test.scm | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 04/test.scm (limited to '04/test.scm') diff --git a/04/test.scm b/04/test.scm new file mode 100644 index 0000000..564016a --- /dev/null +++ b/04/test.scm @@ -0,0 +1,41 @@ +(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" + '("aa bb cc dd ee") 1) +(test-part1 "part 1 example 2" + '("aa bb cc dd aa") 0) +(test-part1 "part 1 example 3" + '("aa bb cc dd aaa") 1) + +(printf "Part 2 tests:\n") + +(define (test-part2 name input expected) + (run-test name solve-part2 input expected)) + +(test-part2 "part 2 example 1" + '("abcde fghij") 1) +(test-part2 "part 2 example 2" + '("abcde xyz ecdab") 0) +(test-part2 "part 2 example 3" + '("a ab abc abd abf abj") 1) +(test-part2 "part 2 example 4" + '("iiii oiii ooii oooi oooo") 1) +(test-part2 "part 2 example 5" + '("oiii ioii iioi iiio") 0) -- cgit v1.2.3