-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathatbash_cipher_test.py
More file actions
47 lines (32 loc) · 1.43 KB
/
atbash_cipher_test.py
File metadata and controls
47 lines (32 loc) · 1.43 KB
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
import unittest
from atbash_cipher import decode, encode
class AtbashCipherTest(unittest.TestCase):
def test_encode_no(self):
self.assertMultiLineEqual("ml", encode("no"))
def test_encode_yes(self):
self.assertMultiLineEqual("bvh", encode("yes"))
def test_encode_OMG(self):
self.assertMultiLineEqual("lnt", encode("OMG"))
def test_encode_O_M_G(self):
self.assertMultiLineEqual("lnt", encode("O M G"))
def test_encode_long_word(self):
self.assertMultiLineEqual("nrmwy oldrm tob", encode("mindblowingly"))
def test_encode_numbers(self):
self.assertMultiLineEqual("gvhgr mt123 gvhgr mt",
encode("Testing, 1 2 3, testing."))
def test_encode_sentence(self):
self.assertMultiLineEqual("gifgs rhurx grlm",
encode("Truth is fiction."))
def test_encode_all_things(self):
plaintext = "The quick brown fox jumps over the lazy dog."
ciphertext = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
self.assertMultiLineEqual(ciphertext, encode(plaintext))
def test_decode_word(self):
self.assertMultiLineEqual("exercism", decode("vcvix rhn"))
def test_decode_sentence(self):
self.assertMultiLineEqual(
"anobstacleisoftenasteppingstone",
decode("zmlyh gzxov rhlug vmzhg vkkrm thglm v")
)
if __name__ == '__main__':
unittest.main()