mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 18:50:06 +00:00
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.
This commit is contained in:
parent
076d064140
commit
c449da64e1
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue