-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.go
36 lines (30 loc) · 1.02 KB
/
utils_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
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
var csvs []string = []string{"assets/goblin/goblin.csv", "assets/gopher/gopher.csv"}
var imgs []string = []string{"assets/goblin/goblin.png", "assets/gopher/gopher.png"}
func TestAssert(t *testing.T) {
require.Equal(t, 123, 123, "they should be equal")
require.NotEqual(t, 2, 456, "they should not be equal")
require.FileExists(t, csvs[0])
}
func TestLoadSprite(t *testing.T) {
require.Equal(t, len(csvs), len(imgs), "make sure imgs and csvs equal len")
for idx := range csvs {
resource := LoadSprite(imgs[idx], csvs[idx])
require.Nil(t, resource.err)
}
}
func TestLoadSpriteCsv(t *testing.T) {
definition, err := LoadSpriteCsvDefinition(csvs[0])
require.Nil(t, err)
require.Equal(t, definition.gridSize, GridSize{5, 11})
val, ok := definition.animationMap["WalkDown"]
require.Equal(t, ok, true)
require.Equal(t, "WalkDown", val.name)
require.Equal(t, 0, val.rowIdx)
require.Equal(t, 0, val.colIdxStart)
require.Equal(t, 11, val.colIdxEnd)
}