forked from reingart/exercism
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcrypto_square_test.py
55 lines (44 loc) · 1.77 KB
/
crypto_square_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
47
48
49
50
51
52
53
54
55
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/crypto-square/canonical-data.json
# File last updated on 2023-07-19
import unittest
from crypto_square import (
cipher_text,
)
class CryptoSquareTest(unittest.TestCase):
def test_empty_plaintext_results_in_an_empty_ciphertext(self):
value = ""
expected = ""
self.assertEqual(cipher_text(value), expected)
def test_normalization_results_in_empty_plaintext(self):
value = "... --- ..."
expected = ""
self.assertEqual(cipher_text(value), expected)
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)