From 3b366d1edd6c8827556c1ff08c25d89808415fc7 Mon Sep 17 00:00:00 2001 From: Jacek Olszak Date: Tue, 12 Feb 2019 15:24:17 +0100 Subject: [PATCH] #159 Use more precise delta for floats comparision --- geometry_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/geometry_test.go b/geometry_test.go index f97b8cd..13f90e2 100644 --- a/geometry_test.go +++ b/geometry_test.go @@ -81,23 +81,24 @@ func TestResizeRect(t *testing.T) { } func TestMatrix_Unproject(t *testing.T) { + const delta = 4e-16 t.Run("for rotated matrix", func(t *testing.T) { matrix := pixel.IM.Rotated(pixel.ZV, math.Pi/2) unprojected := matrix.Unproject(pixel.V(0, 1)) - assert.InDelta(t, unprojected.X, 1, 0.01) - assert.InDelta(t, unprojected.Y, 0, 0.01) + assert.InDelta(t, unprojected.X, 1, delta) + assert.InDelta(t, unprojected.Y, 0, delta) }) t.Run("for moved matrix", func(t *testing.T) { matrix := pixel.IM.Moved(pixel.V(5, 5)) unprojected := matrix.Unproject(pixel.V(0, 0)) - assert.InDelta(t, unprojected.X, -5, 0.01) - assert.InDelta(t, unprojected.Y, -5, 0.01) + assert.InDelta(t, unprojected.X, -5, delta) + assert.InDelta(t, unprojected.Y, -5, delta) }) t.Run("for scaled matrix", func(t *testing.T) { matrix := pixel.IM.Scaled(pixel.ZV, 2) unprojected := matrix.Unproject(pixel.V(4, 4)) - assert.InDelta(t, unprojected.X, 2, 0.01) - assert.InDelta(t, unprojected.Y, 2, 0.01) + assert.InDelta(t, unprojected.X, 2, delta) + assert.InDelta(t, unprojected.Y, 2, delta) }) t.Run("for singular matrix", func(t *testing.T) { matrix := pixel.Matrix{0, 0, 0, 0, 0, 0}