d3dx8: Implement D3DX8Vec2LengthSq with a test.

This commit is contained in:
David Adam 2007-10-14 01:15:30 +02:00 committed by Alexandre Julliard
parent e4ba8eb450
commit d404ec8c4b
3 changed files with 19 additions and 0 deletions

View File

@ -39,7 +39,19 @@ static void D3X8Vector2Test(void)
expected=0.0f;
got= D3DXVec2Length(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec2LengthSq________________________*/
expected = 25.0f;
got = D3DXVec2LengthSq(&u);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/* Tests the case NULL */
expected=0.0f;
got= D3DXVec2LengthSq(NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
}
START_TEST(math)
{
D3X8Vector2Test();

View File

@ -59,5 +59,6 @@ typedef struct D3DXCOLOR
} D3DXCOLOR, *LPD3DXCOLOR;
FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv);
#endif /* __D3DX8MATH_H__ */

View File

@ -25,4 +25,10 @@ extern inline FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv)
return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
}
extern inline FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv)
{
if (!pv) return 0.0f;
return( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
}
#endif