Skip to content

Commit af398d5

Browse files
CadeMichaelvaeng
andauthored
Update anagram tests (#784)
* update anagram tests * uuid for all test * remove include false tests and unicode --------- Co-authored-by: vaeng <[email protected]>
1 parent dfc38ef commit af398d5

File tree

2 files changed

+83
-22
lines changed

2 files changed

+83
-22
lines changed

exercises/practice/anagram/.meta/tests.toml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
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
[dd40c4d2-3c8b-44e5-992a-f42b393ec373]
613
description = "no matches"
714

815
[b3cca662-f50a-489e-ae10-ab8290a09bdc]
916
description = "detects two anagrams"
17+
include = false
18+
19+
[03eb9bbe-8906-4ea0-84fa-ffe711b52c8b]
20+
description = "detects two anagrams"
21+
reimplements = "b3cca662-f50a-489e-ae10-ab8290a09bdc"
1022

1123
[a27558ee-9ba0-4552-96b1-ecf665b06556]
1224
description = "does not detect anagram subsets"
@@ -34,12 +46,43 @@ description = "detects anagrams using case-insensitive possible matches"
3446

3547
[7cc195ad-e3c7-44ee-9fd2-d3c344806a2c]
3648
description = "does not detect an anagram if the original word is repeated"
49+
include = false
50+
51+
[630abb71-a94e-4715-8395-179ec1df9f91]
52+
description = "does not detect an anagram if the original word is repeated"
53+
reimplements = "7cc195ad-e3c7-44ee-9fd2-d3c344806a2c"
3754

3855
[9878a1c9-d6ea-4235-ae51-3ea2befd6842]
3956
description = "anagrams must use all letters exactly once"
4057

4158
[85757361-4535-45fd-ac0e-3810d40debc1]
4259
description = "words are not anagrams of themselves (case-insensitive)"
60+
include = false
61+
62+
[68934ed0-010b-4ef9-857a-20c9012d1ebf]
63+
description = "words are not anagrams of themselves"
64+
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"
65+
66+
[589384f3-4c8a-4e7d-9edc-51c3e5f0c90e]
67+
description = "words are not anagrams of themselves even if letter case is partially different"
68+
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"
69+
70+
[ba53e423-7e02-41ee-9ae2-71f91e6d18e6]
71+
description = "words are not anagrams of themselves even if letter case is completely different"
72+
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"
4373

4474
[a0705568-628c-4b55-9798-82e4acde51ca]
4575
description = "words other than themselves can be anagrams"
76+
include = false
77+
78+
[33d3f67e-fbb9-49d3-a90e-0beb00861da7]
79+
description = "words other than themselves can be anagrams"
80+
reimplements = "a0705568-628c-4b55-9798-82e4acde51ca"
81+
82+
[a6854f66-eec1-4afd-a137-62ef2870c051]
83+
description = "handles case of greek letters"
84+
include = false
85+
86+
[fd3509e5-e3ba-409d-ac3d-a9ac84d13296]
87+
description = "different characters may have the same bytes"
88+
include = false

exercises/practice/anagram/anagram_test.cpp

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ TEST_CASE("no_matches")
2020
}
2121

2222
#if defined(EXERCISM_RUN_ALL_TESTS)
23-
TEST_CASE("detects_two_anagrams")
23+
TEST_CASE("detects_two_anagrams", "[findAnagrams][03eb9bbe-8906-4ea0-84fa-ffe711b52c8b]")
2424
{
25-
auto subject = anagram::anagram("master");
26-
auto matches = subject.matches({"stream", "pigeon", "maters"});
27-
vector<string> expected{"stream", "maters"};
25+
auto subject = anagram::anagram("solemn");
26+
auto matches = subject.matches({"lemons", "cherry", "melons"});
27+
vector<string> expected{"lemons", "melons"};
2828

2929
REQUIRE(expected == matches);
3030
}
3131

32-
TEST_CASE("does_not_detect_anagram_subsets")
32+
TEST_CASE("does_not_detect_anagram_subsets", "[findAnagrams][a27558ee-9ba0-4552-96b1-ecf665b06556]")
3333
{
3434
auto subject = anagram::anagram("good");
3535
auto matches = subject.matches({"dog", "goody"});
@@ -38,7 +38,7 @@ TEST_CASE("does_not_detect_anagram_subsets")
3838
REQUIRE(expected == matches);
3939
}
4040

41-
TEST_CASE("detects_anagram")
41+
TEST_CASE("detects_anagram", "[findAnagrams][64cd4584-fc15-4781-b633-3d814c4941a4]")
4242
{
4343
auto subject = anagram::anagram("listen");
4444
auto matches = subject.matches({"enlists", "google", "inlets", "banana"});
@@ -47,7 +47,7 @@ TEST_CASE("detects_anagram")
4747
REQUIRE(expected == matches);
4848
}
4949

50-
TEST_CASE("detects_three_anagrams")
50+
TEST_CASE("detects_three_anagrams", "[findAnagrams][99c91beb-838f-4ccd-b123-935139917283]")
5151
{
5252
auto subject = anagram::anagram("allergy");
5353
auto matches = subject.matches({
@@ -63,7 +63,7 @@ TEST_CASE("detects_three_anagrams")
6363
REQUIRE(expected == matches);
6464
}
6565

66-
TEST_CASE("detects_multiple_anagrams_with_different_case")
66+
TEST_CASE("detects_multiple_anagrams_with_different_case", "[findAnagrams][78487770-e258-4e1f-a646-8ece10950d90]")
6767
{
6868
auto subject = anagram::anagram("nose");
6969
auto matches = subject.matches({"Eons", "ONES"});
@@ -72,7 +72,7 @@ TEST_CASE("detects_multiple_anagrams_with_different_case")
7272
REQUIRE(expected == matches);
7373
}
7474

75-
TEST_CASE("does_not_detect_non_anagrams_with_identical_checksum")
75+
TEST_CASE("does_not_detect_non_anagrams_with_identical_checksum", "[findAnagrams][1d0ab8aa-362f-49b7-9902-3d0c668d557b]")
7676
{
7777
auto subject = anagram::anagram("mass");
7878
auto matches = subject.matches({"last"});
@@ -81,7 +81,7 @@ TEST_CASE("does_not_detect_non_anagrams_with_identical_checksum")
8181
REQUIRE(expected == matches);
8282
}
8383

84-
TEST_CASE("detects_anagrams_case_insensitively")
84+
TEST_CASE("detects_anagrams_case_insensitively", "[findAnagrams][9e632c0b-c0b1-4804-8cc1-e295dea6d8a8]")
8585
{
8686
auto subject = anagram::anagram("Orchestra");
8787
auto matches = subject.matches({"cashregister", "Carthorse", "radishes"});
@@ -90,7 +90,7 @@ TEST_CASE("detects_anagrams_case_insensitively")
9090
REQUIRE(expected == matches);
9191
}
9292

93-
TEST_CASE("detects_anagrams_using_case_insensitive_subject")
93+
TEST_CASE("detects_anagrams_using_case_insensitive_subject", "[findAnagrams][b248e49f-0905-48d2-9c8d-bd02d8c3e392]")
9494
{
9595
auto subject = anagram::anagram("Orchestra");
9696
auto matches = subject.matches({"cashregister", "carthorse", "radishes"});
@@ -99,7 +99,7 @@ TEST_CASE("detects_anagrams_using_case_insensitive_subject")
9999
REQUIRE(expected == matches);
100100
}
101101

102-
TEST_CASE("detects_anagrams_using_case_insensitive_possible_matches")
102+
TEST_CASE("detects_anagrams_using_case_insensitive_possible_matches", "[findAnagrams][f367325c-78ec-411c-be76-e79047f4bd54]")
103103
{
104104
auto subject = anagram::anagram("orchestra");
105105
auto matches = subject.matches({"cashregister", "Carthorse", "radishes"});
@@ -108,16 +108,16 @@ TEST_CASE("detects_anagrams_using_case_insensitive_possible_matches")
108108
REQUIRE(expected == matches);
109109
}
110110

111-
TEST_CASE("does_not_detect_a_anagram_if_the_original_word_is_repeated")
111+
TEST_CASE("does_not_detect_an_anagram_if_the_original_word_is_repeated", "[findAnagrams][630abb71-a94e-4715-8395-179ec1df9f91]")
112112
{
113113
auto subject = anagram::anagram("go");
114-
auto matches = subject.matches({"go Go GO"});
114+
auto matches = subject.matches({"goGoGO"});
115115
vector<string> expected;
116116

117117
REQUIRE(expected == matches);
118118
}
119119

120-
TEST_CASE("anagrams_must_use_all_letters_exactly_once")
120+
TEST_CASE("anagrams_must_use_all_letters_exactly_once", "[findAnagrams][9878a1c9-d6ea-4235-ae51-3ea2befd6842]")
121121
{
122122
auto subject = anagram::anagram("tapper");
123123
auto matches = subject.matches({"patter"});
@@ -126,19 +126,37 @@ TEST_CASE("anagrams_must_use_all_letters_exactly_once")
126126
REQUIRE(expected == matches);
127127
}
128128

129-
TEST_CASE("words_are_not_anagrams_of_themselves_case_insensitive")
129+
TEST_CASE("words_are_not_anagrams_of_themselves", "[findAnagrams][68934ed0-010b-4ef9-857a-20c9012d1ebf]")
130130
{
131131
auto subject = anagram::anagram("BANANA");
132-
auto matches = subject.matches({"BANANA", "Banana", "banana"});
132+
auto matches = subject.matches({"BANANA"});
133133
vector<string> expected;
134134

135135
REQUIRE(expected == matches);
136136
}
137137

138-
TEST_CASE("words_other_than_themselves_can_be_anagrams")
138+
TEST_CASE("words_are_not_anagrams_of_themselves_even_if_letter_case_is_partially_different", "[findAnagrams][589384f3-4c8a-4e7d-9edc-51c3e5f0c90e]")
139+
{
140+
auto subject = anagram::anagram("BANANA");
141+
auto matches = subject.matches({"Banana"});
142+
vector<string> expected;
143+
144+
REQUIRE(expected == matches);
145+
}
146+
147+
TEST_CASE("words_are_not_anagrams_of_themselves_even_if_letter_case_is_completely_different", "[findAnagrams][ba53e423-7e02-41ee-9ae2-71f91e6d18e6]")
148+
{
149+
auto subject = anagram::anagram("BANANA");
150+
auto matches = subject.matches({"banana"});
151+
vector<string> expected;
152+
153+
REQUIRE(expected == matches);
154+
}
155+
156+
TEST_CASE("words_other_than_themselves_can_be_anagrams", "[findAnagrams][33d3f67e-fbb9-49d3-a90e-0beb00861da7]")
139157
{
140158
auto subject = anagram::anagram("LISTEN");
141-
auto matches = subject.matches({"Listen", "Silent", "LISTEN"});
159+
auto matches = subject.matches({"Silent", "LISTEN"});
142160
vector<string> expected{"Silent"};
143161

144162
REQUIRE(expected == matches);

0 commit comments

Comments
 (0)