1- import static org .assertj .core .api .Assertions .assertThat ;
2-
31import org .junit .jupiter .api .Disabled ;
42import org .junit .jupiter .api .Test ;
53
64import java .util .Arrays ;
75import java .util .Collections ;
86
7+ import static org .assertj .core .api .Assertions .assertThat ;
8+
99public 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