-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathabout_dice_project.go
55 lines (43 loc) · 1.02 KB
/
about_dice_project.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
type DiceSet struct {
values []int
}
func (t *DiceSet) roll(n int) {
//Needs implementing
//Tip: rand.Int
}
func TestCanCreateADiceSet(t *T) {
dice := &DiceSet{}
t.AssertTrue(dice != nil)
}
func TestRollingTheDiceReturnsASetOfIntegersBetween_1_And_6(t *T) {
dice := &DiceSet{}
dice.roll(5)
t.AssertEquals(5, len(dice.values))
for _, value := range dice.values {
t.AssertTrue(1 <= value && value <= 6)
}
}
func TestDiceValuesDoNotChangeUnlessExplicitlyRolled(t *T) {
dice := &DiceSet{}
dice.roll(5)
first_time := dice.values
second_time := dice.values
t.AssertEquals(5, len(first_time))
t.AssertEquals(first_time, second_time)
}
func TestDiceValuesShouldChangeBetweenRolls(t *T) {
dice := &DiceSet{}
dice.roll(5)
first_time := dice.values
dice.roll(5)
second_time := dice.values
t.AssertNotEqual(first_time, second_time)
}
func TestYouCanRollDifferentNumbersOfDice(t *T) {
dice := &DiceSet{}
dice.roll(3)
t.AssertEquals(3, len(dice.values))
dice.roll(1)
t.AssertEquals(1, len(dice.values))
}