;; -*- 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")