d2/lib/xgif/xgif_test.go

36 lines
621 B
Go
Raw Normal View History

2023-04-13 21:16:53 +00:00
package xgif
import (
_ "embed"
2023-04-14 13:35:14 +00:00
"os"
2023-04-13 21:16:53 +00:00
"testing"
"github.com/stretchr/testify/assert"
)
//go:embed test_input1.png
var test_input1 []byte
//go:embed test_input2.png
var test_input2 []byte
//go:embed test_output.gif
var test_output []byte
func TestPngToGif(t *testing.T) {
boards := [][]byte{test_input1, test_input2}
interval := 1_000
gifBytes, err := AnimatePNGs(boards, interval)
2023-04-13 21:16:53 +00:00
assert.NoError(t, err)
2023-04-14 13:35:14 +00:00
// use this to update the test output
if false {
f, err := os.Create("test_output_2.gif")
assert.NoError(t, err)
defer f.Close()
f.Write(gifBytes)
}
2023-04-13 21:16:53 +00:00
assert.Equal(t, test_output, gifBytes)
}