summaryrefslogtreecommitdiff
path: root/calorie-counting/cc-test.scm
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2024-06-10 18:13:57 -0600
committerbd <bdunahu@operationnull.com>2024-06-10 18:16:52 -0600
commit116aa074b190599e38a43bd6a8602a05cebdfb5d (patch)
tree179b2f48c84b243d0ad84dbe23ef7d813349d79b /calorie-counting/cc-test.scm
parent9e149cb6e6f1bf002fb1abc2b79c77afc3d1d36c (diff)
AoC 2022.1 p1+2
Diffstat (limited to 'calorie-counting/cc-test.scm')
-rw-r--r--calorie-counting/cc-test.scm61
1 files changed, 61 insertions, 0 deletions
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")