|
|
@@ -34,7 +34,7 @@ public class WordCountTest {
|
|
34
|
34
|
|
|
35
|
35
|
@Ignore("Remove to run test")
|
|
36
|
36
|
@Test
|
|
37
|
|
- public void countOneOfEach() {
|
|
|
37
|
+ public void countOneOfEachWord() {
|
|
38
|
38
|
expectedWordCount.put("one", 1);
|
|
39
|
39
|
expectedWordCount.put("of", 1);
|
|
40
|
40
|
expectedWordCount.put("each", 1);
|
|
|
@@ -47,7 +47,7 @@ public class WordCountTest {
|
|
47
|
47
|
|
|
48
|
48
|
@Ignore("Remove to run test")
|
|
49
|
49
|
@Test
|
|
50
|
|
- public void countMultipleOccurrences() {
|
|
|
50
|
+ public void multipleOccurrencesOfAWord() {
|
|
51
|
51
|
expectedWordCount.put("one", 1);
|
|
52
|
52
|
expectedWordCount.put("fish", 4);
|
|
53
|
53
|
expectedWordCount.put("two", 1);
|
|
|
@@ -59,6 +59,32 @@ public class WordCountTest {
|
|
59
|
59
|
expectedWordCount, actualWordCount
|
|
60
|
60
|
);
|
|
61
|
61
|
}
|
|
|
62
|
+
|
|
|
63
|
+ @Ignore("Remove to run test")
|
|
|
64
|
+ @Test
|
|
|
65
|
+ public void handlesCrampedLists() {
|
|
|
66
|
+ expectedWordCount.put("one", 1);
|
|
|
67
|
+ expectedWordCount.put("two", 1);
|
|
|
68
|
+ expectedWordCount.put("three", 1);
|
|
|
69
|
+
|
|
|
70
|
+ actualWordCount = wordCount.phrase("one,two,three");
|
|
|
71
|
+ assertEquals(
|
|
|
72
|
+ expectedWordCount, actualWordCount
|
|
|
73
|
+ );
|
|
|
74
|
+ }
|
|
|
75
|
+
|
|
|
76
|
+ @Ignore("Remove to run test")
|
|
|
77
|
+ @Test
|
|
|
78
|
+ public void handlesExpandedLists() {
|
|
|
79
|
+ expectedWordCount.put("one", 1);
|
|
|
80
|
+ expectedWordCount.put("two", 1);
|
|
|
81
|
+ expectedWordCount.put("three", 1);
|
|
|
82
|
+
|
|
|
83
|
+ actualWordCount = wordCount.phrase("one,\ntwo,\nthree");
|
|
|
84
|
+ assertEquals(
|
|
|
85
|
+ expectedWordCount, actualWordCount
|
|
|
86
|
+ );
|
|
|
87
|
+ }
|
|
62
|
88
|
|
|
63
|
89
|
@Ignore("Remove to run test")
|
|
64
|
90
|
@Test
|
|
|
@@ -93,8 +119,52 @@ public class WordCountTest {
|
|
93
|
119
|
@Test
|
|
94
|
120
|
public void normalizeCase() {
|
|
95
|
121
|
expectedWordCount.put("go", 3);
|
|
|
122
|
+ expectedWordCount.put("stop", 2);
|
|
|
123
|
+
|
|
|
124
|
+ actualWordCount = wordCount.phrase("go Go GO Stop stop");
|
|
|
125
|
+ assertEquals(
|
|
|
126
|
+ expectedWordCount, actualWordCount
|
|
|
127
|
+ );
|
|
|
128
|
+ }
|
|
|
129
|
+
|
|
|
130
|
+ @Ignore("Remove to run test")
|
|
|
131
|
+ @Test
|
|
|
132
|
+ public void withApostrophes() {
|
|
|
133
|
+ expectedWordCount.put("first", 1);
|
|
|
134
|
+ expectedWordCount.put("don't", 2);
|
|
|
135
|
+ expectedWordCount.put("laugh", 1);
|
|
|
136
|
+ expectedWordCount.put("then", 1);
|
|
|
137
|
+ expectedWordCount.put("cry", 1);
|
|
|
138
|
+
|
|
|
139
|
+ actualWordCount = wordCount.phrase("First: don't laugh. Then: don't cry.");
|
|
|
140
|
+ assertEquals(
|
|
|
141
|
+ expectedWordCount, actualWordCount
|
|
|
142
|
+ );
|
|
|
143
|
+ }
|
|
|
144
|
+
|
|
|
145
|
+ @Ignore("Remove to run test")
|
|
|
146
|
+ @Test
|
|
|
147
|
+ public void withQuotations() {
|
|
|
148
|
+ expectedWordCount.put("joe", 1);
|
|
|
149
|
+ expectedWordCount.put("can't", 1);
|
|
|
150
|
+ expectedWordCount.put("tell", 1);
|
|
|
151
|
+ expectedWordCount.put("between", 1);
|
|
|
152
|
+ expectedWordCount.put("large", 2);
|
|
|
153
|
+ expectedWordCount.put("and", 1);
|
|
|
154
|
+
|
|
|
155
|
+ actualWordCount = wordCount.phrase("Joe can't tell between 'large' and large.");
|
|
|
156
|
+ assertEquals(
|
|
|
157
|
+ expectedWordCount, actualWordCount
|
|
|
158
|
+ );
|
|
|
159
|
+ }
|
|
|
160
|
+
|
|
|
161
|
+ @Ignore("Remove to run test")
|
|
|
162
|
+ @Test
|
|
|
163
|
+ public void multipleSpacesNotDetectedAsAWord() {
|
|
|
164
|
+ expectedWordCount.put("multiple", 1);
|
|
|
165
|
+ expectedWordCount.put("whitespaces", 1);
|
|
96
|
166
|
|
|
97
|
|
- actualWordCount = wordCount.phrase("go Go GO");
|
|
|
167
|
+ actualWordCount = wordCount.phrase(" multiple whitespaces");
|
|
98
|
168
|
assertEquals(
|
|
99
|
169
|
expectedWordCount, actualWordCount
|
|
100
|
170
|
);
|