bimg/file_test.go

39 lines
603 B
Go
Raw Normal View History

2015-04-06 06:23:25 +08:00
package bimg
import (
"testing"
)
func TestRead(t *testing.T) {
buf, err := Read("fixtures/test.jpg")
if err != nil {
t.Errorf("Cannot read the image: %#v", err)
}
if len(buf) == 0 {
t.Fatal("Empty buffer")
}
if DetermineImageType(buf) != JPEG {
t.Fatal("Image is not jpeg")
}
}
2015-04-07 05:43:30 +08:00
func TestWrite(t *testing.T) {
buf, err := Read("fixtures/test.jpg")
if err != nil {
t.Errorf("Cannot read the image: %#v", err)
}
if len(buf) == 0 {
t.Fatal("Empty buffer")
}
err = Write("fixtures/test_write_out.jpg", buf)
if err != nil {
t.Fatal("Cannot write the file: %#v", err)
}
}