-
Notifications
You must be signed in to change notification settings - Fork 3
/
media_parser_test.go
48 lines (33 loc) · 921 Bytes
/
media_parser_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
package pngstructure
import (
"fmt"
"path"
"testing"
"io/ioutil"
"github.com/dsoprea/go-logging"
)
func TestPngMediaParser_ParseFile(t *testing.T) {
filepath := path.Join(assetsPath, "Selection_058.png")
pmp := NewPngMediaParser()
_, err := pmp.ParseFile(filepath)
log.PanicIf(err)
}
func TestPngMediaParser_LooksLikeFormat(t *testing.T) {
filepath := path.Join(assetsPath, "libpng.png")
data, err := ioutil.ReadFile(filepath)
log.PanicIf(err)
pmp := NewPngMediaParser()
if pmp.LooksLikeFormat(data) != true {
t.Fatalf("not detected as png")
}
}
func ExamplePngMediaParser_LooksLikeFormat() {
filepath := path.Join(assetsPath, "libpng.png")
data, err := ioutil.ReadFile(filepath)
log.PanicIf(err)
pmp := NewPngMediaParser()
isPng := pmp.LooksLikeFormat(data)
fmt.Printf("%v\n", isPng)
// Output:
// true
}