Files
python/exercises/practice/atbash-cipher/atbash_cipher_test.py

68 lines
1.9 KiB
Python
Raw Normal View History

2014-03-27 10:42:07 -03:00
import unittest
from atbash_cipher import (
decode,
encode,
)
2020-10-15 12:46:24 -04:00
# Tests adapted from `problem-specifications//canonical-data.json`
class AtbashCipherTest(unittest.TestCase):
2014-03-27 10:42:07 -03:00
def test_encode_yes(self):
self.assertEqual(encode("yes"), "bvh")
def test_encode_no(self):
self.assertEqual(encode("no"), "ml")
def test_encode_omg(self):
self.assertEqual(encode("OMG"), "lnt")
def test_encode_spaces(self):
self.assertEqual(encode("O M G"), "lnt")
def test_encode_mindblowingly(self):
self.assertEqual(encode("mindblowingly"), "nrmwy oldrm tob")
2014-03-27 10:42:07 -03:00
def test_encode_numbers(self):
self.assertEqual(encode("Testing,1 2 3, testing."), "gvhgr mt123 gvhgr mt")
def test_encode_deep_thought(self):
self.assertEqual(encode("Truth is fiction."), "gifgs rhurx grlm")
def test_encode_all_the_letters(self):
self.assertEqual(
encode("The quick brown fox jumps over the lazy dog."),
"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt",
)
2014-03-27 10:42:07 -03:00
def test_decode_exercism(self):
self.assertEqual(decode("vcvix rhn"), "exercism")
2014-03-27 10:42:07 -03:00
def test_decode_a_sentence(self):
self.assertEqual(
decode("zmlyh gzxov rhlug vmzhg vkkrm thglm v"),
"anobstacleisoftenasteppingstone",
)
def test_decode_numbers(self):
self.assertEqual(decode("gvhgr mt123 gvhgr mt"), "testing123testing")
def test_decode_all_the_letters(self):
self.assertEqual(
decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"),
"thequickbrownfoxjumpsoverthelazydog",
)
def test_decode_with_too_many_spaces(self):
self.assertEqual(decode("vc vix r hn"), "exercism")
def test_decode_with_no_spaces(self):
self.assertEqual(
decode("zmlyhgzxovrhlugvmzhgvkkrmthglmv"), "anobstacleisoftenasteppingstone"
)
2014-03-27 10:42:07 -03:00
if __name__ == "__main__":
2014-03-27 10:42:07 -03:00
unittest.main()