Commit c449da64 authored by Jeff Smith's avatar Jeff Smith Committed by Alexandre Julliard

d3dx9_36/tests: Use compare_uint() in compare_float() instead of abs().

The result of abs(INT_MIN) is INT_MIN, which breaks the ulps comparison.
parent 076d0641
......@@ -23,6 +23,13 @@
#include "d3dx9.h"
/* helper functions */
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, UINT ulps)
{
INT x = *(INT *)&f;
......@@ -33,10 +40,7 @@ static BOOL compare_float(FLOAT f, FLOAT g, UINT 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 INT get_int(D3DXPARAMETER_TYPE type, const void *data)
......
......@@ -24,6 +24,13 @@
#include <math.h>
#include <stdint.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_float(float f, float g, unsigned int ulps)
{
int x = *(int *)&f;
......@@ -34,10 +41,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 BOOL compare_vec2(const D3DXVECTOR2 *v1, const D3DXVECTOR2 *v2, unsigned int ulps)
......
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