[PATCH 2/2] d3dx9/tests: Don't use an arbitrary number in relative_error macro.

Matteo Bruni mbruni at codeweavers.com
Tue Apr 9 18:22:59 CDT 2013


0.01f isn't particularly meaningful, nor particularly small. I decided
to keep the '<' comparison to essentially ignore errors if the expected
result is in the range of denormals (since at that point floats lose
precision).
---
 dlls/d3dx9_36/tests/math.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c
index 8677825..9d90662 100644
--- a/dlls/d3dx9_36/tests/math.c
+++ b/dlls/d3dx9_36/tests/math.c
@@ -27,7 +27,7 @@
 
 #define admitted_error 0.0001f
 
-#define relative_error(exp, out) (fabsf(exp) < 0.01f ? fabsf(exp - out) : fabsf(1.0f - (out) / (exp)))
+#define relative_error(exp, out) (fabsf(exp) < 1e-38f ? fabsf(exp - out) : fabsf(1.0f - (out) / (exp)))
 
 #define expect_color(expectedcolor,gotcolor) ok((relative_error(expectedcolor.r, gotcolor.r)<admitted_error)&&(relative_error(expectedcolor.g, gotcolor.g)<admitted_error)&&(relative_error(expectedcolor.b, gotcolor.b)<admitted_error)&&(relative_error(expectedcolor.a, gotcolor.a)<admitted_error),"Expected Color= (%f, %f, %f, %f)\n , Got Color= (%f, %f, %f, %f)\n", expectedcolor.r, expectedcolor.g, expectedcolor.b, expectedcolor.a, gotcolor.r, gotcolor.g, gotcolor.b, gotcolor.a);
 
-- 
1.8.1.5




More information about the wine-patches mailing list