-
Notifications
You must be signed in to change notification settings - Fork 75
/
animation_test.go
51 lines (43 loc) · 1.01 KB
/
animation_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
package main
import "testing"
func Test_LoadFromFile(t *testing.T) {
a, err := LoadFromFile("parrot")
if err != nil {
t.Fatal(err)
}
if len(a.Frames) != 10 {
for _, frame := range a.Frames {
t.Log(string(frame))
}
t.Fatalf("expected 10 frames, got %d", len(a.Frames))
}
}
func Test_LoadFromBytes(t *testing.T) {
t.Run("invalid: no frames", func(t *testing.T) {
_, err := LoadFromBytes([]byte{})
if err == nil {
t.Fatal("expected error, got nil")
}
})
t.Run("invalid: one frame", func(t *testing.T) {
_, err := LoadFromBytes([]byte("frame"))
if err == nil {
t.Fatal("expected error, got nil")
}
})
t.Run("invalid: empty frame", func(t *testing.T) {
_, err := LoadFromBytes([]byte("!--FRAME--!\n"))
if err == nil {
t.Fatal("expected error, got nil")
}
})
t.Run("valid", func(t *testing.T) {
a, err := LoadFromBytes([]byte("A\n!--FRAME--!\nB\n"))
if err != nil {
t.Fatal(err)
}
if len(a.Frames) != 2 {
t.Fatalf("expected 2 frames, got %d", len(a.Frames))
}
})
}