Files
python/exercises/crypto-square/crypto_square_test.py

51 lines
1.5 KiB
Python
Raw Normal View History

import unittest
from crypto_square import cipher_text
2014-04-09 14:20:52 -03:00
# Tests adapted from `problem-specifications//canonical-data.json` @ v3.2.0
2014-04-09 14:20:52 -03:00
class CryptoSquareTest(unittest.TestCase):
def test_empty_plaintext_results_in_an_empty_ciphertext(self):
value = ""
expected = ""
self.assertEqual(cipher_text(value), expected)
2014-04-09 14:20:52 -03:00
def test_lowercase(self):
value = "A"
expected = "a"
self.assertEqual(cipher_text(value), expected)
def test_remove_spaces(self):
value = " b "
expected = "b"
self.assertEqual(cipher_text(value), expected)
def test_remove_punctuation(self):
value = "@1,%!"
expected = "1"
self.assertEqual(cipher_text(value), expected)
def test_9_character_plaintext_results_in_3_chunks_of_3_characters(self):
value = "This is fun!"
expected = "tsf hiu isn"
self.assertEqual(cipher_text(value), expected)
def test_8_character_plaintext_results_in_3_chunks_the_last_one_with_a_trailing_space(
self
):
value = "Chill out."
expected = "clu hlt io "
self.assertEqual(cipher_text(value), expected)
def test_54_character_plaintext_results_in_7_chunks_the_last_two_with_trailing_spaces(
self
):
value = "If man was meant to stay on the ground, god would have given us roots."
expected = "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau "
self.assertEqual(cipher_text(value), expected)
if __name__ == "__main__":
2014-04-09 14:20:52 -03:00
unittest.main()