summaryrefslogtreecommitdiff
path: root/password-philosophy/pp-test.scm
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2024-06-09 20:28:10 -0600
committerbd <bdunahu@operationnull.com>2024-06-09 20:28:10 -0600
commitf3ae22b302a298984df62a4aaba275c15d010072 (patch)
tree099398ef5ca7b1f462d54ba78b02e0999bdf2078 /password-philosophy/pp-test.scm
parent2c85332e1e402653ed44ea1a5248cb7d11259389 (diff)
AoC 2020.2 p1
Diffstat (limited to 'password-philosophy/pp-test.scm')
-rw-r--r--password-philosophy/pp-test.scm72
1 files changed, 72 insertions, 0 deletions
diff --git a/password-philosophy/pp-test.scm b/password-philosophy/pp-test.scm
new file mode 100644
index 0000000..7641c4a
--- /dev/null
+++ b/password-philosophy/pp-test.scm
@@ -0,0 +1,72 @@
+;; -*- compile-command: "guile -L . pp-test.scm"; -*-
+(use-modules (srfi srfi-64)
+ (pp))
+
+(test-begin "harness")
+
+
+(test-equal "no occurrences"
+ 0
+ (count-occurrences "" #\f))
+
+(test-equal "one occurrences"
+ 1
+ (count-occurrences "f" #\f))
+
+(test-equal "one mixed occurrences"
+ 1
+ (count-occurrences "fc" #\c))
+
+(test-equal "two mixed occurrences"
+ 2
+ (count-occurrences "zzf9ct5f" #\f))
+
+(test-assert "Single X"
+ (valid-password? "X" #\X '(1 . 1)))
+
+(test-assert "Single X extra"
+ (valid-password? "the X marks the spot" #\X '(1 . 1)))
+
+(test-assert "Double X allowed"
+ (valid-password? "X lots of bad things use the logo of just an X" #\X '(1 . 2)))
+
+(test-assert "Double X forced"
+ (valid-password? "X lots of bad things use the logo of just an X" #\X '(2 . 2)))
+
+(test-assert "Double X failed"
+ (not (valid-password? "lots of bad things use the logo of just an X" #\X '(2 . 2))))
+
+(test-equal "Parse line 1"
+ '("abcde" #\a (1 . 3))
+ (parse-line "1-3 a: abcde"))
+
+(test-equal "Parse line 2"
+ '("ccccccccc" #\c (2 . 9))
+ (parse-line "2-9 c: ccccccccc"))
+
+(test-equal "Count valid 0"
+ 0
+ (pp "1-3 a: bcde
+1-3 b: cdefg
+2-9 c: cccccccccc"))
+
+(test-equal "Count valid 1"
+ 1
+ (pp "1-3 a: abcde
+1-3 b: cdefg
+2-9 c: cccccccccc"))
+
+(test-equal "Count valid 2"
+ 2
+ (pp "1-3 a: abcde
+1-3 b: cdefg
+2-9 c: ccccccccc"))
+
+(test-equal "Count valid 3"
+ 3
+ (pp "1-3 a: abcde
+1-3 b: cdbfg
+2-9 c: ccccccccc"))
+
+
+(test-end "harness")