|
|
@@ -18,7 +18,7 @@ public class AnagramTest {
|
|
18
|
18
|
|
|
19
|
19
|
@Ignore
|
|
20
|
20
|
@Test
|
|
21
|
|
- public void testSimpleAnagram() {
|
|
|
21
|
+ public void testDetectSimpleAnagram() {
|
|
22
|
22
|
Anagram detector = new Anagram("ant");
|
|
23
|
23
|
List<String> anagram = detector.match(Arrays.asList("tan", "stand", "at"));
|
|
24
|
24
|
assertThat(anagram, hasItem("tan"));
|
|
|
@@ -27,6 +27,14 @@ public class AnagramTest {
|
|
27
|
27
|
|
|
28
|
28
|
@Ignore
|
|
29
|
29
|
@Test
|
|
|
30
|
+ public void testDetectLongerAnagram() {
|
|
|
31
|
+ Anagram detector = new Anagram("listen");
|
|
|
32
|
+ List<String> anagrams = detector.match(Arrays.asList("enlists", "google", "inlets", "banana"));
|
|
|
33
|
+ assertThat(anagrams, hasItem("inlets"));
|
|
|
34
|
+ }
|
|
|
35
|
+
|
|
|
36
|
+ @Ignore
|
|
|
37
|
+ @Test
|
|
30
|
38
|
public void testDetectMultipleAnagrams() {
|
|
31
|
39
|
Anagram detector = new Anagram("master");
|
|
32
|
40
|
List<String> anagrams = detector.match(Arrays.asList("stream", "pigeon", "maters"));
|
|
|
@@ -35,10 +43,17 @@ public class AnagramTest {
|
|
35
|
43
|
|
|
36
|
44
|
@Ignore
|
|
37
|
45
|
@Test
|
|
|
46
|
+ public void testDetectMultipleAnagramsForLongerWord() {
|
|
|
47
|
+ Anagram detector = new Anagram("allergy");
|
|
|
48
|
+ List<String> anagrams = detector.match(Arrays.asList("gallery", "ballerina", "regally", "clergy", "largely", "leading"));
|
|
|
49
|
+ assertThat(anagrams, allOf(hasItem("gallery"), hasItem("largely"), hasItem("regally")));
|
|
|
50
|
+ }
|
|
|
51
|
+
|
|
|
52
|
+ @Ignore
|
|
|
53
|
+ @Test
|
|
38
|
54
|
public void testDoesNotConfuseDifferentDuplicates() {
|
|
39
|
55
|
Anagram detector = new Anagram("galea");
|
|
40
|
|
- List<String> anagrams = detector.match(Arrays.asList("eagle"));
|
|
41
|
|
- assertTrue(anagrams.isEmpty());
|
|
|
56
|
+ assertTrue(detector.match(Arrays.asList("eagle")).isEmpty());
|
|
42
|
57
|
}
|
|
43
|
58
|
|
|
44
|
59
|
@Ignore
|
|
|
@@ -52,6 +67,20 @@ public class AnagramTest {
|
|
52
|
67
|
|
|
53
|
68
|
@Ignore
|
|
54
|
69
|
@Test
|
|
|
70
|
+ public void testCapitalWordIsNotAnagram() {
|
|
|
71
|
+ Anagram detector = new Anagram("BANANA");
|
|
|
72
|
+ assertTrue(detector.match(Arrays.asList("Banana")).isEmpty());
|
|
|
73
|
+ }
|
|
|
74
|
+
|
|
|
75
|
+ @Ignore
|
|
|
76
|
+ @Test
|
|
|
77
|
+ public void testIdenticalWordRepeatedIsNotAnagram() {
|
|
|
78
|
+ Anagram detector = new Anagram("go");
|
|
|
79
|
+ assertTrue(detector.match(Arrays.asList("go Go GO")).isEmpty());
|
|
|
80
|
+ }
|
|
|
81
|
+
|
|
|
82
|
+ @Ignore
|
|
|
83
|
+ @Test
|
|
55
|
84
|
public void testEliminateAnagramsWithSameChecksum() {
|
|
56
|
85
|
Anagram detector = new Anagram("mass");
|
|
57
|
86
|
assertTrue(detector.match(Arrays.asList("last")).isEmpty());
|
|
|
@@ -66,26 +95,25 @@ public class AnagramTest {
|
|
66
|
95
|
|
|
67
|
96
|
@Ignore
|
|
68
|
97
|
@Test
|
|
69
|
|
- public void testDetectAnagrams() {
|
|
70
|
|
- Anagram detector = new Anagram("listen");
|
|
71
|
|
- List<String> anagrams = detector.match(Arrays.asList("enlists", "google", "inlets", "banana"));
|
|
72
|
|
- assertThat(anagrams, hasItem("inlets"));
|
|
|
98
|
+ public void testCaseInsensitiveWhenSubjectStartsWithUpperCaseLetter() {
|
|
|
99
|
+ Anagram detector = new Anagram("Orchestra");
|
|
|
100
|
+ List<String> anagrams = detector.match(Arrays.asList("cashregister", "carthorse", "radishes"));
|
|
|
101
|
+ assertThat(anagrams, hasItem("carthorse"));
|
|
73
|
102
|
}
|
|
74
|
103
|
|
|
75
|
104
|
@Ignore
|
|
76
|
105
|
@Test
|
|
77
|
|
- public void testMultipleAnagrams() {
|
|
78
|
|
- Anagram detector = new Anagram("allergy");
|
|
79
|
|
- List<String> anagrams = detector.match(Arrays.asList("gallery", "ballerina", "regally", "clergy", "largely", "leading"));
|
|
80
|
|
- assertThat(anagrams, allOf(hasItem("gallery"), hasItem("largely"), hasItem("regally")));
|
|
|
106
|
+ public void testCaseInsensitiveWhenAnagramStartsWithUpperCaseLetter() {
|
|
|
107
|
+ Anagram detector = new Anagram("orchestra");
|
|
|
108
|
+ List<String> anagrams = detector.match(Arrays.asList("cashregister", "Carthorse", "radishes"));
|
|
|
109
|
+ assertThat(anagrams, hasItem("Carthorse"));
|
|
81
|
110
|
}
|
|
82
|
111
|
|
|
83
|
112
|
@Ignore
|
|
84
|
113
|
@Test
|
|
85
|
|
- public void testAnagramsAreCaseInsensitive() {
|
|
|
114
|
+ public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter() {
|
|
86
|
115
|
Anagram detector = new Anagram("Orchestra");
|
|
87
|
116
|
List<String> anagrams = detector.match(Arrays.asList("cashregister", "Carthorse", "radishes"));
|
|
88
|
117
|
assertThat(anagrams, hasItem("Carthorse"));
|
|
89
|
118
|
}
|
|
90
|
|
-
|
|
91
|
119
|
}
|