resize_test.go 716 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package resize
  2. import (
  3. "image"
  4. "image/color"
  5. "testing"
  6. )
  7. var img = image.NewGray16(image.Rect(0, 0, 3, 3))
  8. func Test_Nearest(t *testing.T) {
  9. img.Set(1, 1, color.White)
  10. m := Resize(6, 0, img, NearestNeighbor)
  11. if m.At(2, 2) != m.At(3, 3) {
  12. t.Fail()
  13. }
  14. }
  15. func Test_Param1(t *testing.T) {
  16. m := Resize(0, 0, img, NearestNeighbor)
  17. if m.Bounds() != img.Bounds() {
  18. t.Fail()
  19. }
  20. }
  21. func Test_Param2(t *testing.T) {
  22. m := Resize(100, 0, img, NearestNeighbor)
  23. if m.Bounds() != image.Rect(0, 0, 100, 100) {
  24. t.Fail()
  25. }
  26. }
  27. func Test_ZeroImg(t *testing.T) {
  28. zeroImg := image.NewGray16(image.Rect(0, 0, 0, 0))
  29. m := Resize(0, 0, zeroImg, NearestNeighbor)
  30. if m.Bounds() != zeroImg.Bounds() {
  31. t.Fail()
  32. }
  33. }