mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-19 04:15:06 +00:00
feat: update go boilerplate
This commit is contained in:
1 parent
181b48aff7
commit
f6fe61daac
7 files changed
+97
-88
No files matched your search
@@ -0,0 +1,58 @@
|
||||
package gildedrose
|
||||
|
||||
type Item struct {
|
||||
Name string
|
||||
SellIn, Quality int
|
||||
}
|
||||
|
||||
func UpdateQuality(items []*Item) {
|
||||
for i := 0; i < len(items); i++ {
|
||||
|
||||
if items[i].Name != "Aged Brie" && items[i].Name != "Backstage passes to a TAFKAL80ETC concert" {
|
||||
if items[i].Quality > 0 {
|
||||
if items[i].Name != "Sulfuras, Hand of Ragnaros" {
|
||||
items[i].Quality = items[i].Quality - 1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if items[i].Quality < 50 {
|
||||
items[i].Quality = items[i].Quality + 1
|
||||
if items[i].Name == "Backstage passes to a TAFKAL80ETC concert" {
|
||||
if items[i].SellIn < 11 {
|
||||
if items[i].Quality < 50 {
|
||||
items[i].Quality = items[i].Quality + 1
|
||||
}
|
||||
}
|
||||
if items[i].SellIn < 6 {
|
||||
if items[i].Quality < 50 {
|
||||
items[i].Quality = items[i].Quality + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if items[i].Name != "Sulfuras, Hand of Ragnaros" {
|
||||
items[i].SellIn = items[i].SellIn - 1
|
||||
}
|
||||
|
||||
if items[i].SellIn < 0 {
|
||||
if items[i].Name != "Aged Brie" {
|
||||
if items[i].Name != "Backstage passes to a TAFKAL80ETC concert" {
|
||||
if items[i].Quality > 0 {
|
||||
if items[i].Name != "Sulfuras, Hand of Ragnaros" {
|
||||
items[i].Quality = items[i].Quality - 1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
items[i].Quality = items[i].Quality - items[i].Quality
|
||||
}
|
||||
} else {
|
||||
if items[i].Quality < 50 {
|
||||
items[i].Quality = items[i].Quality + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package gildedrose_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/emilybache/gildedrose-refactoring-kata/gildedrose"
|
||||
)
|
||||
|
||||
func Test_Foo(t *testing.T) {
|
||||
var items = []*gildedrose.Item{
|
||||
{"foo", 0, 0},
|
||||
}
|
||||
|
||||
gildedrose.UpdateQuality(items)
|
||||
|
||||
if items[0].Name != "fixme" {
|
||||
t.Errorf("Name: Expected %s but got %s ", "fixme", items[0].Name)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user