mirror of
https://github.com/h2non/filetype.git
synced 2025-12-24 11:52:08 +08:00
26 lines
380 B
Go
26 lines
380 B
Go
package filetype
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestMatches(t *testing.T) {
|
|
cases := []struct {
|
|
buf []byte
|
|
ext string
|
|
}{
|
|
{[]byte{0xFF, 0xD8, 0xFF}, "jpg"},
|
|
}
|
|
|
|
for _, test := range cases {
|
|
match, err := Match(test.buf)
|
|
if err != nil {
|
|
t.Fatalf("Error: %s", err)
|
|
}
|
|
|
|
if match.Extension != test.ext {
|
|
t.Fatalf("Invalid image type: %s", match.Extension)
|
|
}
|
|
}
|
|
}
|