-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrotational_cipher_test.py
46 lines (31 loc) · 1.31 KB
/
rotational_cipher_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
44
45
46
import unittest
from rotational_cipher import (
rotate,
)
# Tests adapted from `problem-specifications//canonical-data.json`
class RotationalCipherTest(unittest.TestCase):
def test_rotate_a_by_0_same_output_as_input(self):
self.assertEqual(rotate("a", 0), "a")
def test_rotate_a_by_1(self):
self.assertEqual(rotate("a", 1), "b")
def test_rotate_a_by_26_same_output_as_input(self):
self.assertEqual(rotate("a", 26), "a")
def test_rotate_m_by_13(self):
self.assertEqual(rotate("m", 13), "z")
def test_rotate_n_by_13_with_wrap_around_alphabet(self):
self.assertEqual(rotate("n", 13), "a")
def test_rotate_capital_letters(self):
self.assertEqual(rotate("OMG", 5), "TRL")
def test_rotate_spaces(self):
self.assertEqual(rotate("O M G", 5), "T R L")
def test_rotate_numbers(self):
self.assertEqual(rotate("Testing 1 2 3 testing", 4), "Xiwxmrk 1 2 3 xiwxmrk")
def test_rotate_punctuation(self):
self.assertEqual(rotate("Let's eat, Grandma!", 21), "Gzo'n zvo, Bmviyhv!")
def test_rotate_all_letters(self):
self.assertEqual(
rotate("The quick brown fox jumps over the lazy dog.", 13),
"Gur dhvpx oebja sbk whzcf bire gur ynml qbt.",
)
if __name__ == "__main__":
unittest.main()