/
test.py
43 lines (31 loc) · 1.25 KB
/
test.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
import unittest
from pig_latin import piglatin_tranlator as translate
class TestPigLatin(unittest.TestCase):
def test_word_starts_with_consonant(self):
pig = translate('pig')
banana = translate('banana')
self.assertEqual(pig, 'igpay')
self.assertEqual(banana, 'ananabay')
def test_word_begins_with_consonnant_cluster(self):
smile = translate('smile')
glove = translate('glove')
string = translate('string')
self.assertEqual(smile, 'ilesmay')
self.assertEqual(glove, 'oveglay')
self.assertEqual(string, 'ingstray')
def test_word_begins_with_voye(self):
eat = translate('eat')
omelet = translate('omelet')
self.assertEqual(eat, 'eatay')
self.assertEqual(omelet, 'omeletay')
def test_full_sentence(self):
result = translate('Hello, my name is Alice.')
self.assertEqual(result, 'Ellohay, ymay amenay isay Aliceay.')
def test_non_string_input(self):
result = translate(392837263)
self.assertEqual(result, 'The phrase to translate should be a string')
def test_empty_string(self):
result = translate('')
self.assertEqual(result, '')
if __name__ == '__main__':
unittest.main()