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
 import java.io.File;
1
 import java.io.File;
2
 import java.io.IOException;
2
 import java.io.IOException;
3
 import java.util.Scanner;
3
 import java.util.Scanner;
4
+import java.util.regex.*;
4
 
5
 
5
 /**
6
 /**
6
  * Created by thook on 10/7/15.
7
  * Created by thook on 10/7/15.
10
     private String hamletData;
11
     private String hamletData;
11
 
12
 
12
     public HamletParser(){
13
     public HamletParser(){
14
+
13
         this.hamletData = loadFile();
15
         this.hamletData = loadFile();
14
     }
16
     }
15
 
17
 
33
     }
35
     }
34
 
36
 
35
     public String getHamletData(){
37
     public String getHamletData(){
38
+
36
         return hamletData;
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
+import org.junit.Assert;
1
 import org.junit.Before;
2
 import org.junit.Before;
2
 import org.junit.Test;
3
 import org.junit.Test;
3
 
4
 
5
+import java.util.regex.Pattern;
6
+
4
 import static org.junit.Assert.*;
7
 import static org.junit.Assert.*;
5
 
8
 
6
 public class HamletParserTest {
9
 public class HamletParserTest {
15
 
18
 
16
     @Test
19
     @Test
17
     public void testChangeHamletToLeon() {
20
     public void testChangeHamletToLeon() {
18
-    }
19
 
21
 
22
+    }
20
     @Test
23
     @Test
21
     public void testChangeHoratioToTariq() {
24
     public void testChangeHoratioToTariq() {
22
     }
25
     }
23
 
26
 
24
     @Test
27
     @Test
25
     public void testFindHoratio() {
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
     @Test
36
     @Test
29
     public void testFindHamlet() {
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