forked from fxaa/codenames.plus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
room_test.go
49 lines (42 loc) · 1.06 KB
/
room_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
package main
import (
"testing"
)
func TestSelectWords(t *testing.T) {
out := map[string]struct{}{}
selectWords([]string{"a", "b", "c"}, 1, out)
if len(out) != 1 {
log.Fatal("invalid number of words selected", out)
}
}
func TestIsSet(t *testing.T) {
if !isSet(BoardTypeDefault, BoardTypeDefault) {
t.Fatal("equality check failed")
}
if !isSet(BoardTypeDefault, BoardTypeDefault|BoardTypeCustom) {
t.Fatal("test for a combination of two item failed")
}
}
func TestSetsEnabled(t *testing.T) {
defaultSets := getTotalSetsEnabled(BoardTypeDefault)
if defaultSets != 1 {
t.Fatal("wrong set count for one set")
}
compundCount := getTotalSetsEnabled(BoardTypeCustom | BoardTypeDefault)
if compundCount != 2 {
t.Fatal("wrong set count for two sets", compundCount)
}
}
func TestBoardGeneration(t *testing.T) {
tiles := generateBoard(BoardTypeDefault, TeamBlue)
if len(tiles) != 5 {
t.Fatal("board doesn't have 5 rows", len(tiles))
}
for i := 0; i < 5; i++ {
for j := 0; j < 5; j++ {
if tiles[i][j].Word == "" {
t.Fatal("invalid tile")
}
}
}
}