-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_encode.py
46 lines (35 loc) · 1.52 KB
/
test_encode.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
import unittest
import encode
class TestEncode(unittest.TestCase):
def test_that_a_encodes_to_n(self):
result = encode.character_encode('a')
self.assertEqual('n', result)
def test_that_a_does_not_equal_c(self):
result = encode.character_encode('a')
self.assertNotEqual('c', result)
def test_that_s_encodes_to_f(self):
result = encode.character_encode('s')
self.assertEqual('f', result)
def test_that_string_encodes_to_correct_value(self):
result = encode.encode_string('test')
self.assertEqual('grfg', result)
def test_that_we_convert_character_to_number(self):
result = encode.char_to_num('a')
self.assertTrue(type(result) is int)
def test_that_char_to_num_returns_ascii_value(self):
result = encode.char_to_num('a')
self.assertEqual(ord('a'), result)
def test_that_we_rotate_thirteen(self):
result = encode.char_to_encoded('a')
self.assertEqual(110, result)
def test_that_we_can_convert_num_to_char(self):
result = encode.num_to_char(110)
self.assertEqual('n', result)
def test_that_char_to_encoded_does_not_return_a_value_greater_than_end_of_alphabet(self):
result = encode.char_to_encoded('z')
self.assertTrue(122 > result)
def test_full_alphabet(self):
test_string = "thequickbrownfoxjumpsoverthelazydog"
encoded = encode.encode_string(test_string)
decoded = encode.encode_string(encoded)
self.assertEqual(test_string, decoded)