Sfoglia il codice sorgente

test cases are in but some are not working

Jordan Elderidge 6 anni fa
parent
commit
08843c246a

+ 1
- 0
src/main/java/io/zipcoder/ItemParseException.java Vedi File

@@ -1,4 +1,5 @@
1 1
 package io.zipcoder;
2 2
 
3 3
 public class ItemParseException extends Exception {
4
+
4 5
 }

+ 54
- 1
src/test/java/io/zipcoder/ItemParserTest.java Vedi File

@@ -59,4 +59,57 @@ public class ItemParserTest {
59 59
         Integer actual = itemParser.findKeyValuePairsInRawItemData(rawSingleItemIrregularSeperatorSample).size();
60 60
         assertEquals(expected, actual);
61 61
     }
62
-}
62
+    @Test
63
+    public void findNameTest(){
64
+        String expected = "milk";
65
+        String actual = itemParser.findName(rawSingleItem);
66
+        Assert.assertEquals(expected,actual);
67
+
68
+    }
69
+    @Test
70
+    public void findPriceTest() {
71
+        String expected = "3.23";
72
+        String actual = itemParser.findPrice(rawSingleItem);
73
+        Assert.assertEquals(expected, actual);
74
+    }
75
+    @Test
76
+    public void findExpirationTest() {
77
+        String expected = "1/25/2016";
78
+        String actual = itemParser.findExpiration(rawSingleItem);
79
+        Assert.assertEquals(expected, actual);
80
+    }
81
+
82
+    @Test
83
+    public void findTypeTest() {
84
+        String expected = "food";
85
+        String actual = itemParser.findType(rawSingleItem);
86
+        Assert.assertEquals(expected, actual);
87
+    }
88
+
89
+    @Test
90
+    public void display() throws Exception{
91
+        String expected = "\n" + "name:     Bread         seen:  6  times\n" + "===============\t\t\t===============\n" +"Price:     1.23         seen:  6  times\n" + "---------------\t\t\t---------------\n" + "\n" + "name:      Milk         seen:  6  times\n" + "===============\t\t\t===============\n" + "Price:     3.23         seen:  5  times\n" + "---------------\t\t\t---------------\n" + "Price:     1.23         seen:  1  times\n" + "---------------\t\t\t---------------\n" + "\n" + "name:    Apples         seen:  4  times\n" + "===============\t\t\t===============\n" +
92
+                "Price:     0.25         seen:  2  times\n" + "---------------\t\t\t---------------\n" + "Price:     0.23         seen:  2  times\n" + "---------------\t\t\t---------------\n" + "\n" + "name:   Cookies         seen:  8  times\n" + "===============\t\t\t===============\n" + "Price:     2.25         seen:  8  times\n" + "---------------\t\t\t---------------\n" + "\n" + "Errors                  seen:  4  times";
93
+        String actual = itemParser.display();
94
+        Assert.assertEquals(expected,actual);
95
+
96
+
97
+    }
98
+    @Test
99
+    public void seenPriceOccurencesTest(){
100
+        ArrayList<Item> listTest = new ArrayList<Item>();
101
+        Item itemTest = new Item("Bread", 3.12, "Food", "1/25/2016");
102
+        Item itemTest2 = new Item("Bread", 3.12, "Food", "1/25/2016");
103
+        Item itemTest3 = new Item("Bread", 2.00, "Food", "4/16/2016");
104
+
105
+        listTest.add(itemTest);
106
+        listTest.add(itemTest2);
107
+        listTest.add(itemTest3);
108
+
109
+        int expected = 2;
110
+        int actual = itemParser.seenPriceOccurences(listTest,3.12);
111
+
112
+        Assert.assertEquals(expected,actual);
113
+    }
114
+
115
+    }