d3dx9/tests: Cleanup expect_vec.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
cbda84abd9
commit
c0dabf1e6d
|
@ -45,6 +45,11 @@ static BOOL compare_float(float f, float g, unsigned int ulps)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL compare_vec2(const D3DXVECTOR2 *v1, const D3DXVECTOR2 *v2, unsigned int ulps)
|
||||||
|
{
|
||||||
|
return compare_float(v1->x, v2->x, ulps) && compare_float(v1->y, v2->y, ulps);
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL compare_color(const D3DXCOLOR *c1, const D3DXCOLOR *c2, unsigned int ulps)
|
static BOOL compare_color(const D3DXCOLOR *c1, const D3DXCOLOR *c2, unsigned int ulps)
|
||||||
{
|
{
|
||||||
return compare_float(c1->r, c2->r, ulps)
|
return compare_float(c1->r, c2->r, ulps)
|
||||||
|
@ -85,6 +90,15 @@ static BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2, unsigned
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define expect_vec2(expected, vector, ulps) expect_vec2_(__LINE__, expected, vector, ulps)
|
||||||
|
static void expect_vec2_(unsigned int line, const D3DXVECTOR2 *expected, const D3DXVECTOR2 *vector, unsigned int ulps)
|
||||||
|
{
|
||||||
|
BOOL equal = compare_vec2(expected, vector, ulps);
|
||||||
|
ok_(__FILE__, line)(equal,
|
||||||
|
"Got unexpected vector {%.8e, %.8e}, expected {%.8e, %.8e}.\n",
|
||||||
|
vector->x, vector->y, expected->x, expected->y);
|
||||||
|
}
|
||||||
|
|
||||||
#define expect_color(expected, color, ulps) expect_color_(__LINE__, expected, color, ulps)
|
#define expect_color(expected, color, ulps) expect_color_(__LINE__, expected, color, ulps)
|
||||||
static void expect_color_(unsigned int line, const D3DXCOLOR *expected, const D3DXCOLOR *color, unsigned int ulps)
|
static void expect_color_(unsigned int line, const D3DXCOLOR *expected, const D3DXCOLOR *color, unsigned int ulps)
|
||||||
{
|
{
|
||||||
|
@ -182,8 +196,6 @@ static void expect_matrix_(unsigned int line, const D3DXMATRIX *expected, const
|
||||||
i); \
|
i); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define expect_vec(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
|
|
||||||
|
|
||||||
#define expect_vec3(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error)&&(relative_error(expectedvec.z, gotvec.z)<admitted_error),"Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
|
#define expect_vec3(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error)&&(relative_error(expectedvec.z, gotvec.z)<admitted_error),"Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
|
||||||
|
|
||||||
#define expect_vec4(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error)&&(relative_error(expectedvec.z, gotvec.z)<admitted_error)&&(relative_error(expectedvec.w, gotvec.w)<admitted_error),"Expected Vector= (%f, %f, %f, %f)\n , Got Vector= (%f, %f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, expectedvec.w, gotvec.x, gotvec.y, gotvec.z, gotvec.w);
|
#define expect_vec4(expectedvec,gotvec) ok((relative_error(expectedvec.x, gotvec.x)<admitted_error)&&(relative_error(expectedvec.y, gotvec.y)<admitted_error)&&(relative_error(expectedvec.z, gotvec.z)<admitted_error)&&(relative_error(expectedvec.w, gotvec.w)<admitted_error),"Expected Vector= (%f, %f, %f, %f)\n , Got Vector= (%f, %f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, expectedvec.w, gotvec.x, gotvec.y, gotvec.z, gotvec.w);
|
||||||
|
@ -1136,7 +1148,7 @@ static void D3DXVector2Test(void)
|
||||||
/*_______________D3DXVec2Add__________________________*/
|
/*_______________D3DXVec2Add__________________________*/
|
||||||
expectedvec.x = -4.0f; expectedvec.y = 13.0f;
|
expectedvec.x = -4.0f; expectedvec.y = 13.0f;
|
||||||
D3DXVec2Add(&gotvec,&u,&v);
|
D3DXVec2Add(&gotvec,&u,&v);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
/* Tests the case NULL */
|
/* Tests the case NULL */
|
||||||
funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
|
funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
|
||||||
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
||||||
|
@ -1146,12 +1158,12 @@ static void D3DXVector2Test(void)
|
||||||
/*_______________D3DXVec2BaryCentric___________________*/
|
/*_______________D3DXVec2BaryCentric___________________*/
|
||||||
expectedvec.x = -12.0f; expectedvec.y = -21.0f;
|
expectedvec.x = -12.0f; expectedvec.y = -21.0f;
|
||||||
D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
|
D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
|
|
||||||
/*_______________D3DXVec2CatmullRom____________________*/
|
/*_______________D3DXVec2CatmullRom____________________*/
|
||||||
expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
|
expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
|
||||||
D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
|
D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
|
|
||||||
/*_______________D3DXVec2CCW__________________________*/
|
/*_______________D3DXVec2CCW__________________________*/
|
||||||
expected = 55.0f;
|
expected = 55.0f;
|
||||||
|
@ -1180,7 +1192,7 @@ static void D3DXVector2Test(void)
|
||||||
/*_______________D3DXVec2Hermite__________________________*/
|
/*_______________D3DXVec2Hermite__________________________*/
|
||||||
expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
|
expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
|
||||||
D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
|
D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
|
|
||||||
/*_______________D3DXVec2Length__________________________*/
|
/*_______________D3DXVec2Length__________________________*/
|
||||||
expected = 5.0f;
|
expected = 5.0f;
|
||||||
|
@ -1203,8 +1215,8 @@ static void D3DXVector2Test(void)
|
||||||
/*_______________D3DXVec2Lerp__________________________*/
|
/*_______________D3DXVec2Lerp__________________________*/
|
||||||
expectedvec.x = 68.0f; expectedvec.y = -28.5f;
|
expectedvec.x = 68.0f; expectedvec.y = -28.5f;
|
||||||
D3DXVec2Lerp(&gotvec, &u, &v, scale);
|
D3DXVec2Lerp(&gotvec, &u, &v, scale);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
/* Tests the case NULL */
|
/* Tests the case NULL. */
|
||||||
funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
|
funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
|
||||||
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
||||||
funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
|
funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
|
||||||
|
@ -1213,8 +1225,8 @@ static void D3DXVector2Test(void)
|
||||||
/*_______________D3DXVec2Maximize__________________________*/
|
/*_______________D3DXVec2Maximize__________________________*/
|
||||||
expectedvec.x = 3.0f; expectedvec.y = 9.0f;
|
expectedvec.x = 3.0f; expectedvec.y = 9.0f;
|
||||||
D3DXVec2Maximize(&gotvec, &u, &v);
|
D3DXVec2Maximize(&gotvec, &u, &v);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
/* Tests the case NULL */
|
/* Tests the case NULL. */
|
||||||
funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
|
funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
|
||||||
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
||||||
funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
|
funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
|
||||||
|
@ -1223,7 +1235,7 @@ static void D3DXVector2Test(void)
|
||||||
/*_______________D3DXVec2Minimize__________________________*/
|
/*_______________D3DXVec2Minimize__________________________*/
|
||||||
expectedvec.x = -7.0f; expectedvec.y = 4.0f;
|
expectedvec.x = -7.0f; expectedvec.y = 4.0f;
|
||||||
D3DXVec2Minimize(&gotvec,&u,&v);
|
D3DXVec2Minimize(&gotvec,&u,&v);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
/* Tests the case NULL */
|
/* Tests the case NULL */
|
||||||
funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
|
funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
|
||||||
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
||||||
|
@ -1233,16 +1245,16 @@ static void D3DXVector2Test(void)
|
||||||
/*_______________D3DXVec2Normalize_________________________*/
|
/*_______________D3DXVec2Normalize_________________________*/
|
||||||
expectedvec.x = 0.6f; expectedvec.y = 0.8f;
|
expectedvec.x = 0.6f; expectedvec.y = 0.8f;
|
||||||
D3DXVec2Normalize(&gotvec,&u);
|
D3DXVec2Normalize(&gotvec,&u);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
/* Test the nul vector */
|
/* Test the nul vector */
|
||||||
expectedvec.x = 0.0f; expectedvec.y = 0.0f;
|
expectedvec.x = 0.0f; expectedvec.y = 0.0f;
|
||||||
D3DXVec2Normalize(&gotvec,&nul);
|
D3DXVec2Normalize(&gotvec,&nul);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
|
|
||||||
/*_______________D3DXVec2Scale____________________________*/
|
/*_______________D3DXVec2Scale____________________________*/
|
||||||
expectedvec.x = -19.5f; expectedvec.y = -26.0f;
|
expectedvec.x = -19.5f; expectedvec.y = -26.0f;
|
||||||
D3DXVec2Scale(&gotvec,&u,scale);
|
D3DXVec2Scale(&gotvec,&u,scale);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
/* Tests the case NULL */
|
/* Tests the case NULL */
|
||||||
funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
|
funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
|
||||||
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
||||||
|
@ -1252,8 +1264,8 @@ static void D3DXVector2Test(void)
|
||||||
/*_______________D3DXVec2Subtract__________________________*/
|
/*_______________D3DXVec2Subtract__________________________*/
|
||||||
expectedvec.x = 10.0f; expectedvec.y = -5.0f;
|
expectedvec.x = 10.0f; expectedvec.y = -5.0f;
|
||||||
D3DXVec2Subtract(&gotvec, &u, &v);
|
D3DXVec2Subtract(&gotvec, &u, &v);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
/* Tests the case NULL */
|
/* Tests the case NULL. */
|
||||||
funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
|
funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
|
||||||
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
|
||||||
funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
|
funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
|
||||||
|
@ -1270,15 +1282,15 @@ static void D3DXVector2Test(void)
|
||||||
/*_______________D3DXVec2TransformCoord_______________________*/
|
/*_______________D3DXVec2TransformCoord_______________________*/
|
||||||
expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
|
expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
|
||||||
D3DXVec2TransformCoord(&gotvec, &u, &mat);
|
D3DXVec2TransformCoord(&gotvec, &u, &mat);
|
||||||
expect_vec(expectedvec, gotvec);
|
expect_vec2(&expectedvec, &gotvec, 1);
|
||||||
gotvec.x = u.x; gotvec.y = u.y;
|
gotvec.x = u.x; gotvec.y = u.y;
|
||||||
D3DXVec2TransformCoord(&gotvec, (D3DXVECTOR2 *)&gotvec, &mat);
|
D3DXVec2TransformCoord(&gotvec, (D3DXVECTOR2 *)&gotvec, &mat);
|
||||||
expect_vec(expectedvec, gotvec);
|
expect_vec2(&expectedvec, &gotvec, 1);
|
||||||
|
|
||||||
/*_______________D3DXVec2TransformNormal______________________*/
|
/*_______________D3DXVec2TransformNormal______________________*/
|
||||||
expectedvec.x = 23.0f; expectedvec.y = 30.0f;
|
expectedvec.x = 23.0f; expectedvec.y = 30.0f;
|
||||||
D3DXVec2TransformNormal(&gotvec,&u,&mat);
|
D3DXVec2TransformNormal(&gotvec,&u,&mat);
|
||||||
expect_vec(expectedvec,gotvec);
|
expect_vec2(&expectedvec, &gotvec, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void D3DXVector3Test(void)
|
static void D3DXVector3Test(void)
|
||||||
|
|
Loading…
Reference in New Issue