-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiles_test.go
More file actions
60 lines (56 loc) · 1.36 KB
/
tiles_test.go
File metadata and controls
60 lines (56 loc) · 1.36 KB
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
package randomart
import "testing"
func TestTileSet_Index(t *testing.T) {
tests := []struct {
name string
tileset TileSet
n int
want rune
}{
{
name: "wraps within range",
tileset: TileSet{Runes: []rune{'a', 'b', 'c'}},
n: 1,
want: 'b',
},
{
name: "wraps at boundary when overflow prevention disabled",
tileset: TileSet{Runes: []rune{'a', 'b', 'c'}},
n: 3,
want: 'a',
},
{
name: "wraps past boundary when overflow prevention disabled",
tileset: TileSet{Runes: []rune{'a', 'b', 'c'}},
n: 8,
want: 'c',
},
{
name: "clamps at boundary when overflow prevention enabled",
tileset: TileSet{Runes: []rune{'a', 'b', 'c'}, PreventRuneOverflow: true},
n: 3,
want: 'c',
},
{
name: "clamps past boundary when overflow prevention enabled",
tileset: TileSet{Runes: []rune{'a', 'b', 'c'}, PreventRuneOverflow: true},
n: 99,
want: 'c',
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.tileset.Index(tt.n); got != tt.want {
t.Errorf("TileSet.Index(%d) = %q, want %q", tt.n, got, tt.want)
}
})
}
}
func TestTileSets(t *testing.T) {
t.Run("returns bundled tilesets", func(t *testing.T) {
got := TileSets()
if len(got) != 2 {
t.Fatalf("TileSets() len = %d, want 2", len(got))
}
})
}