From 5931cf0a302415374c640e0fdcf4dc814331c905 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Fri, 16 Jul 2021 16:07:05 +0200 Subject: [PATCH] oleaut32/tests: Use EQ_DOUBLE() in vartype too. This simplifies the code and fixes support for negative values. Also trim unnecessary spaces from the EXPECT_DBL() failure messages. Signed-off-by: Francois Gouget Signed-off-by: Alexandre Julliard --- dlls/oleaut32/tests/vartype.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c index c69db6cba17..4a32caae5c2 100644 --- a/dlls/oleaut32/tests/vartype.c +++ b/dlls/oleaut32/tests/vartype.c @@ -50,6 +50,11 @@ DEFINE_GUID(UUID_test_struct, 0x4029f190, 0xca4a, 0x4611, 0xae,0xb9,0x67,0x39,0x # endif #endif +/* When comparing floating point values we cannot expect an exact match + * because the rounding errors depend on the exact algorithm. + */ +#define EQ_DOUBLE(a,b) (fabs((a)-(b)) / (1.0+fabs(a)+fabs(b)) < 1e-14) + static HMODULE hOleaut32; /* Has I8/UI8 data type? */ @@ -77,7 +82,7 @@ static BOOL has_locales; ok(hres == S_OK && out == (CONV_TYPE)(x), "expected " #x ", got " fs "; hres=0x%08x\n", out, hres) #define EXPECT(x) EXPECTRES(S_OK, (x)) #define EXPECT_DBL(x) \ - ok(hres == S_OK && fabs(out-(x))<=1e-14*(x), "expected %16.16g, got %16.16g; hres=0x%08x\n", (x), out, hres) + ok(hres == S_OK && EQ_DOUBLE(out, (x)), "expected %.16g, got %.16g; hres=0x%08x\n", (x), out, hres) #define CONVERT(func, val) in = val; hres = func(in, &out) #define CONVERTRANGE(func,start,end) for (i = start; i < end; i+=1) { CONVERT(func, i); EXPECT(i); };