|
@@ -20,47 +20,27 @@ public class HamletParserTest {
|
20
|
20
|
|
21
|
21
|
@Test
|
22
|
22
|
public void testChangeHamletToLeon() {
|
23
|
|
- Pattern pattern = Pattern.compile("Hamlet");
|
24
|
|
- Matcher m = pattern.matcher(hamletText);
|
25
|
|
- String actual = m.replaceAll("Leon");
|
26
|
|
-
|
27
|
|
- String expected = hamletText.toString().replaceAll("Hamlet","Leon");
|
28
|
|
-
|
29
|
|
- Assert.assertEquals(expected,actual);
|
|
23
|
+ hamletParser.replaceHamlet();
|
|
24
|
+ Assert.assertFalse(hamletParser.findHamlet());
|
30
|
25
|
}
|
31
|
26
|
|
32
|
27
|
@Test
|
33
|
28
|
public void testChangeHoratioToTariq() {
|
34
|
|
- Pattern pattern = Pattern.compile("Horatio");
|
35
|
|
- Matcher cher = pattern.matcher(hamletText);
|
36
|
|
- String actual = cher.replaceAll("Tariq");
|
37
|
|
-
|
38
|
|
- String expected = hamletText.toString().replaceAll("Horatio","Tariq");
|
39
|
|
-
|
40
|
|
- Assert.assertEquals(expected,actual);
|
|
29
|
+ hamletParser.replaceHoratio();
|
|
30
|
+ Assert.assertFalse(hamletParser.findHoratio());
|
41
|
31
|
}
|
42
|
32
|
//
|
43
|
33
|
@Test
|
44
|
34
|
public void testFindHoratio() {
|
45
|
35
|
|
46
|
|
- String regex = "((Horatio) (.+?))";
|
47
|
|
- Pattern pattern=Pattern.compile(regex );
|
48
|
|
- Matcher mat =pattern.matcher(hamletText);
|
49
|
|
-
|
50
|
|
- Boolean expected = mat.find();
|
51
|
|
-
|
52
|
|
- Assert.assertTrue(expected);
|
|
36
|
+ Assert.assertTrue(hamletParser.findHoratio());
|
53
|
37
|
|
54
|
38
|
}
|
55
|
39
|
|
56
|
40
|
@Test
|
57
|
41
|
public void testFindHamlet() {
|
58
|
|
- String regex = "((Hamlet) (.+?))";
|
59
|
|
- Pattern pattern = Pattern.compile(regex);
|
60
|
|
- Matcher m = pattern.matcher(hamletText);
|
61
|
42
|
|
62
|
|
- Boolean expected = m.find();
|
63
|
|
- Assert.assertTrue(expected);
|
|
43
|
+ Assert.assertTrue(hamletParser.findHamlet());
|
64
|
44
|
|
65
|
45
|
}
|
66
|
46
|
}
|