소스 검색

first two methods complete

mpierse 6 년 전
부모
커밋
0f9f6b459a
4개의 변경된 파일5437개의 추가작업 그리고 1개의 파일을 삭제
  1. 4
    1
      pom.xml
  2. 19
    0
      src/main/java/ReplaceNames.java
  3. 31
    0
      src/test/java/HamletParserTest.java
  4. 5383
    0
      target/classes/hamlet.txt

+ 4
- 1
pom.xml 파일 보기

7
     <groupId>com.zipcodewilmington</groupId>
7
     <groupId>com.zipcodewilmington</groupId>
8
     <artifactId>regex</artifactId>
8
     <artifactId>regex</artifactId>
9
     <version>1.0-SNAPSHOT</version>
9
     <version>1.0-SNAPSHOT</version>
10
-
10
+    <properties>
11
+        <maven.compiler.source>1.8</maven.compiler.source>
12
+        <maven.compiler.target>1.8</maven.compiler.target>
13
+    </properties>
11
     <dependencies>
14
     <dependencies>
12
         <dependency>
15
         <dependency>
13
             <groupId>junit</groupId>
16
             <groupId>junit</groupId>

+ 19
- 0
src/main/java/ReplaceNames.java 파일 보기

1
+import java.util.regex.Pattern;
2
+
3
+public class ReplaceNames {
4
+
5
+    Pattern pattern;
6
+
7
+    public boolean isHoratio(String word) {
8
+        return pattern.matches("([Hh][Oo][Rr][Aa][Tt][Ii][Oo])\\H*", word);
9
+    }
10
+
11
+    public boolean isHamlet(String word) {
12
+        return pattern.matches("([Hh][Aa][Mm][Ll][Ee][Tt])\\H*", word);
13
+    }
14
+
15
+    public int findHoratio(String word) {
16
+        return 0;
17
+    }
18
+
19
+}

+ 31
- 0
src/test/java/HamletParserTest.java 파일 보기

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
 
6
 public class HamletParserTest {
7
 public class HamletParserTest {
7
     private String hamletText;
8
     private String hamletText;
8
     private HamletParser hamletParser;
9
     private HamletParser hamletParser;
10
+    private ReplaceNames replaceNames;
9
 
11
 
10
     @Before
12
     @Before
11
     public void setUp() {
13
     public void setUp() {
12
         this.hamletParser = new HamletParser();
14
         this.hamletParser = new HamletParser();
13
         this.hamletText = hamletParser.getHamletData();
15
         this.hamletText = hamletParser.getHamletData();
16
+        this.replaceNames = new ReplaceNames();
14
     }
17
     }
15
 
18
 
16
     @Test
19
     @Test
22
     }
25
     }
23
 
26
 
24
     @Test
27
     @Test
28
+    public void testIsHoratioTrue(){
29
+        boolean actual = replaceNames.isHoratio("hORatIo's");
30
+        Assert.assertTrue(actual);
31
+    }
32
+
33
+    @Test
34
+    public void testIsHoratioFalse(){
35
+        boolean actual = replaceNames.isHoratio("notHoratio");
36
+        Assert.assertFalse(actual);
37
+    }
38
+
39
+    @Test
25
     public void testFindHoratio() {
40
     public void testFindHoratio() {
41
+        String test = "Horatio, horatio test test HORATIO, hORatIo";
42
+        int actual = replaceNames.findHoratio(test);
43
+        int expected = 4;
44
+        Assert.assertEquals(expected, actual);
45
+    }
46
+
47
+    @Test
48
+    public void testIsHamletTrue(){
49
+        boolean actual = replaceNames.isHamlet("HamLet's");
50
+        Assert.assertTrue(actual);
51
+    }
52
+
53
+    @Test
54
+    public void testIsHamletFalse(){
55
+        boolean actual = replaceNames.isHamlet("notHamLet");
56
+        Assert.assertFalse(actual);
26
     }
57
     }
27
 
58
 
28
     @Test
59
     @Test

+ 5383
- 0
target/classes/hamlet.txt
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기