From 12390fd02f81a9bf8ebde9c6d2dff11571517d2d Mon Sep 17 00:00:00 2001 From: "david.wolfson" Date: Mon, 7 Oct 2024 14:52:29 +0100 Subject: [PATCH] added characterisation test for single day --- go/gildedrose/gildedrose_test.go | 47 ++++++++++++++++++++++++++++++-- go/texttest_fixture.go | 4 +-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/go/gildedrose/gildedrose_test.go b/go/gildedrose/gildedrose_test.go index 8ce7a70f9d..70eaceddbb 100644 --- a/go/gildedrose/gildedrose_test.go +++ b/go/gildedrose/gildedrose_test.go @@ -11,9 +11,8 @@ func Test_Foo(t *testing.T) { var items = []*gildedrose.Item{ {"foo", 0, 0}, } - expected := []*gildedrose.Item{ - {"foo", -1, -1}, + {"foo", -1, 0}, } // Act @@ -30,3 +29,47 @@ func Test_Foo(t *testing.T) { t.Errorf("Quality: Expected %d but got %d ", expected[0].Quality, items[0].Quality) } } + +func Test_oneDay(t *testing.T) { + // Arrange + var items = []*gildedrose.Item{ + {"+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}, + {"Conjured Mana Cake", 3, 6}, // <-- :O + } + + var expected = []*gildedrose.Item{ + {"+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}, + {"Conjured Mana Cake", 2, 5}, // <-- :O + } + + // Act + gildedrose.UpdateQuality(items) + + // Assert + for i, item := range expected { + if items[i].Name != item.Name { + t.Errorf("Name: Expected %s but got %s ", item.Name, items[i].Name) + } + if items[i].SellIn != item.SellIn { + t.Errorf("%s - SellIn: Expected %d but got %d ", item.Name, item.SellIn, items[i].SellIn) + } + if items[i].Quality != item.Quality { + t.Errorf("%s - Quality: Expected %d but got %d ", item.Name, item.Quality, items[i].Quality) + } + } + +} diff --git a/go/texttest_fixture.go b/go/texttest_fixture.go index 5c96506493..cee5082f42 100644 --- a/go/texttest_fixture.go +++ b/go/texttest_fixture.go @@ -12,8 +12,8 @@ func main() { fmt.Println("OMGHAI!") var items = []*gildedrose.Item{ - {"+5 Dexterity Vest", 10, 20}, - {"Aged Brie", 2, 0}, + {Name: "+5 Dexterity Vest", SellIn: 10, Quality: 20}, + {Name: "Aged Brie", SellIn: 2, Quality: 0}, {"Elixir of the Mongoose", 5, 7}, {"Sulfuras, Hand of Ragnaros", 0, 80}, {"Sulfuras, Hand of Ragnaros", -1, 80},