|
1
|
|
|
import unittest |
|
2
|
|
|
|
|
3
|
|
|
from hidden_word import checkio |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
class Tests(unittest.TestCase): |
|
7
|
|
|
TESTS = { |
|
8
|
|
|
"Basics": [ |
|
9
|
|
|
{ |
|
10
|
|
|
"input": [ |
|
11
|
|
|
"""DREAMING of apples on a wall, |
|
12
|
|
|
And dreaming often, dear, |
|
13
|
|
|
I dreamed that, if I counted all, |
|
14
|
|
|
-How many would appear?""", |
|
15
|
|
|
"ten", |
|
16
|
|
|
], |
|
17
|
|
|
"answer": [2, 14, 2, 16], |
|
18
|
|
|
}, |
|
19
|
|
|
{ |
|
20
|
|
|
"input": [ |
|
21
|
|
|
"""He took his vorpal sword in hand: |
|
22
|
|
|
Long time the manxome foe he sought-- |
|
23
|
|
|
So rested he by the Tumtum tree, |
|
24
|
|
|
And stood awhile in thought. |
|
25
|
|
|
And as in uffish thought he stood, |
|
26
|
|
|
The Jabberwock, with eyes of flame, |
|
27
|
|
|
Came whiffling through the tulgey wood, |
|
28
|
|
|
And burbled as it came!""", |
|
29
|
|
|
"noir", |
|
30
|
|
|
], |
|
31
|
|
|
"answer": [4, 16, 7, 16], |
|
32
|
|
|
}, |
|
33
|
|
|
], |
|
34
|
|
|
"Extra": [ |
|
35
|
|
|
{ |
|
36
|
|
|
"input": [ |
|
37
|
|
|
"""Twas brillig, and the slithy toves |
|
38
|
|
|
Did gyre and gimble in the wabe; |
|
39
|
|
|
All mimsy were the borogoves, |
|
40
|
|
|
And the mome raths outgrabe.""", |
|
41
|
|
|
"them", |
|
42
|
|
|
], |
|
43
|
|
|
"answer": [4, 4, 4, 7], |
|
44
|
|
|
}, |
|
45
|
|
|
{ |
|
46
|
|
|
"input": [ |
|
47
|
|
|
"""Twas brillig, and the slithy toves |
|
48
|
|
|
Did gyre and gimble in the wabe; |
|
49
|
|
|
All mimsy were the borogoves, |
|
50
|
|
|
And the mome raths outgrabe.""", |
|
51
|
|
|
"stog", |
|
52
|
|
|
], |
|
53
|
|
|
"answer": [1, 19, 4, 19], |
|
54
|
|
|
}, |
|
55
|
|
|
{ |
|
56
|
|
|
"input": [ |
|
57
|
|
|
"""One, two! One, two! And through and through |
|
58
|
|
|
The vorpal blade went snicker-snack! |
|
59
|
|
|
He left it dead, and with its head |
|
60
|
|
|
He went galumphing back.""", |
|
61
|
|
|
"back", |
|
62
|
|
|
], |
|
63
|
|
|
"answer": [4, 17, 4, 20], |
|
64
|
|
|
}, |
|
65
|
|
|
{ |
|
66
|
|
|
"input": [ |
|
67
|
|
|
"""And hast thou slain the Jabberwock? |
|
68
|
|
|
Come to my arms, my beamish boy! |
|
69
|
|
|
O frabjous day! Callooh! Callay!' |
|
70
|
|
|
He chortled in his joy. |
|
71
|
|
|
'Twas brillig, and the slithy toves |
|
72
|
|
|
Did gyre and gimble in the wabe; |
|
73
|
|
|
All mimsy were the borogoves, |
|
74
|
|
|
And the mome raths outgrabe.'""", |
|
75
|
|
|
"tomy", |
|
76
|
|
|
], |
|
77
|
|
|
"answer": [2, 5, 2, 8], |
|
78
|
|
|
}, |
|
79
|
|
|
{ |
|
80
|
|
|
"input": [ |
|
81
|
|
|
"""Humpty Dumpty sat on a wall: |
|
82
|
|
|
Humpty Dumpty had a great fall. |
|
83
|
|
|
All the King's horses and all the King's men |
|
84
|
|
|
Couldn't put Humpty Dumpty in his place again.""", |
|
85
|
|
|
"oast", |
|
86
|
|
|
], |
|
87
|
|
|
"answer": [1, 16, 4, 16], |
|
88
|
|
|
}, |
|
89
|
|
|
{ |
|
90
|
|
|
"input": [ |
|
91
|
|
|
"""Hi all! |
|
92
|
|
|
And all goodbye! |
|
93
|
|
|
Of course goodbye. |
|
94
|
|
|
or not""", |
|
95
|
|
|
"haoo", |
|
96
|
|
|
], |
|
97
|
|
|
"answer": [1, 1, 4, 1], |
|
98
|
|
|
}, |
|
99
|
|
|
{ |
|
100
|
|
|
"input": [ |
|
101
|
|
|
"""xa |
|
102
|
|
|
xb |
|
103
|
|
|
x""", |
|
104
|
|
|
"ab", |
|
105
|
|
|
], |
|
106
|
|
|
"answer": [1, 2, 2, 2], |
|
107
|
|
|
}, |
|
108
|
|
|
], |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
def test_Basics(self): |
|
112
|
|
|
for i in self.TESTS['Basics']: |
|
113
|
|
|
assert checkio(*i['input']) == i['answer'] |
|
114
|
|
|
|
|
115
|
|
|
def test_Extra(self): |
|
116
|
|
|
for i in self.TESTS['Extra']: |
|
117
|
|
|
assert checkio(*i['input']) == i['answer'] |
|
118
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
if __name__ == "__main__": # pragma: no cover |
|
121
|
|
|
unittest.main() |
|
122
|
|
|
|