-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsprites_test.go
More file actions
63 lines (52 loc) · 1.53 KB
/
sprites_test.go
File metadata and controls
63 lines (52 loc) · 1.53 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
61
62
63
package egriden
import (
"embed"
_ "image/png"
"testing"
)
//go:embed examples/gridsweeper/Graphics/*
var GridsweeperGraphics embed.FS
func TestSequenceAndPackCreation(t *testing.T) {
_, err := CreateImageSequenceFromFolder("bad", "./fakedir")
if err == nil {
t.Errorf("failed to report bad path when creating image sequence from folder")
}
goodSeq, err := CreateImageSequenceFromFolder("good",
"./examples/gridsweeper/Graphics/unrevealed")
if err != nil {
t.Errorf("normal error while creating image sequence: %v", err)
}
if len(goodSeq.Frames) != 3 {
t.Errorf("wrong number of frames loaded")
}
emptyPack := EmptySpritePack()
if emptyPack.Sprite() != nil {
t.Errorf("empty SpritePack didn't return a nil")
}
sp1 := NewSpritePack()
sp1.AddImageSequence(goodSeq)
if sp1.Sprite() == nil {
t.Errorf("SpritePack with good image sequence returns nil sprite")
}
yaml := []byte(`
spritepacks:
- name: sp2
sequences:
- name: good
paths:
- examples/gridsweeper/Graphics/unrevealed/unrevealed0.png
- examples/gridsweeper/Graphics/unrevealed/unrevealed1.png
- examples/gridsweeper/Graphics/unrevealed/unrevealed2.png
`)
sp2map, err := CreateSpritePacksFromYaml(yaml, GridsweeperGraphics)
if err != nil {
t.Errorf("normal error from CreateSpritePacksFromYaml: %v", err)
}
sp2, ok := sp2map["sp2"]
if !ok {
t.Errorf("no value for key 'sp2' in SpritePack map from CreateSpritePacksFromYaml")
}
if len(sp2.sequences["good"].Frames) != 3 {
t.Errorf("wrong number of frames loaded")
}
}