d3dx9/tests: Use the available ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2017-12-29 19:20:10 +01:00 committed by Alexandre Julliard
parent 95dc536817
commit c5dfe1b139
2 changed files with 44 additions and 25 deletions

View File

@ -1296,15 +1296,20 @@ static void test_effect_parameter_value_GetMatrix(const struct test_effect_param
const D3DXPARAMETER_DESC *res_desc = &res->desc;
const char *res_full_name = res->full_name;
HRESULT hr;
DWORD cmp = 0xabababab;
FLOAT fvalue[16];
union
{
DWORD d;
float f;
} cmp;
float fvalue[16];
UINT l, k, err = 0;
cmp.d = 0xabababab;
memset(fvalue, 0xab, sizeof(fvalue));
hr = effect->lpVtbl->GetMatrix(effect, parameter, (D3DXMATRIX *)&fvalue);
if (!res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS)
{
ok(hr == D3D_OK, "%u - %s: GetMatrix failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK);
ok(hr == D3D_OK, "%u - %s: GetMatrix failed, got %#x, expected %#x.\n", i, res_full_name, hr, D3D_OK);
for (k = 0; k < 4; ++k)
{
@ -1322,12 +1327,14 @@ static void test_effect_parameter_value_GetMatrix(const struct test_effect_param
}
else
{
ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrix failed, got %#x, expected %#x\n",
ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrix failed, got %#x, expected %#x.\n",
i, res_full_name, hr, D3DERR_INVALIDCALL);
for (l = 0; l < sizeof(fvalue) / sizeof(*fvalue); ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err;
for (l = 0; l < ARRAY_SIZE(fvalue); ++l)
if (fvalue[l] != cmp.f)
++err;
}
ok(!err, "%u - %s: GetMatrix failed with %u errors\n", i, res_full_name, err);
ok(!err, "%u - %s: GetMatrix failed with %u errors.\n", i, res_full_name, err);
}
static void test_effect_parameter_value_GetMatrixArray(const struct test_effect_parameter_value_result *res,
@ -1451,15 +1458,20 @@ static void test_effect_parameter_value_GetMatrixTranspose(const struct test_eff
const D3DXPARAMETER_DESC *res_desc = &res->desc;
const char *res_full_name = res->full_name;
HRESULT hr;
DWORD cmp = 0xabababab;
FLOAT fvalue[16];
union
{
DWORD d;
float f;
} cmp;
float fvalue[16];
UINT l, k, err = 0;
cmp.d = 0xabababab;
memset(fvalue, 0xab, sizeof(fvalue));
hr = effect->lpVtbl->GetMatrixTranspose(effect, parameter, (D3DXMATRIX *)&fvalue);
if (!res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS)
{
ok(hr == D3D_OK, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK);
ok(hr == D3D_OK, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x.\n", i, res_full_name, hr, D3D_OK);
for (k = 0; k < 4; ++k)
{
@ -1477,7 +1489,7 @@ static void test_effect_parameter_value_GetMatrixTranspose(const struct test_eff
}
else if (!res_desc->Elements && (res_desc->Class == D3DXPC_VECTOR || res_desc->Class == D3DXPC_SCALAR))
{
ok(hr == D3D_OK, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK);
ok(hr == D3D_OK, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x.\n", i, res_full_name, hr, D3D_OK);
for (k = 0; k < 4; ++k)
{
@ -1495,12 +1507,14 @@ static void test_effect_parameter_value_GetMatrixTranspose(const struct test_eff
}
else
{
ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x\n",
ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixTranspose failed, got %#x, expected %#x.\n",
i, res_full_name, hr, D3DERR_INVALIDCALL);
for (l = 0; l < sizeof(fvalue) / sizeof(*fvalue); ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err;
for (l = 0; l < ARRAY_SIZE(fvalue); ++l)
if (fvalue[l] != cmp.f)
++err;
}
ok(!err, "%u - %s: GetMatrixTranspose failed with %u errors\n", i, res_full_name, err);
ok(!err, "%u - %s: GetMatrixTranspose failed with %u errors.\n", i, res_full_name, err);
}
static void test_effect_parameter_value_GetMatrixTransposeArray(const struct test_effect_parameter_value_result *res,
@ -1674,8 +1688,7 @@ static void test_effect_parameter_value_ResetValue(const struct test_effect_para
static void test_effect_parameter_value(IDirect3DDevice9 *device)
{
UINT i;
UINT effect_count = sizeof(test_effect_parameter_value_data) / sizeof(*test_effect_parameter_value_data);
unsigned int effect_count = ARRAY_SIZE(test_effect_parameter_value_data), i;
for (i = 0; i < effect_count; ++i)
{

View File

@ -818,7 +818,7 @@ static void test_fvf_decl_conversion(void)
};
unsigned int i;
for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
for (i = 0; i < ARRAY_SIZE(test_data); ++i)
{
test_decl_to_fvf(test_data[i].decl, test_data[i].fvf, D3D_OK, __LINE__, i);
test_fvf_to_decl(test_data[i].fvf, test_data[i].decl, D3D_OK, __LINE__, i);
@ -1185,12 +1185,15 @@ static void D3DXCreateMeshTest(void)
struct mesh mesh;
struct test_context *test_context;
static const D3DVERTEXELEMENT9 decl1[3] = {
static const D3DVERTEXELEMENT9 decl1[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
D3DDECL_END(), };
D3DDECL_END(),
};
static const D3DVERTEXELEMENT9 decl2[] = {
static const D3DVERTEXELEMENT9 decl2[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
{0, 24, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_PSIZE, 0},
@ -1201,7 +1204,8 @@ static void D3DXCreateMeshTest(void)
D3DDECL_END(),
};
static const D3DVERTEXELEMENT9 decl3[] = {
static const D3DVERTEXELEMENT9 decl3[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{1, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
D3DDECL_END(),
@ -1268,7 +1272,7 @@ static void D3DXCreateMeshTest(void)
if (hr == D3D_OK)
{
size = sizeof(decl1) / sizeof(decl1[0]);
size = ARRAY_SIZE(decl1);
for (i = 0; i < size - 1; i++)
{
ok(test_decl[i].Stream == decl1[i].Stream, "Returned stream %d, expected %d\n", test_decl[i].Stream, decl1[i].Stream);
@ -1329,7 +1333,7 @@ static void D3DXCreateMeshTest(void)
if (hr == D3D_OK)
{
size = sizeof(decl2) / sizeof(decl2[0]);
size = ARRAY_SIZE(decl2);
for (i = 0; i < size - 1; i++)
{
ok(test_decl[i].Stream == decl2[i].Stream, "Returned stream %d, expected %d\n", test_decl[i].Stream, decl2[i].Stream);
@ -1387,10 +1391,12 @@ static void D3DXCreateMeshFVFTest(void)
struct mesh mesh;
struct test_context *test_context;
static const D3DVERTEXELEMENT9 decl[3] = {
static const D3DVERTEXELEMENT9 decl[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
D3DDECL_END(), };
D3DDECL_END(),
};
hr = D3DXCreateMeshFVF(0, 0, 0, 0, NULL, NULL);
ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
@ -1453,7 +1459,7 @@ static void D3DXCreateMeshFVFTest(void)
if (hr == D3D_OK)
{
size = sizeof(decl) / sizeof(decl[0]);
size = ARRAY_SIZE(decl);
for (i = 0; i < size - 1; i++)
{
ok(test_decl[i].Stream == decl[i].Stream, "Returned stream %d, expected %d\n", test_decl[i].Stream, decl[i].Stream);