From 116aa074b190599e38a43bd6a8602a05cebdfb5d Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 10 Jun 2024 18:13:57 -0600 Subject: AoC 2022.1 p1+2 --- calorie-counting/cc-test.scm | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 calorie-counting/cc-test.scm (limited to 'calorie-counting/cc-test.scm') diff --git a/calorie-counting/cc-test.scm b/calorie-counting/cc-test.scm new file mode 100644 index 0000000..59c6bfe --- /dev/null +++ b/calorie-counting/cc-test.scm @@ -0,0 +1,61 @@ +;; -*- compile-command: "guile -L . cc-test.scm"; -*- +(use-modules (srfi srfi-64) + (cc)) + +(test-begin "harness") + + +(test-equal "Find largest 1 of 1" + 10000 + (sum-largest-n '(10000) 1)) + +(test-equal "Find largest 1 of 2" + 10001 + (sum-largest-n '(10001 6000) 1)) + +(test-equal "Find largest 1 of 2 requires sort" + 10002 + (sum-largest-n '(6000 10002) 1)) + +(test-equal "Find largest 2 of 4 requires sort" + 30000 + (sum-largest-n '(6000 10000 20000 100) 2)) + +(test-equal "No empty line to split" + '("Newlines\nmust be doubled!") + (split-on-empty-line "Newlines\nmust be doubled!")) + +(test-equal "Empty line split" + '("Through" "the middle!") + (split-on-empty-line "Through\n\nthe middle!")) + +(test-equal "Sum one number" + 10000 + (sum-grouped-string "10000")) + +(test-equal "Sum two numbers" + 10100 + (sum-grouped-string "10000\n100")) + +(test-equal "Single second group less" + 10000 + (cc "10000\n\n500" 1)) + +(test-equal "Single second group more" + 10000 + (cc "500\n\n10000" 1)) + +(test-equal "Add single group greater than second group" + 10500 + (cc "10000\n500\n\n10300" 1)) + +(test-equal "Add single group less than second group" + 10700 + (cc "10000\n500\n\n10700" 1)) + +(test-equal "Example puzzle input" + 24000 + (cc "1000\n2000\n3000\n\n4000\n\n5000\n6000\n\n7000\n8000\n9000\n\n10000" 1)) + + +(test-end "harness") -- cgit v1.2.3