summaryrefslogtreecommitdiff
path: root/password-philosophy/pp-test.scm
blob: 7641c4a8730efa5046599d5de1d57e369c638346 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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")