Browse Source

regexTestSetup

Khalil Malik Saboor 6 years ago
parent
commit
ed9a19e3c3
3 changed files with 5412 additions and 2 deletions
  1. 13
    0
      src/main/java/HamletParser.java
  2. 16
    2
      src/test/java/HamletParserTest.java
  3. 5383
    0
      target/classes/hamlet.txt

+ 13
- 0
src/main/java/HamletParser.java View File

@@ -1,6 +1,7 @@
1 1
 import java.io.File;
2 2
 import java.io.IOException;
3 3
 import java.util.Scanner;
4
+import java.util.regex.*;
4 5
 
5 6
 /**
6 7
  * Created by thook on 10/7/15.
@@ -10,6 +11,7 @@ public class HamletParser {
10 11
     private String hamletData;
11 12
 
12 13
     public HamletParser(){
14
+
13 15
         this.hamletData = loadFile();
14 16
     }
15 17
 
@@ -33,7 +35,18 @@ public class HamletParser {
33 35
     }
34 36
 
35 37
     public String getHamletData(){
38
+
36 39
         return hamletData;
37 40
     }
38 41
 
42
+    public static String findHamlet(String findHamlet){
43
+
44
+        return null;
45
+    }
46
+
47
+    public static String findHoratio(String findHoratio) {
48
+
49
+        return null;
50
+    }
51
+
39 52
 }

+ 16
- 2
src/test/java/HamletParserTest.java View File

@@ -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,28 @@ public class HamletParserTest {
15 18
 
16 19
     @Test
17 20
     public void testChangeHamletToLeon() {
18
-    }
19 21
 
22
+    }
20 23
     @Test
21 24
     public void testChangeHoratioToTariq() {
22 25
     }
23 26
 
24 27
     @Test
25 28
     public void testFindHoratio() {
26
-    }
29
+        String findHoratio = "Horatio Kim James, King Author";
27 30
 
31
+        String expected = "Horatio";
32
+        String actual = HamletParser.findHoratio(findHoratio);
33
+
34
+        Assert.assertEquals(expected,actual);
35
+    }
28 36
     @Test
29 37
     public void testFindHamlet() {
38
+        String findHamlet = "Hamlet Kim James, King Author";
39
+
40
+        String expected = "Hamlet";
41
+        String actual = HamletParser.findHamlet(findHamlet);
42
+
43
+        Assert.assertEquals(expected,actual);
30 44
     }
31 45
 }

+ 5383
- 0
target/classes/hamlet.txt
File diff suppressed because it is too large
View File