|
2 | 2 | #define BOOST_TEST_MAIN
|
3 | 3 | #include <boost/test/unit_test.hpp>
|
4 | 4 |
|
5 |
| -BOOST_AUTO_TEST_CASE(normalize_strange_characters) |
| 5 | +BOOST_AUTO_TEST_CASE(normalize_capitals) |
6 | 6 | {
|
7 |
| - BOOST_REQUIRE_EQUAL("splunk", crypto_square::cipher("s#$%^&plunk").normalize_plain_text()); |
| 7 | + BOOST_REQUIRE_EQUAL("hello", crypto_square::cipher("Hello").normalize_plain_text()); |
8 | 8 | }
|
9 | 9 |
|
10 | 10 | #if defined(EXERCISM_RUN_ALL_TESTS)
|
11 |
| -BOOST_AUTO_TEST_CASE(normalize_numbers) |
| 11 | +BOOST_AUTO_TEST_CASE(normalize_spaces) |
12 | 12 | {
|
13 |
| - BOOST_REQUIRE_EQUAL("123go", crypto_square::cipher("1, 2, 3 GO!").normalize_plain_text()); |
| 13 | + BOOST_REQUIRE_EQUAL("hithere", crypto_square::cipher("Hi there").normalize_plain_text()); |
14 | 14 | }
|
15 | 15 |
|
16 |
| -BOOST_AUTO_TEST_CASE(size_of_small_square) |
| 16 | +BOOST_AUTO_TEST_CASE(normalize_numbers) |
17 | 17 | {
|
18 |
| - BOOST_REQUIRE_EQUAL(2U, crypto_square::cipher("1234").size()); |
| 18 | + BOOST_REQUIRE_EQUAL("123go", crypto_square::cipher("1, 2, 3 GO!").normalize_plain_text()); |
19 | 19 | }
|
20 | 20 |
|
21 |
| -BOOST_AUTO_TEST_CASE(size_of_slightly_larger_square) |
| 21 | +BOOST_AUTO_TEST_CASE(plain_text_empty) |
22 | 22 | {
|
23 |
| - BOOST_REQUIRE_EQUAL(3U, crypto_square::cipher("123456789").size()); |
| 23 | + const std::vector<std::string> expected{}; |
| 24 | + |
| 25 | + const auto actual = crypto_square::cipher("").plain_text_segments(); |
| 26 | + |
| 27 | + BOOST_REQUIRE_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end()); |
24 | 28 | }
|
25 | 29 |
|
26 |
| -BOOST_AUTO_TEST_CASE(size_of_non_perfect_square) |
| 30 | +BOOST_AUTO_TEST_CASE(plain_text_4_characters) |
27 | 31 | {
|
28 |
| - BOOST_REQUIRE_EQUAL(4U, crypto_square::cipher("123456789abc").size()); |
| 32 | + const std::vector<std::string> expected{"ab", "cd"}; |
| 33 | + |
| 34 | + const auto actual = crypto_square::cipher("Ab Cd").plain_text_segments(); |
| 35 | + |
| 36 | + BOOST_REQUIRE_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end()); |
29 | 37 | }
|
30 | 38 |
|
31 |
| -BOOST_AUTO_TEST_CASE(plain_text_segments_from_phrase) |
| 39 | +BOOST_AUTO_TEST_CASE(plain_text_9_characters) |
32 | 40 | {
|
33 |
| - const std::vector<std::string> expected{"neverv", "exthin", "eheart", "withid", "lewoes"}; |
| 41 | + const std::vector<std::string> expected{"thi", "sis", "fun"}; |
34 | 42 |
|
35 |
| - const auto actual = crypto_square::cipher("Never vex thine heart with idle woes").plain_text_segments(); |
| 43 | + const auto actual = crypto_square::cipher("This is fun!").plain_text_segments(); |
36 | 44 |
|
37 | 45 | BOOST_REQUIRE_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end());
|
38 | 46 | }
|
39 | 47 |
|
40 |
| -BOOST_AUTO_TEST_CASE(plain_text_segments_from_complex_phrase) |
| 48 | +BOOST_AUTO_TEST_CASE(plain_text_segments_from_phrase) |
41 | 49 | {
|
42 |
| - const std::vector<std::string> expected{"zomg", "zomb", "ies"}; |
| 50 | + const std::vector<std::string> expected{"ifmanwas", "meanttos", "tayonthe", "groundgo", "dwouldha", "vegivenu", "sroots"}; |
43 | 51 |
|
44 |
| - const auto actual = crypto_square::cipher("ZOMG! ZOMBIES!!!").plain_text_segments(); |
| 52 | + const auto actual = crypto_square::cipher("If man was meant to stay on the ground, god would have given us roots.").plain_text_segments(); |
45 | 53 |
|
46 | 54 | BOOST_REQUIRE_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end());
|
47 | 55 | }
|
48 | 56 |
|
49 |
| -BOOST_AUTO_TEST_CASE(cipher_text_short_phrase) |
| 57 | +BOOST_AUTO_TEST_CASE(cipher_text_empty_phrase) |
50 | 58 | {
|
51 |
| - BOOST_REQUIRE_EQUAL("tasneyinicdsmiohooelntuillibsuuml", |
52 |
| - crypto_square::cipher("Time is an illusion. Lunchtime doubly so.").cipher_text()); |
| 59 | + BOOST_REQUIRE_EQUAL("", |
| 60 | + crypto_square::cipher("").cipher_text()); |
53 | 61 | }
|
54 | 62 |
|
55 | 63 | BOOST_AUTO_TEST_CASE(cipher_text_long_phrase)
|
56 | 64 | {
|
57 |
| - BOOST_REQUIRE_EQUAL("wneiaweoreneawssciliprerlneoidktcms", |
58 |
| - crypto_square::cipher("We all know interspecies romance is weird.").cipher_text()); |
| 65 | + BOOST_REQUIRE_EQUAL("imtgdvsfearwermayoogoanouuiontnnlvtwttddesaohghnsseoau", |
| 66 | + crypto_square::cipher("If man was meant to stay on the ground, god would have given us roots.").cipher_text()); |
| 67 | +} |
| 68 | + |
| 69 | +BOOST_AUTO_TEST_CASE(normalized_cipher_text_empty) |
| 70 | +{ |
| 71 | + BOOST_REQUIRE_EQUAL("", |
| 72 | + crypto_square::cipher("").normalized_cipher_text()); |
59 | 73 | }
|
60 | 74 |
|
61 |
| -BOOST_AUTO_TEST_CASE(normalized_cipher_text1) |
| 75 | +BOOST_AUTO_TEST_CASE(normalized_cipher_text_fun) |
62 | 76 | {
|
63 |
| - BOOST_REQUIRE_EQUAL("msemoa anindn inndla etltsh ui", |
64 |
| - crypto_square::cipher("Madness, and then illumination.").normalized_cipher_text()); |
| 77 | + BOOST_REQUIRE_EQUAL("tsf hiu isn", |
| 78 | + crypto_square::cipher("This is fun!").normalized_cipher_text()); |
65 | 79 | }
|
66 | 80 |
|
67 |
| -BOOST_AUTO_TEST_CASE(normalized_cipher_text2) |
| 81 | +BOOST_AUTO_TEST_CASE(normalized_cipher_text_long_phrase) |
68 | 82 | {
|
69 |
| - BOOST_REQUIRE_EQUAL("vrela epems etpao oirpo", |
70 |
| - crypto_square::cipher("Vampires are people too!").normalized_cipher_text()); |
| 83 | + BOOST_REQUIRE_EQUAL("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()); |
71 | 85 | }
|
72 | 86 | #endif
|
0 commit comments