gdiplus/tests: Introduce compare_uint helper.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Esme Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-05-27 23:55:22 +02:00 committed by Alexandre Julliard
parent f6595bbdff
commit 10257a9417
1 changed files with 10 additions and 4 deletions

View File

@ -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;
}