Export category test to csv and add base test result

This commit is contained in:
King Tran 2022-04-27 17:41:19 +07:00
parent da45945660
commit 9c8577e657
2 changed files with 90 additions and 16 deletions

55
Java/base-output.csv Normal file
View File

@ -0,0 +1,55 @@
name, sellIn, quality
-------- day 0 --------
+5 Dexterity Vest, 10, 20
Aged Brie, 2, 0
Elixir of the Mongoose, 5, 7
Sulfuras, Hand of Ragnaros, 0, 80
Sulfuras, Hand of Ragnaros, -1, 80
Backstage passes to a TAFKAL80ETC concert, 15, 20
Backstage passes to a TAFKAL80ETC concert, 10, 49
Backstage passes to a TAFKAL80ETC concert, 5, 49
-------- day 1 --------
+5 Dexterity Vest, 9, 19
Aged Brie, 1, 1
Elixir of the Mongoose, 4, 6
Sulfuras, Hand of Ragnaros, 0, 80
Sulfuras, Hand of Ragnaros, -1, 80
Backstage passes to a TAFKAL80ETC concert, 14, 21
Backstage passes to a TAFKAL80ETC concert, 9, 50
Backstage passes to a TAFKAL80ETC concert, 4, 50
-------- day 2 --------
+5 Dexterity Vest, 8, 18
Aged Brie, 0, 2
Elixir of the Mongoose, 3, 5
Sulfuras, Hand of Ragnaros, 0, 80
Sulfuras, Hand of Ragnaros, -1, 80
Backstage passes to a TAFKAL80ETC concert, 13, 22
Backstage passes to a TAFKAL80ETC concert, 8, 50
Backstage passes to a TAFKAL80ETC concert, 3, 50
-------- day 3 --------
+5 Dexterity Vest, 7, 17
Aged Brie, -1, 4
Elixir of the Mongoose, 2, 4
Sulfuras, Hand of Ragnaros, 0, 80
Sulfuras, Hand of Ragnaros, -1, 80
Backstage passes to a TAFKAL80ETC concert, 12, 23
Backstage passes to a TAFKAL80ETC concert, 7, 50
Backstage passes to a TAFKAL80ETC concert, 2, 50
-------- day 4 --------
+5 Dexterity Vest, 6, 16
Aged Brie, -2, 6
Elixir of the Mongoose, 1, 3
Sulfuras, Hand of Ragnaros, 0, 80
Sulfuras, Hand of Ragnaros, -1, 80
Backstage passes to a TAFKAL80ETC concert, 11, 24
Backstage passes to a TAFKAL80ETC concert, 6, 50
Backstage passes to a TAFKAL80ETC concert, 1, 50
-------- day 5 --------
+5 Dexterity Vest, 5, 15
Aged Brie, -3, 8
Elixir of the Mongoose, 0, 2
Sulfuras, Hand of Ragnaros, 0, 80
Sulfuras, Hand of Ragnaros, -1, 80
Backstage passes to a TAFKAL80ETC concert, 10, 25
Backstage passes to a TAFKAL80ETC concert, 5, 50
Backstage passes to a TAFKAL80ETC concert, 0, 50
1 name, sellIn, quality
2 -------- day 0 --------
3 +5 Dexterity Vest, 10, 20
4 Aged Brie, 2, 0
5 Elixir of the Mongoose, 5, 7
6 Sulfuras, Hand of Ragnaros, 0, 80
7 Sulfuras, Hand of Ragnaros, -1, 80
8 Backstage passes to a TAFKAL80ETC concert, 15, 20
9 Backstage passes to a TAFKAL80ETC concert, 10, 49
10 Backstage passes to a TAFKAL80ETC concert, 5, 49
11 -------- day 1 --------
12 +5 Dexterity Vest, 9, 19
13 Aged Brie, 1, 1
14 Elixir of the Mongoose, 4, 6
15 Sulfuras, Hand of Ragnaros, 0, 80
16 Sulfuras, Hand of Ragnaros, -1, 80
17 Backstage passes to a TAFKAL80ETC concert, 14, 21
18 Backstage passes to a TAFKAL80ETC concert, 9, 50
19 Backstage passes to a TAFKAL80ETC concert, 4, 50
20 -------- day 2 --------
21 +5 Dexterity Vest, 8, 18
22 Aged Brie, 0, 2
23 Elixir of the Mongoose, 3, 5
24 Sulfuras, Hand of Ragnaros, 0, 80
25 Sulfuras, Hand of Ragnaros, -1, 80
26 Backstage passes to a TAFKAL80ETC concert, 13, 22
27 Backstage passes to a TAFKAL80ETC concert, 8, 50
28 Backstage passes to a TAFKAL80ETC concert, 3, 50
29 -------- day 3 --------
30 +5 Dexterity Vest, 7, 17
31 Aged Brie, -1, 4
32 Elixir of the Mongoose, 2, 4
33 Sulfuras, Hand of Ragnaros, 0, 80
34 Sulfuras, Hand of Ragnaros, -1, 80
35 Backstage passes to a TAFKAL80ETC concert, 12, 23
36 Backstage passes to a TAFKAL80ETC concert, 7, 50
37 Backstage passes to a TAFKAL80ETC concert, 2, 50
38 -------- day 4 --------
39 +5 Dexterity Vest, 6, 16
40 Aged Brie, -2, 6
41 Elixir of the Mongoose, 1, 3
42 Sulfuras, Hand of Ragnaros, 0, 80
43 Sulfuras, Hand of Ragnaros, -1, 80
44 Backstage passes to a TAFKAL80ETC concert, 11, 24
45 Backstage passes to a TAFKAL80ETC concert, 6, 50
46 Backstage passes to a TAFKAL80ETC concert, 1, 50
47 -------- day 5 --------
48 +5 Dexterity Vest, 5, 15
49 Aged Brie, -3, 8
50 Elixir of the Mongoose, 0, 2
51 Sulfuras, Hand of Ragnaros, 0, 80
52 Sulfuras, Hand of Ragnaros, -1, 80
53 Backstage passes to a TAFKAL80ETC concert, 10, 25
54 Backstage passes to a TAFKAL80ETC concert, 5, 50
55 Backstage passes to a TAFKAL80ETC concert, 0, 50

View File

@ -1,37 +1,56 @@
package com.gildedrose;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
public class TexttestFixture {
public static void main(String[] args) {
System.out.println("OMGHAI!");
Item[] items = new Item[] {
new Item("+5 Dexterity Vest", 10, 20), //
new Item("Aged Brie", 2, 0), //
new Item("Elixir of the Mongoose", 5, 7), //
new Item("Sulfuras, Hand of Ragnaros", 0, 80), //
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
// this conjured item does not work properly yet
new Item("Conjured Mana Cake", 3, 6) };
Item[] items = new Item[]{
new Item("+5 Dexterity Vest", 10, 20), //
new Item("Aged Brie", 2, 0), //
new Item("Elixir of the Mongoose", 5, 7), //
new Item("Sulfuras, Hand of Ragnaros", 0, 80), //
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
// this conjured item does not work properly yet
// new Item("Conjured Mana Cake", 3, 6)
};
GildedRose app = new GildedRose(items);
int days = 2;
int days = 6;
if (args.length > 0) {
days = Integer.parseInt(args[0]) + 1;
}
List<String> output = new ArrayList<>();
output.add("name, sellIn, quality");
for (int i = 0; i < days; i++) {
System.out.println("-------- day " + i + " --------");
System.out.println("name, sellIn, quality");
output.add("-------- day " + i + " --------");
for (Item item : items) {
System.out.println(item);
output.add(item.toString());
}
System.out.println();
app.updateQuality();
}
try {
exportToCsv(output, "base-output.csv");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
private static void exportToCsv(List<String> data, String fileName) throws FileNotFoundException {
File csvOutputFile = new File(fileName);
try (PrintWriter pw = new PrintWriter(csvOutputFile)) {
data.forEach(pw::println);
}
}
}