|
5 | 5 | #include "test/catch.hpp" |
6 | 6 | #endif |
7 | 7 |
|
8 | | -TEST_CASE("normalize_capitals") |
9 | | -{ |
10 | | - REQUIRE("hello" == crypto_square::cipher("Hello").normalize_plain_text()); |
| 8 | +TEST_CASE("empty plaintext results in an empty ciphertext", |
| 9 | + "[407c3837-9aa7-4111-ab63-ec54b58e8e9f]") { |
| 10 | + REQUIRE("" == crypto_square::cipher("").normalized_cipher_text()); |
11 | 11 | } |
12 | 12 |
|
13 | 13 | #if defined(EXERCISM_RUN_ALL_TESTS) |
14 | | -TEST_CASE("normalize_spaces") |
15 | | -{ |
16 | | - REQUIRE("hithere" == crypto_square::cipher("Hi there").normalize_plain_text()); |
17 | | -} |
18 | | - |
19 | | -TEST_CASE("normalize_numbers") |
20 | | -{ |
21 | | - REQUIRE("123go" == crypto_square::cipher("1, 2, 3 GO!").normalize_plain_text()); |
22 | | -} |
23 | | - |
24 | | -TEST_CASE("plain_text_empty") |
25 | | -{ |
26 | | - const std::vector<std::string> expected{}; |
27 | | - |
28 | | - const auto actual = crypto_square::cipher("").plain_text_segments(); |
29 | | - |
30 | | - REQUIRE(expected == actual); |
31 | | -} |
32 | | - |
33 | | -TEST_CASE("plain_text_4_characters") |
34 | | -{ |
35 | | - const std::vector<std::string> expected{"ab", "cd"}; |
36 | | - |
37 | | - const auto actual = crypto_square::cipher("Ab Cd").plain_text_segments(); |
38 | | - |
39 | | - REQUIRE(expected == actual); |
| 14 | +TEST_CASE("normalization results in empty plaintext", |
| 15 | + "[aad04a25-b8bb-4304-888b-581bea8e0040]") { |
| 16 | + REQUIRE("" == |
| 17 | + crypto_square::cipher("... --- ...").normalized_cipher_text()); |
40 | 18 | } |
41 | 19 |
|
42 | | -TEST_CASE("plain_text_9_characters") |
43 | | -{ |
44 | | - const std::vector<std::string> expected{"thi", "sis", "fun"}; |
45 | | - |
46 | | - const auto actual = crypto_square::cipher("This is fun!").plain_text_segments(); |
47 | | - |
48 | | - REQUIRE(expected == actual); |
| 20 | +TEST_CASE("Lowercase", "[64131d65-6fd9-4f58-bdd8-4a2370fb481d]") { |
| 21 | + REQUIRE("a" == crypto_square::cipher("A").normalized_cipher_text()); |
49 | 22 | } |
50 | 23 |
|
51 | | -TEST_CASE("plain_text_segments_from_phrase") |
52 | | -{ |
53 | | - const std::vector<std::string> expected{"ifmanwas", "meanttos", "tayonthe", "groundgo", "dwouldha", "vegivenu", "sroots"}; |
54 | | - |
55 | | - const auto actual = crypto_square::cipher("If man was meant to stay on the ground, god would have given us roots.").plain_text_segments(); |
56 | | - |
57 | | - REQUIRE(expected == actual); |
58 | | -} |
59 | | - |
60 | | -TEST_CASE("cipher_text_empty_phrase") |
61 | | -{ |
62 | | - REQUIRE("" == crypto_square::cipher("").cipher_text()); |
| 24 | +TEST_CASE("Remove spaces", "[63a4b0ed-1e3c-41ea-a999-f6f26ba447d6]") { |
| 25 | + REQUIRE("b" == crypto_square::cipher(" b ").normalized_cipher_text()); |
63 | 26 | } |
64 | 27 |
|
65 | | -TEST_CASE("cipher_text_long_phrase") |
66 | | -{ |
67 | | - REQUIRE("imtgdvsfearwermayoogoanouuiontnnlvtwttddesaohghnsseoau" == |
68 | | - crypto_square::cipher("If man was meant to stay on the ground, god would have given us roots.").cipher_text()); |
| 28 | +TEST_CASE("Remove punctuation", "[1b5348a1-7893-44c1-8197-42d48d18756c]") { |
| 29 | + REQUIRE("1" == crypto_square::cipher("@1,%!").normalized_cipher_text()); |
69 | 30 | } |
70 | 31 |
|
71 | | -TEST_CASE("normalized_cipher_text_empty") |
72 | | -{ |
73 | | - REQUIRE("" == crypto_square::cipher("").normalized_cipher_text()); |
| 32 | +TEST_CASE("9 character plaintext results in 3 chunks of 3 characters", |
| 33 | + "[8574a1d3-4a08-4cec-a7c7-de93a164f41a]") { |
| 34 | + REQUIRE("tsf hiu isn" == |
| 35 | + crypto_square::cipher("This is fun!").normalized_cipher_text()); |
74 | 36 | } |
75 | 37 |
|
76 | | -TEST_CASE("normalized_cipher_text_fun") |
77 | | -{ |
78 | | - REQUIRE("tsf hiu isn" == crypto_square::cipher("This is fun!").normalized_cipher_text()); |
| 38 | +TEST_CASE( |
| 39 | + // clang-format off |
| 40 | + "8 character plaintext results in 3 chunks, the last one with a trailing space", |
| 41 | + // clang-format on |
| 42 | + "[a65d3fa1-9e09-43f9-bcec-7a672aec3eae]") { |
| 43 | + REQUIRE("clu hlt io " == |
| 44 | + crypto_square::cipher("Chill out.").normalized_cipher_text()); |
79 | 45 | } |
80 | 46 |
|
81 | | -TEST_CASE("normalized_cipher_text_long_phrase") |
82 | | -{ |
| 47 | +TEST_CASE( |
| 48 | + "54 character plaintext results in 7 chunks, the last two with trailing " |
| 49 | + "spaces", |
| 50 | + "[fbcb0c6d-4c39-4a31-83f6-c473baa6af80]") { |
83 | 51 | REQUIRE("imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau " == |
84 | | - crypto_square::cipher("If man was meant to stay on the ground, god would have given us roots.").normalized_cipher_text()); |
| 52 | + crypto_square::cipher("If man was meant to stay on the ground, god " |
| 53 | + "would have given us roots.") |
| 54 | + .normalized_cipher_text()); |
85 | 55 | } |
86 | 56 | #endif |
0 commit comments