github.com/uriel/resize@v0.0.0-20120831222110-339b8fd43a21/resize_test.go (about) 1 package resize 2 3 import ( 4 "image" 5 "image/color" 6 "testing" 7 ) 8 9 var img = image.NewGray16(image.Rect(0, 0, 3, 3)) 10 11 func init() { 12 img.Set(1, 1, color.White) 13 } 14 15 func Test_Nearest(t *testing.T) { 16 m := Resize(6, 0, img, NearestNeighbor) 17 if m.At(2, 2) != m.At(3, 3) { 18 t.Fail() 19 } 20 } 21 22 func Test_Param1(t *testing.T) { 23 m := Resize(0, 0, img, NearestNeighbor) 24 if m.Bounds() != img.Bounds() { 25 t.Fail() 26 } 27 } 28 29 func Test_Param2(t *testing.T) { 30 m := Resize(100, 0, img, NearestNeighbor) 31 if m.Bounds() != image.Rect(0, 0, 100, 100) { 32 t.Fail() 33 } 34 } 35 36 func Test_ZeroImg(t *testing.T) { 37 zeroImg := image.NewGray16(image.Rect(0, 0, 0, 0)) 38 39 m := Resize(0, 0, zeroImg, NearestNeighbor) 40 if m.Bounds() != zeroImg.Bounds() { 41 t.Fail() 42 } 43 } 44 45 func Benchmark_BigResize(b *testing.B) { 46 m := Resize(1000, 1000, img, Lanczos3) 47 m.At(0, 0) 48 }