|
@@ -1,6 +1,9 @@
|
|
1
|
+import org.junit.Assert;
|
1
|
2
|
import org.junit.Before;
|
2
|
3
|
import org.junit.Test;
|
3
|
4
|
|
|
5
|
+import java.util.regex.Pattern;
|
|
6
|
+
|
4
|
7
|
import static org.junit.Assert.*;
|
5
|
8
|
|
6
|
9
|
public class HamletParserTest {
|
|
@@ -15,17 +18,37 @@ public class HamletParserTest {
|
15
|
18
|
|
16
|
19
|
@Test
|
17
|
20
|
public void testChangeHamletToLeon() {
|
|
21
|
+ Pattern ham = Pattern.compile("(H|h)(A|a)(M|m)(L|l)(E|e)(T|t)");
|
|
22
|
+ String output = hamletParser.searchAndReplace(ham, "Leon");
|
|
23
|
+
|
|
24
|
+ Assert.assertFalse(output.contains("Hamlet"));
|
|
25
|
+ Assert.assertFalse(output.contains("HAMLET"));
|
|
26
|
+
|
18
|
27
|
}
|
19
|
28
|
|
20
|
29
|
@Test
|
21
|
30
|
public void testChangeHoratioToTariq() {
|
|
31
|
+ Pattern tariq = Pattern.compile("(H|h)(O|o)(R|r)(A|a)(T|t)(I|i)(O|o)");
|
|
32
|
+ String output = hamletParser.searchAndReplace(tariq, "Tariq");
|
|
33
|
+
|
|
34
|
+ Assert.assertFalse(output.contains("Horatio"));
|
|
35
|
+ Assert.assertFalse(output.contains("HORATIO"));
|
22
|
36
|
}
|
23
|
37
|
|
24
|
38
|
@Test
|
25
|
39
|
public void testFindHoratio() {
|
|
40
|
+ Pattern horatio = Pattern.compile("(H|h)(O|o)(R|r)(A|a)(T|t)(I|i)(O|o)");
|
|
41
|
+ String output = hamletParser.searchAndReplace(horatio, "Tariq");
|
|
42
|
+
|
|
43
|
+ Assert.assertFalse(hamletParser.findMe(horatio, output));
|
26
|
44
|
}
|
27
|
45
|
|
28
|
46
|
@Test
|
29
|
47
|
public void testFindHamlet() {
|
|
48
|
+ Pattern hamlet = Pattern.compile("(H|h)(A|a)(M|m)(L|l)(E|e)(T|t)");
|
|
49
|
+ String output = hamletParser.searchAndReplace(hamlet, "Leon");
|
|
50
|
+
|
|
51
|
+ Assert.assertFalse(hamletParser.findMe(hamlet, output));
|
|
52
|
+
|
30
|
53
|
}
|
31
|
54
|
}
|