|
@@ -1,3 +1,4 @@
|
|
1
|
+import org.junit.Assert;
|
1
|
2
|
import org.junit.Before;
|
2
|
3
|
import org.junit.Test;
|
3
|
4
|
|
|
@@ -15,17 +16,61 @@ public class HamletParserTest {
|
15
|
16
|
|
16
|
17
|
@Test
|
17
|
18
|
public void testChangeHamletToLeon() {
|
|
19
|
+ String testString = "Hamlet is a really terrible story.";
|
|
20
|
+ String acutal = hamletParser.swapWords(testString, "Hamlet", "Leon");
|
|
21
|
+ String expect = "Leon is a really terrible story.";
|
|
22
|
+
|
|
23
|
+ Assert.assertEquals(expect, acutal);
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ @Test
|
|
27
|
+ public void findPunctuation(){
|
|
28
|
+ String testString = "Hamlet.";
|
|
29
|
+ String expect = ".";
|
|
30
|
+ String actual = hamletParser.findPunctuation(testString);
|
|
31
|
+
|
|
32
|
+ Assert.assertEquals(expect, actual);
|
18
|
33
|
}
|
19
|
34
|
|
20
|
35
|
@Test
|
21
|
36
|
public void testChangeHoratioToTariq() {
|
|
37
|
+ String testString = "Horatio is a persons name?";
|
|
38
|
+ String acutal = hamletParser.swapWords(testString, "Horatio", "Tariq");
|
|
39
|
+ String expect = "Tariq is a persons name?";
|
|
40
|
+
|
|
41
|
+ Assert.assertEquals(expect, acutal);
|
22
|
42
|
}
|
23
|
43
|
|
24
|
44
|
@Test
|
25
|
45
|
public void testFindHoratio() {
|
|
46
|
+ String testString = "Horatio is a persons name?";
|
|
47
|
+ boolean acutal = hamletParser.findName(testString,"Horatio");
|
|
48
|
+ boolean expect = true;
|
|
49
|
+
|
|
50
|
+ Assert.assertEquals(expect, acutal);
|
26
|
51
|
}
|
27
|
52
|
|
28
|
53
|
@Test
|
29
|
54
|
public void testFindHamlet() {
|
|
55
|
+ String testString = "Hamlet is a persons name?";
|
|
56
|
+ boolean acutal = hamletParser.findName(testString,"Hamlet");
|
|
57
|
+ boolean expect = true;
|
|
58
|
+
|
|
59
|
+ Assert.assertEquals(expect, acutal);
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ @Test
|
|
63
|
+ public void testFindHoratioFail() {
|
|
64
|
+ String testString = "Hamlet is a persons name?";
|
|
65
|
+ boolean actual = hamletParser.findName(testString,"Horatio");
|
|
66
|
+ Assert.assertFalse(actual);
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+ @Test
|
|
70
|
+ public void testFindHamletFail() {
|
|
71
|
+ String testString = "Horatio is a persons name?";
|
|
72
|
+ boolean actual = hamletParser.findName(testString,"Hamlet");
|
|
73
|
+
|
|
74
|
+ Assert.assertFalse(actual);
|
30
|
75
|
}
|
31
|
76
|
}
|