1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 03:45:57 +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:
Jeff Smith 2023-08-02 22:39:03 -05:00 committed by Alexandre Julliard
parent 076d064140
commit c449da64e1
2 changed files with 16 additions and 8 deletions

View File

@ -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)

View File

@ -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)