mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-16 23:35:13 +02:00
add miscellaneous tests
also fix minor bug in detecting content type for content less than 512 bytes.
This commit is contained in:
parent
6975320eb4
commit
a7a8966289
4 changed files with 33 additions and 3 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue