-
Notifications
You must be signed in to change notification settings - Fork 91
/
webp_test.go
49 lines (44 loc) · 1.02 KB
/
webp_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
// Copyright 2014 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package webp
import (
"io/ioutil"
"testing"
)
type tGetInfoTester struct {
Filename string
HdrSize int
Width int
Height int
HasAlpha bool
}
func TestGetInfo(t *testing.T) {
for i, v := range tGetInfoTesterList {
data, err := ioutil.ReadFile(testdataDir + v.Filename)
if err != nil {
t.Fatalf("%d: %v", i, err)
}
width, height, hasAlpha, err := GetInfo(data)
if err != nil {
t.Fatalf("%d: %v", i, err)
}
if width != v.Width {
t.Fatalf("%d: expect = %v, got = %v", i, v.Width, width)
}
if height != v.Height {
t.Fatalf("%d: expect = %v, got = %v", i, v.Height, height)
}
if hasAlpha != v.HasAlpha {
t.Fatalf("%d: expect = %v, got = %v", i, v.HasAlpha, hasAlpha)
}
}
}
var tGetInfoTesterList = []tGetInfoTester{
tGetInfoTester{
Filename: "1_webp_ll.webp",
Width: 400,
Height: 301,
HasAlpha: true,
},
}