/
Checkpoint1Tests.java
48 lines (38 loc) · 1.33 KB
/
Checkpoint1Tests.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package textGen1;
import org.junit.Before;
import org.junit.Test;
import testHelp.verify;
public class Checkpoint1Tests {
TextAnalyzer wc;
@Before
public void setUp() throws Exception {
wc = new WordCounter("tale_of_two_cities_tokenized.txt");
}
@Test
public void testWordCounts() {
verify.that(wc.getWordCounts("It")).isEqualTo(1);
verify.that(wc.getWordCounts("it")).isEqualTo(9);
verify.that(wc.getWordCounts("was")).isEqualTo(11);
verify.that(wc.getWordCounts("of")).isEqualTo(12);
}
@Test
public void testMostCommonWord() {
String mostCommonWord = wc.getMostCommonWord();
String expectedMostCommonWord = ",";
verify.that(expectedMostCommonWord).isEqualTo(mostCommonWord);
}
@Test
public void testStartsWithCapitalLetter() {
verify.that(wc.startsWithCapitalLetter("It")).isTrue();
verify.that(wc.startsWithCapitalLetter("BY")).isTrue();
verify.that(wc.startsWithCapitalLetter("A")).isTrue();
verify.that(wc.startsWithCapitalLetter("tt")).isFalse();
}
@Test
public void testIsSentenceEndingPunctuation() {
verify.that(wc.isSentenceEndingPunctuation(".")).isTrue();
verify.that(wc.isSentenceEndingPunctuation("?")).isTrue();
verify.that(wc.isSentenceEndingPunctuation("!")).isTrue();
verify.that(wc.isSentenceEndingPunctuation("a")).isFalse();
}
}