-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_no.py
98 lines (77 loc) · 2.36 KB
/
test_no.py
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
#!/usr/bin/env python
"""
Unit tests for no.py
"""
import re
import unittest
import meow
import no
class TestIt(unittest.TestCase):
def sanity_check(self, word, out):
self.assertEqual(len(word), len(out))
# Check pattern
if len(word) > 1:
found = re.match("n[o]+", out, re.IGNORECASE)
self.assertTrue(found)
# Check caps
for i in range(len(word)):
self.assertEqual(word[i].isupper(), out[i].isupper())
def test_1_letter_word(self):
word = "I"
out = no.no(word)
self.sanity_check(word, out)
self.assertEqual(out, "N")
def test_2_letter_word(self):
word = "on"
out = no.no(word)
self.sanity_check(word, out)
self.assertEqual(out, "no")
def test_3_letter_word(self):
word = "The"
out = no.no(word)
self.sanity_check(word, out)
self.assertEqual(out, "Noo")
def test_4_letter_word(self):
word = "book"
out = no.no(word)
self.sanity_check(word, out)
self.assertEqual(out, "nooo")
def test_upper_4_letter_word(self):
word = "NOOO"
out = no.no(word)
self.sanity_check(word, out)
self.assertEqual(out, "NOOO")
def test_capped_4_letter_word(self):
word = "Nooo"
out = no.no(word)
self.sanity_check(word, out)
self.assertEqual(out, "Nooo")
def test_mixcapped_4_letter_word(self):
word = "NooO"
out = no.no(word)
self.sanity_check(word, out)
self.assertEqual(out, "NooO")
def test_5_letter_word(self):
word = "clock"
out = no.no(word)
self.sanity_check(word, out)
def test_6_letter_word(self):
word = "whales"
out = no.no(word)
self.sanity_check(word, out)
def test_13_letter_word(self):
word = "Extraordinary"
out = no.no(word)
self.sanity_check(word, out)
def test_line(self):
line = "On the bus"
out = meow.meow_meow(line, no.no)
self.assertEqual(out, "No noo noo")
def test_line_punctuation(self):
line = "On the bus? On the bus."
out = meow.meow_meow(line, no.no)
self.assertEqual(out, "No noo noo? No noo noo.")
self.assertEqual(out, "No noo noo? No noo noo.")
if __name__ == "__main__":
unittest.main()
# End of file