-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestCaesar.py
38 lines (28 loc) · 1.19 KB
/
testCaesar.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
import unittest
import Caesar
class TestCryptMethods(unittest.TestCase):
"""Tests for Caesar.py"""
cryptInput = ['encrypt', 'Encrypt', 'decrypt', 'Decrypt']
encryptInput = ['foo', 'bar', 'Hello World', 'xyz', '101010111']
decryptInput = ['ktt', 'gfw', 'Mjqqt Btwqi', 'cde', '101010111']
def test_crypt(self):
result = []
for i in range(len(self.cryptInput)):
result.append(Caesar.crypt(self.cryptInput[i]))
self.assertTrue(result[0])
self.assertTrue(result[1])
self.assertFalse(result[2])
self.assertFalse(result[3])
def test_encryption(self):
result = []
for i in range(len(self.encryptInput)):
result.append(Caesar.encryption(self.encryptInput[i], 5))
self.assertEqual(result[i], self.decryptInput[i])
def test_decryption(self):
result = []
for i in range(len(self.decryptInput)):
result.append(Caesar.decryption(self.decryptInput[i], 5))
self.assertEqual(result[i], self.encryptInput[i])
#TODO: test decryption runs appropriately
if __name__ == "__main__":
unittest.main()