Quellcode durchsuchen

made the tests pass with a nifty new move

rjsmall90 vor 6 Jahren
Ursprung
Commit
4e03c5a4a3
2 geänderte Dateien mit 16 neuen und 5 gelöschten Zeilen
  1. 3
    2
      src/main/java/HamletParser.java
  2. 13
    3
      src/test/java/HamletParserTest.java

+ 3
- 2
src/main/java/HamletParser.java Datei anzeigen

@@ -54,15 +54,16 @@ public class HamletParser {
54 54
         Pattern p = Pattern.compile(input);
55 55
 
56 56
         Matcher m = p.matcher(hamletData.toLowerCase());
57
-        hamletData = m.replaceAll("Leon");
57
+        hamletData = m.replaceAll("leon");
58 58
 
59 59
         return hamletData;
60 60
     }
61
+
61 62
     public String changeNameTariq(String input) {
62 63
         Pattern p = Pattern.compile(input);
63 64
 
64 65
         Matcher m = p.matcher(hamletData.toLowerCase());
65
-        hamletData = m.replaceAll("Tariq");
66
+        hamletData = m.replaceAll("tariq");
66 67
 
67 68
         return hamletData;
68 69
     }

+ 13
- 3
src/test/java/HamletParserTest.java Datei anzeigen

@@ -16,17 +16,27 @@ public class HamletParserTest {
16 16
     @Test
17 17
     public void testChangeHamletToLeon() {
18 18
         String hToL = "hamlet";
19
+        String expected = "leon";
20
+        String fakeName = "tariq";
19 21
 
22
+        String actual = hamletParser.changeNameLeon(hToL);
20 23
 
21
-        assertNotNull(hamletParser.changeNameTariq(hToL));
24
+        assertTrue(actual.contains(expected));
25
+        assertFalse(actual.contains(fakeName));
22 26
     }
23 27
 
24 28
     @Test
25 29
     public void testChangeHoratioToTariq() {
26
-        String hToL = "horatio";
30
+        String hToT = "horatio";
31
+        String expected = "tariq";
32
+        String fakeName = "lil bobby tables";
27 33
 
28 34
 
29
-        assertNotNull(hamletParser.changeNameTariq(hToL));
35
+        String actual = hamletParser.changeNameTariq(hToT);
36
+
37
+        assertTrue(actual.contains(expected));
38
+        assertFalse(actual.contains(fakeName));
39
+
30 40
     }
31 41
 
32 42
     @Test