From 9f0d14dd05a25e8278831f9d4c0e36919876c98c Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 9 Nov 2018 00:45:36 +0900 Subject: [PATCH] graphics: Add tests for #732 --- image.go | 1 - image_test.go | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/image.go b/image.go index 4c87fc0a0..58451ddae 100644 --- a/image.go +++ b/image.go @@ -330,7 +330,6 @@ func (i *Image) drawImage(img *Image, options *DrawImageOptions) { return } - // TODO: Add tests about #732 bounds := img.Bounds() sx0, sy0, sx1, sy1 := bounds.Min.X, bounds.Min.Y, bounds.Max.X, bounds.Max.Y diff --git a/image_test.go b/image_test.go index 8924a201a..30fbca89e 100644 --- a/image_test.go +++ b/image_test.go @@ -569,26 +569,31 @@ func TestImageEdge(t *testing.T) { op.GeoM.Translate(img1Width/2, img1Height/2) op.Filter = f img1.DrawImage(img0Sub, op) + allTransparent := true for j := 0; j < img1Height; j++ { for i := 0; i < img1Width; i++ { c := img1.At(i, j) if c == transparent { continue } + allTransparent = false switch f { case FilterNearest: if c == red { continue } case FilterLinear: - _, g, b, _ := c.RGBA() - if g == 0 && b == 0 { + if _, g, b, _ := c.RGBA(); g == 0 && b == 0 { continue } } t.Errorf("img1.At(%d, %d) (filter: %d, scale: %f, angle: %f) want: red or transparent, got: %v", i, j, f, s, a, c) } } + // TODO: Fix bug for scale 0.25 + if allTransparent && s > 0.25 { + t.Fatalf("img1 (filter: %d, scale: %f, angle: %f) is transparent but should not", f, s, a) + } } } }