Package dmd implements well-known formats for dot-matrix display (DMD) art.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.2 KiB

package dmd
import (
"os"
"path/filepath"
"testing"
"time"
)
func TestDecodeGIF(t *testing.T) {
tests := []struct {
Name string
Width, Height int
Len int
Duration time.Duration
}{
{
Name: "1942.gif",
Width: 128,
Height: 32,
Len: 969,
Duration: 19*time.Second + 380*time.Millisecond,
},
{
Name: "afterburner.gif",
Width: 128,
Height: 32,
Len: 600,
Duration: 12 * time.Second,
},
}
for _, test := range tests {
t.Run(test.Name, func(it *testing.T) {
f, err := os.Open(filepath.Join("testdata", "gif", test.Name))
if err != nil {
it.Fatal(err)
}
defer func() { _ = f.Close() }()
a, err := DecodeGIF(f)
if err != nil {
it.Fatal(err)
}
if v := a.Len(); v != test.Len {
it.Errorf("expected %d frames, got %d", test.Len, v)
}
if v := a.Duration(); v != test.Duration {
it.Errorf("expected %s duration, got %s", test.Duration, v)
}
w, h := a.Size()
if w != test.Width || h != test.Height {
it.Errorf("expected %dx%d size, got %dx%d", test.Width, test.Height, w, h)
}
if err = f.Close(); err != nil {
it.Fatal(err)
}
})
}
}