Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aa485e0

Browse files
committedMar 2, 2024·
tests: update crypto-square exercise
1 parent f6a34aa commit aa485e0

File tree

3 files changed

+45
-65
lines changed

3 files changed

+45
-65
lines changed
 

‎exercises/practice/crypto-square/.meta/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"KevinWMatthews",
1010
"kytrinyx",
1111
"patricksjackson",
12-
"sjwarner"
12+
"sjwarner",
13+
"ahans"
1314
],
1415
"files": {
1516
"solution": [

‎exercises/practice/crypto-square/.meta/tests.toml

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[407c3837-9aa7-4111-ab63-ec54b58e8e9f]
613
description = "empty plaintext results in an empty ciphertext"
714

15+
[aad04a25-b8bb-4304-888b-581bea8e0040]
16+
description = "normalization results in empty plaintext"
17+
818
[64131d65-6fd9-4f58-bdd8-4a2370fb481d]
919
description = "Lowercase"
1020

‎exercises/practice/crypto-square/crypto_square_test.cpp

+30-61
Original file line numberDiff line numberDiff line change
@@ -5,82 +5,51 @@
55
#include "test/catch.hpp"
66
#endif
77

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());
1111
}
1212

1313
#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());
4018
}
4119

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());
4922
}
5023

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());
6326
}
6427

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());
6930
}
7031

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());
7436
}
7537

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+
"8 character plaintext results in 3 chunks, the last one with a trailing "
40+
"space",
41+
"[a65d3fa1-9e09-43f9-bcec-7a672aec3eae]") {
42+
REQUIRE("clu hlt io " ==
43+
crypto_square::cipher("Chill out.").normalized_cipher_text());
7944
}
8045

81-
TEST_CASE("normalized_cipher_text_long_phrase")
82-
{
46+
TEST_CASE(
47+
"54 character plaintext results in 7 chunks, the last two with trailing "
48+
"spaces",
49+
"[fbcb0c6d-4c39-4a31-83f6-c473baa6af80]") {
8350
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());
51+
crypto_square::cipher("If man was meant to stay on the ground, god "
52+
"would have given us roots.")
53+
.normalized_cipher_text());
8554
}
8655
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.