vcomp/tests: Add tests for atomic double functions.

This commit is contained in:
Sebastian Lackner 2015-07-27 01:39:34 +02:00 committed by Alexandre Julliard
parent 36fe1f8a82
commit dfe32d6c52
1 changed files with 34 additions and 0 deletions

View File

@ -33,18 +33,22 @@ static VOID (WINAPI *pReleaseActCtx)(HANDLE);
static void (CDECL *p_vcomp_atomic_add_i4)(int *dest, int val);
static void (CDECL *p_vcomp_atomic_add_r4)(float *dest, float val);
static void (CDECL *p_vcomp_atomic_add_r8)(double *dest, double val);
static void (CDECL *p_vcomp_atomic_and_i4)(int *dest, int val);
static void (CDECL *p_vcomp_atomic_div_i4)(int *dest, int val);
static void (CDECL *p_vcomp_atomic_div_r4)(float *dest, float val);
static void (CDECL *p_vcomp_atomic_div_r8)(double *dest, double val);
static void (CDECL *p_vcomp_atomic_div_ui4)(unsigned int *dest, unsigned int val);
static void (CDECL *p_vcomp_atomic_mul_i4)(int *dest, int val);
static void (CDECL *p_vcomp_atomic_mul_r4)(float *dest, float val);
static void (CDECL *p_vcomp_atomic_mul_r8)(double *dest, double val);
static void (CDECL *p_vcomp_atomic_or_i4)(int *dest, int val);
static void (CDECL *p_vcomp_atomic_shl_i4)(int *dest, int val);
static void (CDECL *p_vcomp_atomic_shr_i4)(int *dest, int val);
static void (CDECL *p_vcomp_atomic_shr_ui4)(unsigned int *dest, unsigned int val);
static void (CDECL *p_vcomp_atomic_sub_i4)(int *dest, int val);
static void (CDECL *p_vcomp_atomic_sub_r4)(float *dest, float val);
static void (CDECL *p_vcomp_atomic_sub_r8)(double *dest, double val);
static void (CDECL *p_vcomp_atomic_xor_i4)(int *dest, int val);
static void (CDECL *p_vcomp_barrier)(void);
static void (CDECL *p_vcomp_for_static_end)(void);
@ -192,18 +196,22 @@ static BOOL init_vcomp(void)
VCOMP_GET_PROC(_vcomp_atomic_add_i4);
VCOMP_GET_PROC(_vcomp_atomic_add_r4);
VCOMP_GET_PROC(_vcomp_atomic_add_r8);
VCOMP_GET_PROC(_vcomp_atomic_and_i4);
VCOMP_GET_PROC(_vcomp_atomic_div_i4);
VCOMP_GET_PROC(_vcomp_atomic_div_r4);
VCOMP_GET_PROC(_vcomp_atomic_div_r8);
VCOMP_GET_PROC(_vcomp_atomic_div_ui4);
VCOMP_GET_PROC(_vcomp_atomic_mul_i4);
VCOMP_GET_PROC(_vcomp_atomic_mul_r4);
VCOMP_GET_PROC(_vcomp_atomic_mul_r8);
VCOMP_GET_PROC(_vcomp_atomic_or_i4);
VCOMP_GET_PROC(_vcomp_atomic_shl_i4);
VCOMP_GET_PROC(_vcomp_atomic_shr_i4);
VCOMP_GET_PROC(_vcomp_atomic_shr_ui4);
VCOMP_GET_PROC(_vcomp_atomic_sub_i4);
VCOMP_GET_PROC(_vcomp_atomic_sub_r4);
VCOMP_GET_PROC(_vcomp_atomic_sub_r8);
VCOMP_GET_PROC(_vcomp_atomic_xor_i4);
VCOMP_GET_PROC(_vcomp_barrier);
VCOMP_GET_PROC(_vcomp_for_static_end);
@ -958,6 +966,31 @@ static void test_atomic_float(void)
}
}
static void test_atomic_double(void)
{
struct
{
void (CDECL *func)(double *, double);
double v1, v2, expected;
}
tests[] =
{
{ p_vcomp_atomic_add_r8, 42.0, 17.0, 42.0 + 17.0 },
{ p_vcomp_atomic_div_r8, 42.0, 17.0, 42.0 / 17.0 },
{ p_vcomp_atomic_mul_r8, 42.0, 17.0, 42.0 * 17.0 },
{ p_vcomp_atomic_sub_r8, 42.0, 17.0, 42.0 - 17.0 },
};
int i;
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
{
double val = tests[i].v1;
tests[i].func(&val, tests[i].v2);
ok(tests[i].expected - 0.001 < val && val < tests[i].expected + 0.001,
"test %d: expected val == %f, got %f\n", i, tests[i].expected, val);
}
}
START_TEST(vcomp)
{
if (!init_vcomp())
@ -971,6 +1004,7 @@ START_TEST(vcomp)
test_vcomp_for_static_init();
test_atomic_integer32();
test_atomic_float();
test_atomic_double();
release_vcomp();
}