add miscellaneous tests

also fix minor bug in detecting content type for content less than 512
bytes.
This commit is contained in:
Will Norris 2019-06-11 14:02:44 -07:00
parent 6975320eb4
commit a7a8966289
4 changed files with 33 additions and 3 deletions

View file

@ -91,6 +91,7 @@ func TestCropParams(t *testing.T) {
{Options{CropX: 50, CropY: 100, CropWidth: 100, CropHeight: 150}, 50, 100, 64, 128},
{Options{CropX: -50, CropY: -50}, 14, 78, 64, 128},
{Options{CropY: 0.5, CropWidth: 0.5}, 0, 64, 32, 128},
{Options{Width: 10, Height: 10, SmartCrop: true}, 0, 0, 64, 64},
}
for _, tt := range tests {
want := image.Rect(tt.x0, tt.y0, tt.x1, tt.y1)
@ -148,6 +149,17 @@ func TestTransform(t *testing.T) {
}
}
func TestTransform_InvalidFormat(t *testing.T) {
src := newImage(2, 2, red, green, blue, yellow)
buf := new(bytes.Buffer)
png.Encode(buf, src)
_, err := Transform(buf.Bytes(), Options{Format: "invalid"})
if err == nil {
t.Errorf("Transform with invalid format did not return expected error")
}
}
// Test that each of the eight EXIF orientations is applied to the transformed
// image appropriately.
func TestTransform_EXIF(t *testing.T) {