|
|
|
|
@ -20,6 +20,11 @@ func TestResize(t *testing.T) {
|
|
|
|
|
t.Fatal("Image is not jpeg")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size, _ := Size(newImg)
|
|
|
|
|
if size.Height != options.Height || size.Width != options.Width {
|
|
|
|
|
t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write("fixtures/test_out.jpg", newImg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -36,12 +41,17 @@ func TestRotate(t *testing.T) {
|
|
|
|
|
t.Fatal("Image is not jpeg")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size, _ := Size(newImg)
|
|
|
|
|
if size.Height != options.Width {
|
|
|
|
|
t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write("fixtures/test_rotate_out.jpg", newImg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCorruptedImage(t *testing.T) {
|
|
|
|
|
options := Options{Width: 800, Height: 600}
|
|
|
|
|
buf, _ := Read("fixtures/corrupt.jpg")
|
|
|
|
|
func TestInvalidRotate(t *testing.T) {
|
|
|
|
|
options := Options{Width: 800, Height: 600, Rotate: 111}
|
|
|
|
|
buf, _ := Read("fixtures/test.jpg")
|
|
|
|
|
|
|
|
|
|
newImg, err := Resize(buf, options)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@ -52,12 +62,17 @@ func TestCorruptedImage(t *testing.T) {
|
|
|
|
|
t.Fatal("Image is not jpeg")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write("fixtures/test_corrupt_out.jpg", newImg)
|
|
|
|
|
size, _ := Size(newImg)
|
|
|
|
|
if size.Height != options.Width {
|
|
|
|
|
t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestInvalidRotate(t *testing.T) {
|
|
|
|
|
options := Options{Width: 800, Height: 600, Rotate: 111}
|
|
|
|
|
buf, _ := Read("fixtures/test.jpg")
|
|
|
|
|
Write("fixtures/test_invalid_rotate_out.jpg", newImg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCorruptedImage(t *testing.T) {
|
|
|
|
|
options := Options{Width: 800, Height: 600}
|
|
|
|
|
buf, _ := Read("fixtures/corrupt.jpg")
|
|
|
|
|
|
|
|
|
|
newImg, err := Resize(buf, options)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@ -68,7 +83,12 @@ func TestInvalidRotate(t *testing.T) {
|
|
|
|
|
t.Fatal("Image is not jpeg")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write("fixtures/test_invalid_rotate_out.jpg", newImg)
|
|
|
|
|
size, _ := Size(newImg)
|
|
|
|
|
if size.Height != options.Height || size.Width != options.Width {
|
|
|
|
|
t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write("fixtures/test_corrupt_out.jpg", newImg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestNoColorProfile(t *testing.T) {
|
|
|
|
|
@ -84,6 +104,11 @@ func TestNoColorProfile(t *testing.T) {
|
|
|
|
|
if metadata.Profile == true {
|
|
|
|
|
t.Fatal("Invalid profile data")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size, _ := Size(newImg)
|
|
|
|
|
if size.Height != options.Height || size.Width != options.Width {
|
|
|
|
|
t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestConvert(t *testing.T) {
|
|
|
|
|
|