-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameTileStack_test.go
72 lines (59 loc) · 1.79 KB
/
gameTileStack_test.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGameTileStack_Shuffle(t *testing.T) {
stack := NewEmptyGameTileStack()
stack.list = append(stack.list, NewTile(TileTypeBamboo, 1))
stack.list = append(stack.list, NewTile(TileTypeBamboo, 3))
stack.list = append(stack.list, NewTile(TileTypeBamboo, 2))
stack.list = append(stack.list, NewTile(TileTypeBamboo, 5))
stack.Shuffle()
assert.Equal(t, len(stack.list), 4)
}
func TestGameTileStack_GetTileList(t *testing.T) {
list := TileList{
NewTile(TileTypeDot, 1),
NewTile(TileTypeDot, 3),
NewTile(TileTypeDot, 4),
NewTile(TileTypeDot, 8),
NewTile(TileTypeBamboo, 2),
NewTile(TileTypeBamboo, 6),
NewTile(TileTypeBamboo, 9),
}
stack := NewGameTileStack(list)
assert.Equal(t, stack.GetTileList(), list)
}
func TestGameTileStack_GetOneFromHead(t *testing.T) {
first := NewTile(TileTypeWind, 2)
list := TileList{
NewTile(TileTypeDot, 1),
NewTile(TileTypeDot, 3),
NewTile(TileTypeDot, 4),
NewTile(TileTypeDot, 8),
NewTile(TileTypeBamboo, 2),
NewTile(TileTypeBamboo, 6),
NewTile(TileTypeBamboo, 9),
}
stack := NewGameTileStack(append(TileList{first}, list...))
assert.Equal(t, stack.GetOneFromHead(), first)
assert.Equal(t, stack.GetTileList().Len(), len(list))
assert.Equal(t, stack.GetTileList(), list)
}
func TestGameTileStack_GetOneFromEnd(t *testing.T) {
end := NewTile(TileTypeFlower, 1)
list := TileList{
NewTile(TileTypeDot, 1),
NewTile(TileTypeDot, 3),
NewTile(TileTypeDot, 4),
NewTile(TileTypeDot, 8),
NewTile(TileTypeBamboo, 2),
NewTile(TileTypeBamboo, 6),
NewTile(TileTypeBamboo, 9),
}
stack := NewGameTileStack(append(list, end))
assert.Equal(t, stack.GetOneFromEnd(), end)
assert.Equal(t, stack.GetTileList().Len(), len(list))
assert.Equal(t, stack.GetTileList(), list)
}