Henri Verbeet : d3d12/tests: Introduce compare_uint().
Module: wine Branch: master Commit: c635f95518d50ed4e85ddf3fd4b283a7c6853d58 URL: https://source.winehq.org/git/wine.git/?a=commit;h=c635f95518d50ed4e85ddf3fd... Author: Henri Verbeet <hverbeet(a)codeweavers.com> Date: Mon Mar 30 20:48:12 2020 +0430 d3d12/tests: Introduce compare_uint(). Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3d12/tests/d3d12.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/dlls/d3d12/tests/d3d12.c b/dlls/d3d12/tests/d3d12.c index 33f5288a8c..0200047fd1 100644 --- a/dlls/d3d12/tests/d3d12.c +++ b/dlls/d3d12/tests/d3d12.c @@ -24,20 +24,19 @@ #include "dxgi1_6.h" #include "wine/test.h" +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 compare_color(DWORD c1, DWORD c2, unsigned int max_diff) { - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) - return FALSE; - c1 >>= 8; c2 >>= 8; - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) - return FALSE; - c1 >>= 8; c2 >>= 8; - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) - return FALSE; - c1 >>= 8; c2 >>= 8; - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) - return FALSE; - return TRUE; + return compare_uint(c1 & 0xff, c2 & 0xff, max_diff) + && compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff) + && compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff) + && compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff); } static BOOL equal_luid(LUID a, LUID b)
participants (1)
-
Alexandre Julliard