oleaut32/tests: Avoid an ARRAY_SIZE-like macro.
Also use a better type for the dimension variable. Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
050edeb420
commit
db48640a51
|
@ -828,11 +828,9 @@ static void test_SafeArrayCreateLockDestroy(void)
|
||||||
SAFEARRAY *sa;
|
SAFEARRAY *sa;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
VARTYPE vt;
|
VARTYPE vt;
|
||||||
int dimension;
|
UINT dimension;
|
||||||
|
|
||||||
#define NUM_DIMENSIONS (int)(sizeof(sab) / sizeof(sab[0]))
|
for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
|
||||||
|
|
||||||
for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
|
|
||||||
{
|
{
|
||||||
sab[dimension].lLbound = 0;
|
sab[dimension].lLbound = 0;
|
||||||
sab[dimension].cElements = 8;
|
sab[dimension].cElements = 8;
|
||||||
|
@ -850,7 +848,7 @@ static void test_SafeArrayCreateLockDestroy(void)
|
||||||
|
|
||||||
/* Don't test 0 sized dimensions, as Windows has a bug which allows this */
|
/* Don't test 0 sized dimensions, as Windows has a bug which allows this */
|
||||||
|
|
||||||
for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
|
for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
|
||||||
sab[dimension].cElements = 8;
|
sab[dimension].cElements = 8;
|
||||||
|
|
||||||
/* Test all VARTYPES in 1-4 dimensions */
|
/* Test all VARTYPES in 1-4 dimensions */
|
||||||
|
@ -870,7 +868,7 @@ static void test_SafeArrayCreateLockDestroy(void)
|
||||||
|
|
||||||
if (sa)
|
if (sa)
|
||||||
{
|
{
|
||||||
ok(SafeArrayGetDim(sa) == (UINT)dimension,
|
ok(SafeArrayGetDim(sa) == dimension,
|
||||||
"VARTYPE %d (@%d dimensions) cDims is %d, expected %d\n",
|
"VARTYPE %d (@%d dimensions) cDims is %d, expected %d\n",
|
||||||
vt, dimension, SafeArrayGetDim(sa), dimension);
|
vt, dimension, SafeArrayGetDim(sa), dimension);
|
||||||
ok(SafeArrayGetElemsize(sa) == dwLen || vt == VT_R8,
|
ok(SafeArrayGetElemsize(sa) == dwLen || vt == VT_R8,
|
||||||
|
@ -1007,13 +1005,13 @@ static void test_LockUnlock(void)
|
||||||
hres = SafeArrayUnlock(NULL);
|
hres = SafeArrayUnlock(NULL);
|
||||||
ok(hres == E_INVALIDARG, "Lock NULL array hres 0x%x\n", hres);
|
ok(hres == E_INVALIDARG, "Lock NULL array hres 0x%x\n", hres);
|
||||||
|
|
||||||
for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
|
for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
|
||||||
{
|
{
|
||||||
sab[dimension].lLbound = 0;
|
sab[dimension].lLbound = 0;
|
||||||
sab[dimension].cElements = 8;
|
sab[dimension].cElements = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
sa = SafeArrayCreate(VT_UI1, NUM_DIMENSIONS, sab);
|
sa = SafeArrayCreate(VT_UI1, ARRAY_SIZE(sab), sab);
|
||||||
|
|
||||||
/* Test maximum locks */
|
/* Test maximum locks */
|
||||||
test_LockUnlock_Vector:
|
test_LockUnlock_Vector:
|
||||||
|
@ -1054,27 +1052,27 @@ test_LockUnlock_Vector:
|
||||||
static void test_SafeArrayGetPutElement(void)
|
static void test_SafeArrayGetPutElement(void)
|
||||||
{
|
{
|
||||||
SAFEARRAYBOUND sab[4];
|
SAFEARRAYBOUND sab[4];
|
||||||
LONG indices[NUM_DIMENSIONS], index;
|
LONG indices[ARRAY_SIZE(sab)], index;
|
||||||
SAFEARRAY *sa;
|
SAFEARRAY *sa;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
int value = 0, gotvalue, dimension;
|
int value = 0, gotvalue, dimension;
|
||||||
IRecordInfoImpl *irec;
|
IRecordInfoImpl *irec;
|
||||||
unsigned int x,y,z,a;
|
unsigned int x,y,z,a;
|
||||||
|
|
||||||
for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
|
for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
|
||||||
{
|
{
|
||||||
sab[dimension].lLbound = dimension * 2 + 1;
|
sab[dimension].lLbound = dimension * 2 + 1;
|
||||||
sab[dimension].cElements = dimension * 3 + 1;
|
sab[dimension].cElements = dimension * 3 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sa = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
|
sa = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
|
||||||
if (!sa)
|
if (!sa)
|
||||||
return; /* Some early versions can't handle > 3 dims */
|
return; /* Some early versions can't handle > 3 dims */
|
||||||
|
|
||||||
ok(sa->cbElements == sizeof(value), "int size mismatch\n");
|
ok(sa->cbElements == sizeof(value), "int size mismatch\n");
|
||||||
|
|
||||||
/* Failure cases */
|
/* Failure cases */
|
||||||
for (x = 0; x < NUM_DIMENSIONS; x++)
|
for (x = 0; x < ARRAY_SIZE(sab); x++)
|
||||||
{
|
{
|
||||||
indices[0] = sab[0].lLbound;
|
indices[0] = sab[0].lLbound;
|
||||||
indices[1] = sab[1].lLbound;
|
indices[1] = sab[1].lLbound;
|
||||||
|
@ -1384,16 +1382,16 @@ static void test_SafeArrayCopyData(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
|
for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
|
||||||
{
|
{
|
||||||
sab[dimension].lLbound = dimension * 2 + 2;
|
sab[dimension].lLbound = dimension * 2 + 2;
|
||||||
sab[dimension].cElements = dimension * 3 + 1;
|
sab[dimension].cElements = dimension * 3 + 1;
|
||||||
size *= sab[dimension].cElements;
|
size *= sab[dimension].cElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
sa = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
|
sa = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
|
||||||
ok(sa != NULL, "Copy test couldn't create array\n");
|
ok(sa != NULL, "Copy test couldn't create array\n");
|
||||||
sacopy = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
|
sacopy = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
|
||||||
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
|
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
|
||||||
|
|
||||||
if (!sa || !sacopy)
|
if (!sa || !sacopy)
|
||||||
|
@ -1453,7 +1451,7 @@ static void test_SafeArrayCopyData(void)
|
||||||
hres = SafeArrayDestroy(sacopy);
|
hres = SafeArrayDestroy(sacopy);
|
||||||
ok(hres == S_OK, "got 0x%08x\n", hres);
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
||||||
|
|
||||||
sacopy = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
|
sacopy = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
|
||||||
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
|
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
|
||||||
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
|
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
|
||||||
|
|
||||||
|
@ -1491,7 +1489,7 @@ static void test_SafeArrayCopyData(void)
|
||||||
"got 0x%04x\n", sacopy->fFeatures);
|
"got 0x%04x\n", sacopy->fFeatures);
|
||||||
SafeArrayDestroy(sacopy);
|
SafeArrayDestroy(sacopy);
|
||||||
|
|
||||||
sacopy = SafeArrayCreate(VT_UI1, NUM_DIMENSIONS, sab);
|
sacopy = SafeArrayCreate(VT_UI1, ARRAY_SIZE(sab), sab);
|
||||||
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
|
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
|
||||||
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
|
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
|
||||||
hres = SafeArrayCopyData(sa, sacopy);
|
hres = SafeArrayCopyData(sa, sacopy);
|
||||||
|
@ -1507,7 +1505,7 @@ static void test_SafeArrayCreateEx(void)
|
||||||
SAFEARRAYBOUND sab[4];
|
SAFEARRAYBOUND sab[4];
|
||||||
SAFEARRAY *sa;
|
SAFEARRAY *sa;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
int dimension;
|
UINT dimension;
|
||||||
|
|
||||||
if (!pSafeArrayCreateEx)
|
if (!pSafeArrayCreateEx)
|
||||||
{
|
{
|
||||||
|
@ -1515,7 +1513,7 @@ static void test_SafeArrayCreateEx(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
|
for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
|
||||||
{
|
{
|
||||||
sab[dimension].lLbound = 0;
|
sab[dimension].lLbound = 0;
|
||||||
sab[dimension].cElements = 8;
|
sab[dimension].cElements = 8;
|
||||||
|
|
Loading…
Reference in New Issue