Commit 050edeb4 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

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

parent 0c8e555e
......@@ -420,7 +420,7 @@ static void test_font_events_disp(void)
hr = IFont_QueryInterface(pFont, &IID_IFontDisp, (void **)&pFontDisp);
EXPECT_HR(hr, S_OK);
for (i = 0; i < sizeof(font_dispids)/sizeof(font_dispids[0]); i++)
for (i = 0; i < ARRAY_SIZE(font_dispids); i++)
{
switch (font_dispids[i].dispid)
{
......
......@@ -501,7 +501,7 @@ static void test_Invoke(void)
/* DISPID_PICT_RENDER */
hdc = create_render_dc();
for (i = 0; i < sizeof(args)/sizeof(args[0]); i++)
for (i = 0; i < ARRAY_SIZE(args); i++)
V_VT(&args[i]) = VT_I4;
V_I4(&args[0]) = 0;
......@@ -679,7 +679,7 @@ static HRESULT picture_render(IPicture *iface, HDC hdc, LONG x, LONG y, LONG cx,
IPicture_QueryInterface(iface, &IID_IDispatch, (void**)&disp);
/* This is broken on 64 bits - accepted pointer argument type is still VT_I4 */
for (i = 0; i < sizeof(args)/sizeof(args[0]); i++)
for (i = 0; i < ARRAY_SIZE(args); i++)
V_VT(&args[i]) = VT_I4;
/* pack arguments and call */
......@@ -884,7 +884,7 @@ static void test_OleLoadPicturePath(void)
{emptyW, &IID_IPicture, NULL},
};
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
pic = (IPicture *)0xdeadbeef;
hres = OleLoadPicturePath(invalid_parameters[i].szURLorPath, NULL, 0, 0,
......@@ -924,7 +924,7 @@ static void test_OleLoadPicturePath(void)
WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL);
CloseHandle(file);
MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, sizeof(temp_fileW)/sizeof(WCHAR) - 8);
MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, ARRAY_SIZE(temp_fileW) - 8);
/* Try a normal DOS path. */
hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);
......
......@@ -567,7 +567,7 @@ static void test_safearray(void)
hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD failed with hres %x\n", hres);
for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) {
for (i = 0; i < ARRAY_SIZE(vttypes); i++) {
if ((i == VT_I8 || i == VT_UI8) && has_i8)
{
vttypes[i].elemsize = sizeof(LONG64);
......@@ -704,7 +704,7 @@ static void test_safearray(void)
if (!pSafeArrayAllocDescriptorEx)
return;
for (i = 0; i < sizeof(vttypes)/sizeof(vttypes[0]); i++) {
for (i = 0; i < ARRAY_SIZE(vttypes); i++) {
a = NULL;
hres = pSafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a);
ok(hres == S_OK, "SafeArrayAllocDescriptorEx gave hres 0x%x\n", hres);
......@@ -1457,7 +1457,7 @@ static void test_SafeArrayCopyData(void)
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
for (i = 0; i < sizeof(ignored_copy_features)/sizeof(USHORT); i++)
for (i = 0; i < ARRAY_SIZE(ignored_copy_features); i++)
{
USHORT feature = ignored_copy_features[i];
USHORT orig = sacopy->fFeatures;
......@@ -1765,7 +1765,7 @@ static void test_SafeArrayCopy(void)
ok(sa->fFeatures == 0, "got src features 0x%04x\n", sa->fFeatures);
sa->cbElements = 16;
for (i = 0; i < sizeof(ignored_copy_features)/sizeof(USHORT); i++)
for (i = 0; i < ARRAY_SIZE(ignored_copy_features); i++)
{
USHORT feature = ignored_copy_features[i];
......
......@@ -725,7 +725,7 @@ static HRESULT WINAPI Widget_VarArg(
static BOOL mystruct_uint_ordered(MYSTRUCT *mystruct)
{
int i;
for (i = 0; i < sizeof(mystruct->uarr)/sizeof(mystruct->uarr[0]); i++)
for (i = 0; i < ARRAY_SIZE(mystruct->uarr); i++)
if (mystruct->uarr[i] != i)
return FALSE;
return TRUE;
......
......@@ -627,7 +627,7 @@ static void test_CreateDispTypeInfo(void)
OLECHAR *name = func1;
ifdata.pmethdata = methdata;
ifdata.cMembers = sizeof(methdata) / sizeof(methdata[0]);
ifdata.cMembers = ARRAY_SIZE(methdata);
methdata[0].szName = SysAllocString(func1);
methdata[0].ppdata = parms1;
......@@ -1350,7 +1350,7 @@ static LSTATUS myRegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM view)
dwMaxSubkeyLen++;
dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
......@@ -1483,7 +1483,7 @@ static void test_QueryPathOfRegTypeLib(DWORD arch)
if (!do_typelib_reg_key(&uid, 5, 37, arch, base, FALSE)) return;
if (arch == 64 && !do_typelib_reg_key(&uid, 5, 37, 32, wrongW, FALSE)) return;
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
for (i = 0; i < ARRAY_SIZE(td); i++)
{
ret = QueryPathOfRegTypeLib(&uid, td[i].maj, td[i].min, LOCALE_NEUTRAL, &path);
ok(ret == td[i].ret, "QueryPathOfRegTypeLib(%u.%u) returned %08x\n", td[i].maj, td[i].min, ret);
......@@ -2309,7 +2309,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(V_BSTR(&paramdescex.varDefaultValue));
WideCharToMultiByte(CP_ACP, 0, defaultW, -1, nameA, sizeof(nameA), NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, sizeof(nameW)/sizeof(nameW[0]));
MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, ARRAY_SIZE(nameW));
hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
ok(hres == S_OK, "got %08x\n", hres);
......@@ -3041,7 +3041,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 0, "got: %u\n", cnames);
hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
......@@ -3145,7 +3145,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(name);
SysFreeString(helpfile);
hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 3, "got: %u\n", cnames);
ok(!memcmp(names[0], func2W, sizeof(func2W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
......@@ -3375,7 +3375,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(name);
SysFreeString(helpfile);
hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
......@@ -3474,7 +3474,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(name);
SysFreeString(helpfile);
hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
......@@ -4701,7 +4701,7 @@ static void test_dump_typelib(const char *name)
{
WCHAR wszName[MAX_PATH];
ITypeLib *typelib;
int ticount = sizeof(info)/sizeof(info[0]);
int ticount = ARRAY_SIZE(info);
int iface, func;
MultiByteToWideChar(CP_ACP, 0, name, -1, wszName, MAX_PATH);
......@@ -4739,7 +4739,7 @@ static void test_dump_typelib(const char *name)
HRESULT hr;
GUID guid;
MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, sizeof(guidW)/sizeof(guidW[0]));
MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, ARRAY_SIZE(guidW));
IIDFromString(guidW, &guid);
expect_guid(&guid, &typeattr->guid);
......@@ -5002,7 +5002,7 @@ static void test_register_typelib(BOOL system_registration)
}
StringFromGUID2(&attr->guid, uuidW, sizeof(uuidW) / sizeof(uuidW[0]));
StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid);
......@@ -5050,7 +5050,7 @@ static void test_register_typelib(BOOL system_registration)
if((attr->typekind == TKIND_INTERFACE && (attr->wTypeFlags & TYPEFLAG_FOLEAUTOMATION)) ||
attr->typekind == TKIND_DISPATCH)
{
StringFromGUID2(&attr->guid, uuidW, sizeof(uuidW) / sizeof(uuidW[0]));
StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid);
......@@ -6204,7 +6204,7 @@ static void test_stub(void)
WCHAR guidW[40];
REGSAM opposite = side ^ (KEY_WOW64_64KEY | KEY_WOW64_32KEY);
StringFromGUID2(&interfaceguid, guidW, sizeof(guidW)/sizeof(guidW[0]));
StringFromGUID2(&interfaceguid, guidW, ARRAY_SIZE(guidW));
/* Delete the opposite interface key */
lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_READ | opposite, &hkey);
......
......@@ -416,7 +416,7 @@ static void test_marshal_LPSAFEARRAY(void)
/* Test an array of VT_BSTR */
sab[0].lLbound = 3;
sab[0].cElements = sizeof(values) / sizeof(values[0]);
sab[0].cElements = ARRAY_SIZE(values);
lpsa = SafeArrayCreate(VT_BSTR, 1, sab);
expected_bstr_size = 0;
......@@ -463,7 +463,7 @@ static void test_marshal_LPSAFEARRAY(void)
ok(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal, result %p\n", next);
for (i = 0; i < sizeof(values) / sizeof(values[0]); i++)
for (i = 0; i < ARRAY_SIZE(values); i++)
{
BSTR gotvalue = NULL;
......
......@@ -80,7 +80,7 @@ static void test_VarFormatNumber(void)
CHECKPTR(VarFormatNumber);
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (buff[0] != '.' || buff[1])
{
skip("Skipping VarFormatNumber tests as decimal separator is '%s'\n", buff);
......@@ -127,7 +127,7 @@ static const char *szVarFmtFail = "VT %d|0x%04x Format %s: expected 0x%08x, '%s'
#define VARFMT(vt,v,val,fmt,ret,str) do { \
out = NULL; \
V_VT(&in) = (vt); v(&in) = val; \
if (fmt) MultiByteToWideChar(CP_ACP, 0, fmt, -1, buffW, sizeof(buffW)/sizeof(WCHAR)); \
if (fmt) MultiByteToWideChar(CP_ACP, 0, fmt, -1, buffW, ARRAY_SIZE(buffW)); \
hres = pVarFormat(&in,fmt ? buffW : NULL,fd,fw,flags,&out); \
if (SUCCEEDED(hres)) WideCharToMultiByte(CP_ACP, 0, out, -1, buff, sizeof(buff),0,0); \
else buff[0] = '\0'; \
......@@ -224,7 +224,7 @@ static const FMTDATERES VarFormat_namedtime_results[] =
};
#define VNUMFMT(vt,v) \
for (i = 0; i < sizeof(VarFormat_results)/sizeof(FMTRES); i++) \
for (i = 0; i < ARRAY_SIZE(VarFormat_results); i++) \
{ \
VARFMT(vt,v,1,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].one_res); \
VARFMT(vt,v,0,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].zero_res); \
......@@ -256,13 +256,13 @@ static void test_VarFormat(void)
skip("Skipping VarFormat tests for non English language\n");
return;
}
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (buff[0] != '.' || buff[1])
{
skip("Skipping VarFormat tests as decimal separator is '%s'\n", buff);
return;
}
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, buff, sizeof(buff)/sizeof(char));
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, buff, ARRAY_SIZE(buff));
if (buff[0] != '2' || buff[1])
{
skip("Skipping VarFormat tests as decimal places is '%s'\n", buff);
......@@ -296,7 +296,7 @@ static void test_VarFormat(void)
VARFMT(VT_BOOL|VT_BYREF,V_BOOLREF,&bFalse,"True/False",S_OK,"False");
/* Dates */
for (i = 0; i < sizeof(VarFormat_date_results)/sizeof(FMTDATERES); i++)
for (i = 0; i < ARRAY_SIZE(VarFormat_date_results); i++)
{
if (i < 7)
fd = i + 1; /* Test first day */
......@@ -308,14 +308,14 @@ static void test_VarFormat(void)
}
/* Named time formats */
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buff, sizeof(buff)/sizeof(char));
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buff, ARRAY_SIZE(buff));
if (strcmp(buff, "h:mm:ss tt"))
{
skip("Skipping named time tests as time format is '%s'\n", buff);
}
else
{
for (i = 0; i < sizeof(VarFormat_namedtime_results)/sizeof(FMTDATERES); i++)
for (i = 0; i < ARRAY_SIZE(VarFormat_namedtime_results); i++)
{
fd = 0;
VARFMT(VT_DATE,V_DATE,VarFormat_namedtime_results[i].val,
......
......@@ -112,7 +112,7 @@ static BOOL has_locales;
#define CONVERT_STR(func,str,flags) \
SetLastError(0); \
if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,ARRAY_SIZE(buff)); \
hres = func(str ? buff : NULL,in,flags,&out)
#define COPYTEST(val, vt, srcval, dstval, srcref, dstref, fs) do { \
......@@ -2944,7 +2944,7 @@ static void test_VarDateFromDec(void)
#define DFS(str) \
buff[0] = '\0'; out = 0.0; \
if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,ARRAY_SIZE(buff)); \
hres = VarDateFromStr(str ? buff : NULL,lcid,LOCALE_NOUSEROVERRIDE,&out)
#define MKRELDATE(day,mth) st.wMonth = mth; st.wDay = day; \
......@@ -3091,7 +3091,7 @@ static void test_VarDateFromStr(void)
DFS("1.2.3 4 5 6"); EXPECT_DBL(38812.04309027778);
DFS("1 2 3 4.5.6"); EXPECT_DBL(37623.17020833334);
for (i = 0; i < sizeof(BadDateStrings)/sizeof(char*); i++)
for (i = 0; i < ARRAY_SIZE(BadDateStrings); i++)
{
DFS(BadDateStrings[i]); EXPECT_MISMATCH;
}
......@@ -4816,12 +4816,12 @@ static void test_VarBstrCmp(void)
/* These two strings are considered equal even though one is
* NULL-terminated and the other not.
*/
bstr2 = SysAllocStringLen(s1, sizeof(s1) / sizeof(WCHAR));
bstr2 = SysAllocStringLen(s1, ARRAY_SIZE(s1));
VARBSTRCMP(bstr,bstr2,0,VARCMP_EQ);
SysFreeString(bstr2);
/* These two strings are not equal */
bstr2 = SysAllocStringLen(s2, sizeof(s2) / sizeof(WCHAR));
bstr2 = SysAllocStringLen(s2, ARRAY_SIZE(s2));
VARBSTRCMP(bstr,bstr2,0,VARCMP_LT);
SysFreeString(bstr2);
......@@ -5235,8 +5235,7 @@ if (0)
ret = VarBstrCat(str1, str2, &res);
ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret);
ok(res != NULL, "Expected a string\n");
ok(SysStringLen(res) == sizeof(sz1sz2) / sizeof(WCHAR) - 1,
"Unexpected length\n");
ok(SysStringLen(res) == ARRAY_SIZE(sz1sz2) - 1, "Unexpected length\n");
ok(!memcmp(res, sz1sz2, sizeof(sz1sz2)), "Unexpected value\n");
SysFreeString(res);
......@@ -5244,14 +5243,13 @@ if (0)
SysFreeString(str1);
/* Concatenation of two strings with embedded NULLs */
str1 = SysAllocStringLen(s1, sizeof(s1) / sizeof(WCHAR));
str2 = SysAllocStringLen(s2, sizeof(s2) / sizeof(WCHAR));
str1 = SysAllocStringLen(s1, ARRAY_SIZE(s1));
str2 = SysAllocStringLen(s2, ARRAY_SIZE(s2));
ret = VarBstrCat(str1, str2, &res);
ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret);
ok(res != NULL, "Expected a string\n");
ok(SysStringLen(res) == sizeof(s1s2) / sizeof(WCHAR),
"Unexpected length\n");
ok(SysStringLen(res) == ARRAY_SIZE(s1s2), "Unexpected length\n");
ok(!memcmp(res, s1s2, sizeof(s1s2)), "Unexpected value\n");
SysFreeString(res);
......@@ -5893,13 +5891,13 @@ static void test_bstr_cache(void)
/* Fill the bucket with cached entries.
We roll our own, to show that the cache doesn't use
the bstr length field to determine bucket allocation. */
for(i=0; i < sizeof(strs)/sizeof(*strs); i++)
for(i=0; i < ARRAY_SIZE(strs); i++)
{
DWORD_PTR *ptr = CoTaskMemAlloc(64);
ptr[0] = 0;
strs[i] = (BSTR)(ptr + 1);
}
for(i=0; i < sizeof(strs)/sizeof(*strs); i++)
for(i=0; i < ARRAY_SIZE(strs); i++)
SysFreeString(strs[i]);
/* Following allocation will be made from cache */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment