blob: 88e019b216f747bdf2ef3eba60c0092746c3e4ea (
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
;; -*- compile-command: "guile -L . dhhieft-test.scm"; -*-
(use-modules (srfi srfi-64)
(dhhieft))
(test-begin "harness")
(test-equal "string->vowels none"
""
(string->vowels ""))
(test-equal "string->vowels vowels"
"aeiou"
(string->vowels "aeiou"))
(test-equal "string->vowels single consonant"
""
(string->vowels "x"))
(test-equal "string->vowels mix"
"uoiea"
(string->vowels "uywoigxebwa"))
(test-assert "three-vowels? empty string"
(not (three-vowels? "")))
(test-assert "three-vowels? two vowels"
(not (three-vowels? "axkoh")))
(test-assert "three-vowels? exactly three vowels"
(three-vowels? "axkioh"))
(test-assert "three-vowels? four vowels"
(three-vowels? "axkiohe"))
(test-assert "three-vowels? uppercase vowels"
(three-vowels? "AXKIOHE"))
(test-assert "repeated-char? empty string"
(not (repeated-char? "" 0)))
(test-assert "repeated-char? single char"
(not (repeated-char? "a" 0)))
(test-assert "repeated-char? single repeat"
(repeated-char? "aa" 0))
(test-assert "repeated-char? single repeat other"
(repeated-char? "xx" 0))
(test-assert "repeated-char? single repeat break"
(not (repeated-char? "a?a" 0)))
(test-assert "repeated-char? needle-in-hay"
(repeated-char? "ugknbfddgicrmopn" 0))
(test-assert "favorable? ugknbfddgicrmopn"
(favorable-string? "ugknbfddgicrmopn" #f))
(test-assert "favorable? aaa"
(favorable-string? "aaa" #f))
(test-assert "favorable? jchzalrnumimnmhp"
(not (favorable-string? "jchzalrnumimnmhp" #f))) ;; no double letter
(test-assert "favorable? habegwjzuzvuyypu"
(not (favorable-string? "habegwjzuzvuyypu" #f))) ;; contains ab
(test-assert "favorable? hacdegwzuvuyypxu"
(not (favorable-string? "hacdegwzuvuyypxu" #f))) ;; contains cd
(test-assert "favorable? haegwjzuvuqyypqu"
(not (favorable-string? "haegwjzuvuqyypqu" #f))) ;; contains pq
(test-assert "favorable? haegwjzuvuyypxyu"
(not (favorable-string? "haegwjzuvuyypxyu" #f))) ;; contains xy
(test-assert "favorable? dvszwmarrgswjxmb"
(not (favorable-string? "dvszwmarrgswjxmb" #f))) ;; single vowel
(test-equal "file run through"
2
(dhhieft "
ugknbfddgicrmopn
aaa
jchzalrnumimnmhp
haegwjzuvuyypxyu
dvszwmarrgswjxmb" #f))
(test-assert "repeated-char? over-extend-lookahead"
(not (repeated-char? "a" 3)))
(test-assert "repeated-char? single gap false"
(not (repeated-char? "aab" 1)))
(test-assert "repeated-char single gap simple"
(repeated-char? "aba" 1))
(test-assert "repeated-char double gap simple false"
(not (repeated-char? "acab" 2)))
(test-assert "repeated-char double gap simple"
(repeated-char? "acba" 2))
(test-assert "repeated-char double gap simple"
(repeated-char? "acba" 2))
(test-assert "repeated-char single gap needle in hay"
(repeated-char? "abcdefeghi" 1))
(test-assert "long-distance-match? empty"
(not (long-distance-match? "")))
(test-assert "long-distance-match? single char"
(not (long-distance-match? "a")))
(test-assert "long-distance-match? single repeat"
(not (long-distance-match? "aa")))
(test-assert "long-distance-match? match but shared"
(not (long-distance-match? "aaa")))
(test-assert "long-distance-match? simple match"
(long-distance-match? "abab"))
(test-assert "long-distance-match? match alongside share"
(long-distance-match? "aaaa"))
(test-assert "long-distance-match? simple fail"
(not (long-distance-match? "aaba")))
(test-assert "long-distance-match? far match"
(long-distance-match? "aabcdefgaa"))
(test-assert "long-distance-match? needle-in-haystack match"
(long-distance-match? "qjhvhtzxzqqjkmpb"))
(test-assert "long-distance-match? needle-in-haystack no match"
(not (long-distance-match? "ieodomkazucvgmuy")))
(test-assert "favorable? p2 meets none"
(not (favorable-string? "" #t)))
(test-assert "favorable? p2 no long-distance match"
(not (favorable-string? "ieodomkazucvgmuy" #t)))
(test-assert "favorable? p2 no repeat-char"
(not (favorable-string? "uurcxstgmygtbstg" #t)))
(test-assert "favorable? p2 meets all"
(favorable-string? "qjhvhtzxzqqjkmpb" #t))
(test-assert "favorable? p2 meets all other"
(favorable-string? "xxyxx" #t))
(test-equal "file run through p2"
3
(dhhieft "
aaaa
qjhvhtzxzqqjkmpb
xxyxx
uurcxstgmygtbstg
ieodomkazucvgmuy" #t))
(test-end "harness")
|