Skip to content

Commit

Permalink
add basic tests for NewCropped
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Burns committed Sep 18, 2012
1 parent ed902d2 commit 402bdaa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ func TestResizeSuccess(t *testing.T) {
assertDimension(t, resized, "50x50")
}

func TestCropSuccess(t *testing.T) {
img := asset("./assets/image.jpg")
defer img.Destroy()

cropped, err := img.NewCropped(0,0,Bounds{50, 50})
if err != nil {
t.Error(err)
}
defer cropped.Destroy()

assertDimension(t, cropped, "50x50")
}

func TestGifResizeSuccess(t *testing.T) {
img := asset("./assets/image.gif")
defer img.Destroy()
Expand Down Expand Up @@ -101,6 +114,16 @@ func TestResampleFailure(t *testing.T) {
}
}

func TestCropFailure(t *testing.T) {
img := asset("./assets/image.jpg")
defer img.Destroy()

_, err := img.NewCropped(0,0,Bounds{-1, 50})
if err == nil {
t.Fatalf("This should have failed...")
}
}

func TestDecodeEncode(t *testing.T) {
img := asset("./assets/image.jpg")
defer img.Destroy()
Expand Down

0 comments on commit 402bdaa

Please sign in to comment.