Jacek Caban : gdiplus/tests: Introduce compare_uint helper.
Alexandre Julliard
julliard at winehq.org
Fri May 29 15:22:54 CDT 2020
Module: wine
Branch: master
Commit: 10257a9417323f87094eda18fb4122f02a36aad4
URL: https://source.winehq.org/git/wine.git/?a=commit;h=10257a9417323f87094eda18fb4122f02a36aad4
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed May 27 23:55:22 2020 +0200
gdiplus/tests: Introduce compare_uint helper.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Esme Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdiplus/tests/image.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index de6fad093d..b17323cb75 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -39,15 +39,21 @@ static GpStatus (WINGDIPAPI *pGdipInitializePalette)(ColorPalette*,PaletteType,I
#define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (UINT)(expected), (UINT)(got))
#define expectf(expected, got) ok(fabs((expected) - (got)) < 0.0001, "Expected %f, got %f\n", (expected), (got))
+static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
+{
+ unsigned int diff = x > y ? x - y : y - x;
+ return diff <= max_diff;
+}
+
static BOOL color_match(ARGB c1, ARGB c2, BYTE max_diff)
{
- if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+ if (!compare_uint(c1 & 0xff, c2 & 0xff, max_diff)) return FALSE;
c1 >>= 8; c2 >>= 8;
- if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+ if (!compare_uint(c1 & 0xff, c2 & 0xff, max_diff)) return FALSE;
c1 >>= 8; c2 >>= 8;
- if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+ if (!compare_uint(c1 & 0xff, c2 & 0xff, max_diff)) return FALSE;
c1 >>= 8; c2 >>= 8;
- if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
+ if (!compare_uint(c1 & 0xff, c2 & 0xff, max_diff)) return FALSE;
return TRUE;
}
More information about the wine-cvs
mailing list