Skip to content

Commit 2ba57bf

Browse files
anagram: Sync tests (#2762)
[no important files changed]
1 parent d56f06e commit 2ba57bf

File tree

3 files changed

+59
-35
lines changed

3 files changed

+59
-35
lines changed

exercises/practice/anagram/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"muzimuzhi",
1818
"redshirt4",
1919
"rohit1104",
20+
"sanderploegsma",
2021
"sjwarner-bp",
2122
"SleeplessByte",
2223
"Smarticles101",

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,9 @@ include = false
7878
[33d3f67e-fbb9-49d3-a90e-0beb00861da7]
7979
description = "words other than themselves can be anagrams"
8080
reimplements = "a0705568-628c-4b55-9798-82e4acde51ca"
81+
82+
[a6854f66-eec1-4afd-a137-62ef2870c051]
83+
description = "handles case of greek letters"
84+
85+
[fd3509e5-e3ba-409d-ac3d-a9ac84d13296]
86+
description = "different characters may have the same bytes"
Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import static org.assertj.core.api.Assertions.assertThat;
2-
31
import org.junit.jupiter.api.Disabled;
42
import org.junit.jupiter.api.Test;
53

64
import java.util.Arrays;
75
import java.util.Collections;
86

7+
import static org.assertj.core.api.Assertions.assertThat;
8+
99
public class AnagramTest {
1010

1111
@Test
1212
public void testNoMatches() {
1313
Anagram detector = new Anagram("diaper");
1414

1515
assertThat(
16-
detector.match(
17-
Arrays.asList("hello", "world", "zombies", "pants")))
18-
.isEmpty();
16+
detector.match(
17+
Arrays.asList("hello", "world", "zombies", "pants")))
18+
.isEmpty();
1919
}
2020

2121
@Disabled("Remove to run test")
@@ -24,7 +24,7 @@ public void testDetectsTwoAnagrams() {
2424
Anagram detector = new Anagram("solemn");
2525

2626
assertThat(detector.match(Arrays.asList("lemons", "cherry", "melons")))
27-
.containsExactlyInAnyOrder("lemons", "melons");
27+
.containsExactlyInAnyOrder("lemons", "melons");
2828
}
2929

3030
@Disabled("Remove to run test")
@@ -41,25 +41,25 @@ public void testDetectLongerAnagram() {
4141
Anagram detector = new Anagram("listen");
4242

4343
assertThat(
44-
detector.match(
45-
Arrays.asList("enlists", "google", "inlets", "banana")))
46-
.containsExactlyInAnyOrder("inlets");
44+
detector.match(
45+
Arrays.asList("enlists", "google", "inlets", "banana")))
46+
.containsExactlyInAnyOrder("inlets");
4747
}
4848

4949
@Disabled("Remove to run test")
5050
@Test
5151
public void testDetectMultipleAnagramsForLongerWord() {
5252
Anagram detector = new Anagram("allergy");
5353
assertThat(
54-
detector.match(
55-
Arrays.asList(
56-
"gallery",
57-
"ballerina",
58-
"regally",
59-
"clergy",
60-
"largely",
61-
"leading")))
62-
.containsExactlyInAnyOrder("gallery", "regally", "largely");
54+
detector.match(
55+
Arrays.asList(
56+
"gallery",
57+
"ballerina",
58+
"regally",
59+
"clergy",
60+
"largely",
61+
"leading")))
62+
.containsExactlyInAnyOrder("gallery", "regally", "largely");
6363
}
6464

6565
@Disabled("Remove to run test")
@@ -68,7 +68,7 @@ public void testDetectsMultipleAnagramsWithDifferentCase() {
6868
Anagram detector = new Anagram("nose");
6969

7070
assertThat(detector.match(Arrays.asList("Eons", "ONES")))
71-
.containsExactlyInAnyOrder("Eons", "ONES");
71+
.containsExactlyInAnyOrder("Eons", "ONES");
7272
}
7373

7474
@Disabled("Remove to run test")
@@ -77,7 +77,7 @@ public void testEliminateAnagramsWithSameChecksum() {
7777
Anagram detector = new Anagram("mass");
7878

7979
assertThat(detector.match(Collections.singletonList("last")))
80-
.isEmpty();
80+
.isEmpty();
8181
}
8282

8383
@Disabled("Remove to run test")
@@ -86,9 +86,9 @@ public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter
8686
Anagram detector = new Anagram("Orchestra");
8787

8888
assertThat(
89-
detector.match(
90-
Arrays.asList("cashregister", "Carthorse", "radishes")))
91-
.containsExactlyInAnyOrder("Carthorse");
89+
detector.match(
90+
Arrays.asList("cashregister", "Carthorse", "radishes")))
91+
.containsExactlyInAnyOrder("Carthorse");
9292
}
9393

9494
@Disabled("Remove to run test")
@@ -97,9 +97,9 @@ public void testCaseInsensitiveWhenSubjectStartsWithUpperCaseLetter() {
9797
Anagram detector = new Anagram("Orchestra");
9898

9999
assertThat(
100-
detector.match(
101-
Arrays.asList("cashregister", "carthorse", "radishes")))
102-
.containsExactlyInAnyOrder("carthorse");
100+
detector.match(
101+
Arrays.asList("cashregister", "carthorse", "radishes")))
102+
.containsExactlyInAnyOrder("carthorse");
103103
}
104104

105105
@Disabled("Remove to run test")
@@ -108,9 +108,9 @@ public void testCaseInsensitiveWhenAnagramStartsWithUpperCaseLetter() {
108108
Anagram detector = new Anagram("orchestra");
109109

110110
assertThat(
111-
detector.match(
112-
Arrays.asList("cashregister", "Carthorse", "radishes")))
113-
.containsExactlyInAnyOrder("Carthorse");
111+
detector.match(
112+
Arrays.asList("cashregister", "Carthorse", "radishes")))
113+
.containsExactlyInAnyOrder("Carthorse");
114114
}
115115

116116
@Disabled("Remove to run test")
@@ -119,7 +119,7 @@ public void testIdenticalWordRepeatedIsNotAnagram() {
119119
Anagram detector = new Anagram("go");
120120

121121
assertThat(detector.match(Collections.singletonList("goGoGO")))
122-
.isEmpty();
122+
.isEmpty();
123123
}
124124

125125
@Disabled("Remove to run test")
@@ -128,7 +128,7 @@ public void testAnagramMustUseAllLettersExactlyOnce() {
128128
Anagram detector = new Anagram("tapper");
129129

130130
assertThat(detector.match(Collections.singletonList("patter")))
131-
.isEmpty();
131+
.isEmpty();
132132
}
133133

134134
@Disabled("Remove to run test")
@@ -137,7 +137,7 @@ public void testWordsAreNotAnagramsOfThemselvesCaseInsensitive() {
137137
Anagram detector = new Anagram("BANANA");
138138

139139
assertThat(detector.match(Collections.singletonList("BANANA")))
140-
.isEmpty();
140+
.isEmpty();
141141
}
142142

143143
@Disabled("Remove to run test")
@@ -146,7 +146,7 @@ public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDiffer
146146
Anagram detector = new Anagram("BANANA");
147147

148148
assertThat(detector.match(Collections.singletonList("Banana")))
149-
.isEmpty();
149+
.isEmpty();
150150
}
151151

152152
@Disabled("Remove to run test")
@@ -155,7 +155,7 @@ public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDiffe
155155
Anagram detector = new Anagram("BANANA");
156156

157157
assertThat(detector.match(Collections.singletonList("banana")))
158-
.isEmpty();
158+
.isEmpty();
159159
}
160160

161161
@Disabled("Remove to run test")
@@ -164,7 +164,24 @@ public void testWordsOtherThanThemselvesCanBeAnagrams() {
164164
Anagram detector = new Anagram("LISTEN");
165165

166166
assertThat(detector.match(Arrays.asList("LISTEN", "Silent")))
167-
.containsExactlyInAnyOrder("Silent");
167+
.containsExactlyInAnyOrder("Silent");
168168
}
169169

170+
@Disabled("Remove to run test")
171+
@Test
172+
public void testHandlesCaseOfGreekLetters() {
173+
Anagram detector = new Anagram("ΑΒΓ");
174+
175+
assertThat(detector.match(Arrays.asList("ΒΓΑ", "ΒΓΔ", "γβα", "αβγ")))
176+
.containsExactlyInAnyOrder("ΒΓΑ", "γβα");
177+
}
178+
179+
@Disabled("Remove to run test")
180+
@Test
181+
public void testDifferentCharactersWithSameBytes() {
182+
Anagram detector = new Anagram("a⬂");
183+
184+
assertThat(detector.match(Collections.singletonList("€a")))
185+
.isEmpty();
186+
}
170187
}

0 commit comments

Comments
 (0)