Skip to content
Snippets Groups Projects
Commit 69ecfdfb authored by Elizabeth Figura's avatar Elizabeth Figura Committed by Alexandre Julliard
Browse files

tests: Use compare_uint() in compare_float().

Comparing the result of abs() is broken in the case that x - y == INT_MIN.
parent bdfec488
No related branches found
No related tags found
1 merge request!247tests: Cast abs() result to unsigned int in compare_float().
Pipeline #11808 skipped
......@@ -74,13 +74,6 @@ static void set_viewport(D3D12_VIEWPORT *vp, float x, float y,
vp->MaxDepth = max_depth;
}
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, BYTE max_diff)
{
return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)
......
......@@ -82,6 +82,13 @@ static inline bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t
return true;
}
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_float(float f, float g, unsigned int ulps)
{
int x, y;
......@@ -101,10 +108,7 @@ static bool compare_float(float f, float g, unsigned int ulps)
if (y < 0)
y = INT_MIN - y;
if (abs(x - y) > ulps)
return false;
return true;
return compare_uint(x, y, ulps);
}
static inline bool compare_uvec4(const struct uvec4 *v1, const struct uvec4 *v2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment