Commit 10257a94 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdiplus/tests: Introduce compare_uint helper.

parent f6595bbd
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment