diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2017-02-18 21:14:22 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2017-02-18 21:14:22 +0100 |
| commit | 6566f09803377bb22b5460f9decb7d201b861ff4 (patch) | |
| tree | 25b6369f1daa8a1ed6b1989956324bf3196df23a | |
| parent | c4f76699aa1459564792395f272052fce6b433bd (diff) | |
| download | goffel-6566f09803377bb22b5460f9decb7d201b861ff4.tar.gz goffel-6566f09803377bb22b5460f9decb7d201b861ff4.zip | |
logic: rename Dices -> Dice in tests
| -rw-r--r-- | logic/dice_test.go | 56 | ||||
| -rw-r--r-- | logic/score_test.go | 26 |
2 files changed, 41 insertions, 41 deletions
diff --git a/logic/dice_test.go b/logic/dice_test.go index 2a6c67c..f458708 100644 --- a/logic/dice_test.go +++ b/logic/dice_test.go @@ -6,33 +6,33 @@ package logic import "testing" func TestSum(t *testing.T) { - d := Dices{1, 1, 1, 2, 6} + d := Dice{1, 1, 1, 2, 6} if d.Sum(1) != 3 { t.Errorf("Sum(1) of %v should be 3", d) } - d = Dices{1, 1, 1, 2, 6} + d = Dice{1, 1, 1, 2, 6} if d.Sum(2) != 2 { t.Errorf("Sum(2) of %v should be 2", d) } - d = Dices{1, 1, 1, 2, 6} + d = Dice{1, 1, 1, 2, 6} if d.Sum(0) != 11 { t.Errorf("Sum(0) of %v should be 11", d) } - d = Dices{1, 1, 1, 2, 6} + d = Dice{1, 1, 1, 2, 6} if d.Sum(3) != 0 { t.Errorf("Sum(3) of %v should be 0", d) } } func TestIsThreeOfAKind(t *testing.T) { - dices := []Dices{Dices{1, 2, 3, 3, 3}, Dices{1, 4, 4, 4, 5}, Dices{2, 2, 2, 3, 6}, Dices{1, 1, 1, 1, 1}} - for _, d := range dices { + dice := []Dice{{1, 2, 3, 3, 3}, {1, 4, 4, 4, 5}, {2, 2, 2, 3, 6}, {1, 1, 1, 1, 1}} + for _, d := range dice { if !d.IsThreeOfAKind() { t.Errorf("%v is three of a kind", d) } } - dices = []Dices{Dices{1, 2, 3, 3, 4}, Dices{1, 4, 4, 5, 5}, Dices{1, 2, 2, 3, 6}, Dices{1, 1, 2, 5, 6}} - for _, d := range dices { + dice = []Dice{{1, 2, 3, 3, 4}, {1, 4, 4, 5, 5}, {1, 2, 2, 3, 6}, {1, 1, 2, 5, 6}} + for _, d := range dice { if d.IsThreeOfAKind() { t.Errorf("%v is not three of a kind", d) } @@ -40,14 +40,14 @@ func TestIsThreeOfAKind(t *testing.T) { } func TestIsFourOfAKind(t *testing.T) { - dices := []Dices{Dices{1, 3, 3, 3, 3}, Dices{1, 4, 4, 4, 4}, Dices{2, 2, 2, 2, 6}, Dices{1, 1, 1, 1, 1}} - for _, d := range dices { + dice := []Dice{{1, 3, 3, 3, 3}, {1, 4, 4, 4, 4}, {2, 2, 2, 2, 6}, {1, 1, 1, 1, 1}} + for _, d := range dice { if !d.IsFourOfAKind() { t.Errorf("%v is four of a kind", d) } } - dices = []Dices{Dices{1, 2, 3, 3, 4}, Dices{1, 4, 4, 5, 5}, Dices{1, 2, 2, 3, 6}, Dices{1, 1, 2, 5, 6}} - for _, d := range dices { + dice = []Dice{{1, 2, 3, 3, 4}, {1, 4, 4, 5, 5}, {1, 2, 2, 3, 6}, {1, 1, 2, 5, 6}} + for _, d := range dice { if d.IsFourOfAKind() { t.Errorf("%v is not four of a kind", d) } @@ -55,14 +55,14 @@ func TestIsFourOfAKind(t *testing.T) { } func TestIsFullHouse(t *testing.T) { - dices := []Dices{Dices{1, 1, 3, 3, 3}, Dices{1, 1, 4, 4, 4}, Dices{2, 2, 2, 6, 6}} - for _, d := range dices { + dice := []Dice{{1, 1, 3, 3, 3}, {1, 1, 4, 4, 4}, {2, 2, 2, 6, 6}} + for _, d := range dice { if !d.IsFullHouse() { t.Errorf("%v is a full house", d) } } - dices = []Dices{Dices{1, 2, 3, 3, 4}, Dices{1, 4, 4, 5, 5}, Dices{1, 2, 2, 3, 6}, Dices{1, 1, 2, 5, 6}} - for _, d := range dices { + dice = []Dice{{1, 2, 3, 3, 4}, {1, 4, 4, 5, 5}, {1, 2, 2, 3, 6}, {1, 1, 2, 5, 6}} + for _, d := range dice { if d.IsFullHouse() { t.Errorf("%v is not a full house", d) } @@ -70,14 +70,14 @@ func TestIsFullHouse(t *testing.T) { } func TestIsSmallStraight(t *testing.T) { - dices := []Dices{Dices{1, 2, 3, 4, 6}, Dices{1, 1, 2, 3, 4}, Dices{2, 3, 4, 5, 6}, Dices{1, 2, 3, 3, 4}} - for _, d := range dices { + dice := []Dice{{1, 2, 3, 4, 6}, {1, 1, 2, 3, 4}, {2, 3, 4, 5, 6}, {1, 2, 3, 3, 4}} + for _, d := range dice { if !d.IsSmallStraight() { t.Errorf("%v is a small straight", d) } } - dices = []Dices{Dices{1, 2, 3, 3, 5}, Dices{1, 4, 4, 5, 5}, Dices{1, 2, 2, 3, 6}, Dices{1, 1, 2, 5, 6}} - for _, d := range dices { + dice = []Dice{{1, 2, 3, 3, 5}, {1, 4, 4, 5, 5}, {1, 2, 2, 3, 6}, {1, 1, 2, 5, 6}} + for _, d := range dice { if d.IsSmallStraight() { t.Errorf("%v is not a small straight", d) } @@ -85,14 +85,14 @@ func TestIsSmallStraight(t *testing.T) { } func TestIsLargeStraight(t *testing.T) { - dices := []Dices{Dices{1, 2, 3, 4, 5}, Dices{2, 3, 4, 5, 6}} - for _, d := range dices { + dice := []Dice{{1, 2, 3, 4, 5}, {2, 3, 4, 5, 6}} + for _, d := range dice { if !d.IsLargeStraight() { t.Errorf("%v is a large straight", d) } } - dices = []Dices{Dices{1, 2, 3, 3, 4}, Dices{1, 4, 4, 5, 5}, Dices{1, 2, 2, 3, 6}, Dices{1, 1, 2, 5, 6}} - for _, d := range dices { + dice = []Dice{{1, 2, 3, 3, 4}, {1, 4, 4, 5, 5}, {1, 2, 2, 3, 6}, {1, 1, 2, 5, 6}} + for _, d := range dice { if d.IsLargeStraight() { t.Errorf("%v is not a large straight", d) } @@ -100,14 +100,14 @@ func TestIsLargeStraight(t *testing.T) { } func TestIsYahtzee(t *testing.T) { - dices := []Dices{Dices{3, 3, 3, 3, 3}, Dices{1, 1, 1, 1, 1}} - for _, d := range dices { + dice := []Dice{{3, 3, 3, 3, 3}, {1, 1, 1, 1, 1}} + for _, d := range dice { if !d.IsYahtzee() { t.Errorf("%v is a yahtzee", d) } } - dices = []Dices{Dices{1, 2, 3, 3, 4}, Dices{1, 4, 4, 5, 5}, Dices{1, 2, 2, 3, 6}, Dices{1, 1, 2, 5, 6}} - for _, d := range dices { + dice = []Dice{{1, 2, 3, 3, 4}, {1, 4, 4, 5, 5}, {1, 2, 2, 3, 6}, {1, 1, 2, 5, 6}} + for _, d := range dice { if d.IsYahtzee() { t.Errorf("%v is not a yahtzee", d) } diff --git a/logic/score_test.go b/logic/score_test.go index 66ed608..8a254a7 100644 --- a/logic/score_test.go +++ b/logic/score_test.go @@ -23,13 +23,13 @@ func TestScore(t *testing.T) { func TestInsert(t *testing.T) { s := NewScore() - d := Dices{1, 2, 3, 4, 5} + d := Dice{1, 2, 3, 4, 5} p, err := s.Insert(d, 0) if p != 1 || err != nil { t.Errorf("Inserting %v as aces should return 1", d) } - d = Dices{1, 2, 2, 3, 4} + d = Dice{1, 2, 2, 3, 4} p, err = s.Insert(d, 1) if p != 4 || err != nil { t.Errorf("Inserting %v as twos should return 4", d) @@ -40,67 +40,67 @@ func TestInsert(t *testing.T) { t.Errorf("Inserting %v as twos again should fail", d) } - d = Dices{1, 2, 2, 4, 4} + d = Dice{1, 2, 2, 4, 4} p, err = s.Insert(d, 2) if p != 0 || err != nil { t.Errorf("Inserting %v as threes should return 0", d) } - d = Dices{1, 2, 2, 6, 6} + d = Dice{1, 2, 2, 6, 6} p, err = s.Insert(d, 5) if p != 12 || err != nil { t.Errorf("Inserting %v as sixes should return 12", d) } - d = Dices{1, 2, 6, 6, 6} + d = Dice{1, 2, 6, 6, 6} p, err = s.Insert(d, 6) if p != 21 || err != nil { t.Errorf("Inserting %v as three of a kind should return 21", d) } - d = Dices{1, 1, 2, 2, 2} + d = Dice{1, 1, 2, 2, 2} p, err = s.Insert(d, 7) if p != 0 || err == nil { t.Errorf("Inserting %v as four of a kind should fail", d) } - d = Dices{1, 2, 2, 2, 2} + d = Dice{1, 2, 2, 2, 2} p, err = s.Insert(d, 7) if p != 9 || err != nil { t.Errorf("Inserting %v as four of a kind should return 9", d) } - d = Dices{1, 1, 2, 2, 2} + d = Dice{1, 1, 2, 2, 2} p, err = s.Insert(d, 8) if p != 25 || err != nil { t.Errorf("Inserting %v as full house should return 25", d) } - d = Dices{1, 2, 3, 4, 5} + d = Dice{1, 2, 3, 4, 5} p, err = s.Insert(d, 9) if p != 30 || err != nil { t.Errorf("Inserting %v as small straight should return 30", d) } - d = Dices{1, 2, 3, 4, 5} + d = Dice{1, 2, 3, 4, 5} p, err = s.Insert(d, 10) if p != 40 || err != nil { t.Errorf("Inserting %v as large straight should return 40", d) } - d = Dices{2, 2, 3, 4, 5} + d = Dice{2, 2, 3, 4, 5} p, err = s.Insert(d, 10) if p != 0 || err == nil { t.Errorf("Inserting %v as large straight should fail", d) } - d = Dices{2, 2, 2, 2, 2} + d = Dice{2, 2, 2, 2, 2} p, err = s.Insert(d, 11) if p != 50 || err != nil { t.Errorf("Inserting %v as yahtzee should return 50", d) } - d = Dices{1, 3, 3, 5, 6} + d = Dice{1, 3, 3, 5, 6} p, err = s.Insert(d, 12) if p != 18 || err != nil { t.Errorf("Inserting %v as chance should return 18", d) |
