mirror of https://github.com/talgo-cloud/bimg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
604 B
39 lines
604 B
package bimg
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestRead(t *testing.T) {
|
|
buf, err := Read("testdata/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")
|
|
}
|
|
}
|
|
|
|
func TestWrite(t *testing.T) {
|
|
buf, err := Read("testdata/test.jpg")
|
|
|
|
if err != nil {
|
|
t.Errorf("Cannot read the image: %#v", err)
|
|
}
|
|
|
|
if len(buf) == 0 {
|
|
t.Fatal("Empty buffer")
|
|
}
|
|
|
|
err = Write("testdata/test_write_out.jpg", buf)
|
|
if err != nil {
|
|
t.Fatalf("Cannot write the file: %#v", err)
|
|
}
|
|
}
|