Commit 3851d97e authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

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

parent 85f1a79b
......@@ -62,7 +62,7 @@ static void test_getstring_bad(void)
"Unexpected result : %08x\n", hr);
ok(len == 0xdeadbeef, "got %u\n", len);
len = sizeof(buf)/sizeof(buf[0]);
len = ARRAY_SIZE(buf);
hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotBad, open, buf, &len);
ok(hr == E_FAIL ||
hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */ ||
......@@ -70,8 +70,8 @@ static void test_getstring_bad(void)
"Unexpected result : %08x\n", hr);
if (hr == S_OK)
{
ok(len < sizeof(buf)/sizeof(buf[0]), "got %u\n", len);
ok(!lstrcmpiW(buf + len - sizeof(openwith)/sizeof(openwith[0]), openwith), "wrong data\n");
ok(len < ARRAY_SIZE(buf), "got %u\n", len);
ok(!lstrcmpiW(buf + len - ARRAY_SIZE(openwith), openwith), "wrong data\n");
}
len = 0xdeadbeef;
......@@ -105,7 +105,7 @@ static void test_getstring_bad(void)
hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND) /* Win8 */ ||
hr == S_FALSE, /* Win10 */
"Unexpected result : %08x\n", hr);
ok((hr == S_FALSE && len < sizeof(buf)/sizeof(buf[0])) || len == 0xdeadbeef,
ok((hr == S_FALSE && len < ARRAY_SIZE(buf)) || len == 0xdeadbeef,
"got hr=%08x and len=%u\n", hr, len);
len = 0xdeadbeef;
......
......@@ -362,8 +362,7 @@ static void test_CList(void)
if (hRet == S_OK)
{
/* 1 call for each element, + 1 for OK (use our null element for this) */
ok(streamobj.writecalls == sizeof(SHLWAPI_CLIST_items)/sizeof(SHLWAPI_CLIST),
"wrong call count\n");
ok(streamobj.writecalls == ARRAY_SIZE(SHLWAPI_CLIST_items), "wrong call count\n");
ok(streamobj.readcalls == 0,"called Read() in write\n");
ok(streamobj.seekcalls == 0,"called Seek() in write\n");
}
......@@ -433,8 +432,7 @@ static void test_CList(void)
{
ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
/* 2 calls per item, but only 1 for the terminator */
ok(streamobj.readcalls == sizeof(SHLWAPI_CLIST_items)/sizeof(SHLWAPI_CLIST)*2-1,
"wrong call count\n");
ok(streamobj.readcalls == ARRAY_SIZE(SHLWAPI_CLIST_items) * 2 - 1, "wrong call count\n");
ok(streamobj.writecalls == 0, "called Write() from create\n");
ok(streamobj.seekcalls == 0,"called Seek() from create\n");
......
......@@ -726,12 +726,12 @@ START_TEST(istream)
int i, j, k;
for (i = 0; i != sizeof(stgm_access)/sizeof(stgm_access[0]); i++) {
for (j = 0; j != sizeof(stgm_sharing)/sizeof(stgm_sharing[0]); j ++) {
for (i = 0; i != ARRAY_SIZE(stgm_access); i++) {
for (j = 0; j != ARRAY_SIZE(stgm_sharing); j ++) {
test_SHCreateStreamOnFileA(stgm_access[i], stgm_sharing[j]);
test_SHCreateStreamOnFileW(stgm_access[i], stgm_sharing[j]);
for (k = 0; k != sizeof(stgm_flags)/sizeof(stgm_flags[0]); k++)
for (k = 0; k != ARRAY_SIZE(stgm_flags); k++)
test_SHCreateStreamOnFileEx(stgm_access[i], stgm_sharing[j] | stgm_flags[k]);
}
}
......
......@@ -1862,14 +1862,14 @@ if (0)
/* all combinations documented as invalid succeeded */
flags = FDTF_SHORTTIME | FDTF_LONGTIME;
SetLastError(0xdeadbeef);
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
flags = FDTF_SHORTDATE | FDTF_LONGDATE;
SetLastError(0xdeadbeef);
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
......@@ -1877,7 +1877,7 @@ if (0)
flags = FDTF_SHORTDATE | FDTF_LTRDATE | FDTF_RTLDATE;
SetLastError(0xdeadbeef);
buff[0] = 0; /* NT4 doesn't clear the buffer on failure */
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ok(GetLastError() == 0xdeadbeef,
......@@ -1885,67 +1885,67 @@ if (0)
/* now check returned strings */
flags = FDTF_SHORTTIME;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
SetLastError(0xdeadbeef);
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
flags = FDTF_LONGTIME;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
/* both time flags */
flags = FDTF_LONGTIME | FDTF_SHORTTIME;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal string\n");
flags = FDTF_SHORTDATE;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
flags = FDTF_LONGDATE;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
/* both date flags */
flags = FDTF_LONGDATE | FDTF_SHORTDATE;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
/* various combinations of date/time flags */
flags = FDTF_LONGDATE | FDTF_SHORTTIME;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, sizeof(buff3)/sizeof(WCHAR));
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, ARRAY_SIZE(buff3));
ok(ret == lstrlenW(buff3)+1, "expected %d, got %d\n", lstrlenW(buff3)+1, ret);
ok(lstrcmpW(buff3, buff + lstrlenW(buff) - lstrlenW(buff3)) == 0,
"expected (%s), got (%s) for time part\n",
wine_dbgstr_w(buff3), wine_dbgstr_w(buff + lstrlenW(buff) - lstrlenW(buff3)));
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
p1 = buff;
p2 = buff2;
......@@ -1963,15 +1963,15 @@ if (0)
wine_dbgstr_w(buff2), wine_dbgstr_w(buff));
flags = FDTF_LONGDATE | FDTF_LONGTIME;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, sizeof(buff3)/sizeof(WCHAR));
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, ARRAY_SIZE(buff3));
ok(ret == lstrlenW(buff3)+1, "expected %d, got %d\n", lstrlenW(buff3)+1, ret);
ok(lstrcmpW(buff3, buff + lstrlenW(buff) - lstrlenW(buff3)) == 0,
"expected (%s), got (%s) for time part\n",
wine_dbgstr_w(buff3), wine_dbgstr_w(buff + lstrlenW(buff) - lstrlenW(buff3)));
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
p1 = buff;
p2 = buff2;
......@@ -1989,25 +1989,25 @@ if (0)
wine_dbgstr_w(buff2), wine_dbgstr_w(buff));
flags = FDTF_SHORTDATE | FDTF_SHORTTIME;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
lstrcatW(buff2, spaceW);
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, sizeof(buff3)/sizeof(WCHAR));
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, ARRAY_SIZE(buff3));
ok(ret == lstrlenW(buff3)+1, "expected %d, got %d\n", lstrlenW(buff3)+1, ret);
lstrcatW(buff2, buff3);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
flags = FDTF_SHORTDATE | FDTF_LONGTIME;
ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
lstrcatW(buff2, spaceW);
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, sizeof(buff3)/sizeof(WCHAR));
ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, ARRAY_SIZE(buff3));
ok(ret == lstrlenW(buff3)+1, "expected %d, got %d\n", lstrlenW(buff3)+1, ret);
lstrcatW(buff2, buff3);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
......@@ -2068,7 +2068,7 @@ static void test_SHGetObjectCompatFlags(void)
{
int j;
for (j = 0; j < sizeof(values)/sizeof(struct compat_value); j++)
for (j = 0; j < ARRAY_SIZE(values); j++)
if (lstrcmpA(values[j].nameA, valueA) == 0)
{
expected |= values[j].value;
......
......@@ -283,7 +283,7 @@ static void test_PathCreateFromUrl(void)
ok(len == 0xdeca, "got %x expected 0xdeca\n", len);
/* Test the decoding itself */
for(i = 0; i < sizeof(TEST_PATHFROMURL) / sizeof(TEST_PATHFROMURL[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_PATHFROMURL); i++) {
len = INTERNET_MAX_URL_LENGTH;
ret = pPathCreateFromUrlA(TEST_PATHFROMURL[i].url, ret_path, &len, 0);
todo_wine_if (TEST_PATHFROMURL[i].todo & 0x1)
......@@ -350,7 +350,7 @@ static void test_PathIsUrl(void)
size_t i;
BOOL ret;
for(i = 0; i < sizeof(TEST_PATH_IS_URL)/sizeof(TEST_PATH_IS_URL[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_PATH_IS_URL); i++) {
ret = PathIsURLA(TEST_PATH_IS_URL[i].path);
ok(ret == TEST_PATH_IS_URL[i].expect,
"returned %d from path %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
......@@ -1403,7 +1403,7 @@ static void test_PathCommonPrefixA(void)
static void test_PathUnquoteSpaces(void)
{
int i;
for(i = 0; i < sizeof(TEST_PATH_UNQUOTE_SPACES) / sizeof(TEST_PATH_UNQUOTE_SPACES[0]); i++)
for (i = 0; i < ARRAY_SIZE(TEST_PATH_UNQUOTE_SPACES); i++)
{
char *path = strdupA(TEST_PATH_UNQUOTE_SPACES[i].path);
WCHAR *pathW = GetWideString(TEST_PATH_UNQUOTE_SPACES[i].path);
......@@ -1484,10 +1484,10 @@ static void test_PathUnExpandEnvStrings(void)
ret = pPathUnExpandEnvStringsA(envvarA, buff, sizeof(buff));
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
ret = GetEnvironmentVariableW(computernameW, envvarW, sizeof(envvarW)/sizeof(WCHAR));
ret = GetEnvironmentVariableW(computernameW, envvarW, ARRAY_SIZE(envvarW));
ok(ret, "got %d\n", ret);
SetLastError(0xdeadbeef);
ret = pPathUnExpandEnvStringsW(envvarW, buffW, sizeof(buffW)/sizeof(WCHAR));
ret = pPathUnExpandEnvStringsW(envvarW, buffW, ARRAY_SIZE(buffW));
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
/* something that can't be represented with env var */
......@@ -1559,7 +1559,7 @@ static void test_PathUnExpandEnvStrings(void)
lstrcpyW(pathW, nonpathW);
buffW[0] = 'x'; buffW[1] = 0;
SetLastError(0xdeadbeef);
ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(buffW)/sizeof(WCHAR));
ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(buffW));
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
......@@ -1580,13 +1580,13 @@ static void test_PathUnExpandEnvStrings(void)
/* buffer size is enough to hold variable name only */
buffW[0] = 'x'; buffW[1] = 0;
SetLastError(0xdeadbeef);
ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(sysrootW)/sizeof(WCHAR));
ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(sysrootW));
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
/* enough size */
buffW[0] = 0;
ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(buffW)/sizeof(WCHAR));
ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(buffW));
ok(ret, "got %d\n", ret);
ok(!memcmp(buffW, sysrootW, sizeof(sysrootW) - sizeof(WCHAR)), "wrong return string %s\n", wine_dbgstr_w(buffW));
......@@ -1626,7 +1626,7 @@ static void test_PathIsRelativeA(void)
return;
}
num = sizeof(test_path_is_relative) / sizeof(test_path_is_relative[0]);
num = ARRAY_SIZE(test_path_is_relative);
for (i = 0; i < num; i++) {
ret = pPathIsRelativeA(test_path_is_relative[i].path);
ok(ret == test_path_is_relative[i].expect,
......@@ -1646,7 +1646,7 @@ static void test_PathIsRelativeW(void)
return;
}
num = sizeof(test_path_is_relative) / sizeof(test_path_is_relative[0]);
num = ARRAY_SIZE(test_path_is_relative);
for (i = 0; i < num; i++) {
path = GetWideString(test_path_is_relative[i].path);
......
......@@ -412,7 +412,7 @@ static void test_StrCpyW(void)
while(result->value)
{
MultiByteToWideChar(CP_ACP,0,result->byte_size_64,-1,szSrc,sizeof(szSrc)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, result->byte_size_64, -1, szSrc, ARRAY_SIZE(szSrc));
lpRes = StrCpyW(szBuff, szSrc);
ok(!StrCmpW(szSrc, szBuff) && lpRes == szBuff, "Copied string %s wrong\n", result->byte_size_64);
......@@ -476,7 +476,7 @@ static void test_StrToIntW(void)
while (result->string)
{
MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
return_val = StrToIntW(szBuff);
ok(return_val == result->str_to_int, "converted '%s' wrong (%d)\n",
result->string, return_val);
......@@ -526,7 +526,7 @@ static void test_StrToIntExW(void)
while (result->string)
{
return_val = -1;
MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
bRet = StrToIntExW(szBuff, 0, &return_val);
ok(!bRet || return_val != -1, "No result returned from '%s'\n",
result->string);
......@@ -540,7 +540,7 @@ static void test_StrToIntExW(void)
while (result->string)
{
return_val = -1;
MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
bRet = StrToIntExW(szBuff, STIF_SUPPORT_HEX, &return_val);
ok(!bRet || return_val != -1, "No result returned from '%s'\n",
result->string);
......@@ -605,7 +605,7 @@ static void test_StrToInt64ExW(void)
while (result->string)
{
return_val = -1;
MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
bRet = pStrToInt64ExW(szBuff, 0, &return_val);
ok(!bRet || return_val != -1, "No result returned from '%s'\n",
result->string);
......@@ -619,7 +619,7 @@ static void test_StrToInt64ExW(void)
while (result->string)
{
return_val = -1;
MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
bRet = pStrToInt64ExW(szBuff, STIF_SUPPORT_HEX, &return_val);
ok(!bRet || return_val != -1, "No result returned from '%s'\n",
result->string);
......@@ -865,7 +865,7 @@ static void test_StrCpyNXA(void)
}
memset(dest, '\n', sizeof(dest));
lpszRes = pStrCpyNXA(dest, lpSrc, sizeof(dest)/sizeof(dest[0]));
lpszRes = pStrCpyNXA(dest, lpSrc, ARRAY_SIZE(dest));
ok(lpszRes == dest + 5 && !memcmp(dest, "hello\0\n\n", sizeof(dest)),
"StrCpyNXA: expected %p, \"hello\\0\\n\\n\", got %p, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
dest + 5, lpszRes, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
......@@ -886,7 +886,7 @@ static void test_StrCpyNXW(void)
}
memcpy(dest, lpInit, sizeof(lpInit));
lpszRes = pStrCpyNXW(dest, lpSrc, sizeof(dest)/sizeof(dest[0]));
lpszRes = pStrCpyNXW(dest, lpSrc, ARRAY_SIZE(dest));
ok(lpszRes == dest + 5 && !memcmp(dest, lpRes, sizeof(dest)),
"StrCpyNXW: expected %p, \"hello\\0\\n\\n\", got %p, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
dest + 5, lpszRes, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
......@@ -949,7 +949,7 @@ static void test_SHAnsiToAnsi(void)
}
memset(dest, '\n', sizeof(dest));
dwRet = pSHAnsiToAnsi("hello", dest, sizeof(dest)/sizeof(dest[0]));
dwRet = pSHAnsiToAnsi("hello", dest, ARRAY_SIZE(dest));
ok(dwRet == 6 && !memcmp(dest, "hello\0\n\n", sizeof(dest)),
"SHAnsiToAnsi: expected 6, \"hello\\0\\n\\n\", got %d, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
dwRet, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
......@@ -976,7 +976,7 @@ static void test_SHUnicodeToUnicode(void)
}
memcpy(dest, lpInit, sizeof(lpInit));
dwRet = pSHUnicodeToUnicode(lpSrc, dest, sizeof(dest)/sizeof(dest[0]));
dwRet = pSHUnicodeToUnicode(lpSrc, dest, ARRAY_SIZE(dest));
ok(dwRet == 6 && !memcmp(dest, lpRes, sizeof(dest)),
"SHUnicodeToUnicode: expected 6, \"hello\\0\\n\\n\", got %d, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
dwRet, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
......@@ -1158,7 +1158,7 @@ static void test_StrStrA(void)
ret = StrStrA("", "");
ok(!ret, "Expected StrStrA to return NULL, got %p\n", ret);
for (i = 0; i < sizeof(StrStrA_cases)/sizeof(StrStrA_cases[0]); i++)
for (i = 0; i < ARRAY_SIZE(StrStrA_cases); i++)
{
ret = StrStrA(deadbeefA, StrStrA_cases[i].search);
ok(ret == StrStrA_cases[i].expect,
......@@ -1212,7 +1212,7 @@ static void test_StrStrW(void)
ret = StrStrW(emptyW, emptyW);
ok(!ret, "Expected StrStrW to return NULL, got %p\n", ret);
for (i = 0; i < sizeof(StrStrW_cases)/sizeof(StrStrW_cases[0]); i++)
for (i = 0; i < ARRAY_SIZE(StrStrW_cases); i++)
{
ret = StrStrW(deadbeefW, StrStrW_cases[i].search);
ok(ret == StrStrW_cases[i].expect,
......@@ -1260,7 +1260,7 @@ static void test_StrStrIA(void)
ret = StrStrIA("", "");
ok(!ret, "Expected StrStrIA to return NULL, got %p\n", ret);
for (i = 0; i < sizeof(StrStrIA_cases)/sizeof(StrStrIA_cases[0]); i++)
for (i = 0; i < ARRAY_SIZE(StrStrIA_cases); i++)
{
ret = StrStrIA(deadbeefA, StrStrIA_cases[i].search);
ok(ret == StrStrIA_cases[i].expect,
......@@ -1316,7 +1316,7 @@ static void test_StrStrIW(void)
ret = StrStrIW(emptyW, emptyW);
ok(!ret, "Expected StrStrIW to return NULL, got %p\n", ret);
for (i = 0; i < sizeof(StrStrIW_cases)/sizeof(StrStrIW_cases[0]); i++)
for (i = 0; i < ARRAY_SIZE(StrStrIW_cases); i++)
{
ret = StrStrIW(deadbeefW, StrStrIW_cases[i].search);
ok(ret == StrStrIW_cases[i].expect,
......@@ -1343,13 +1343,13 @@ static void test_StrStrNW(void)
const WCHAR *expect;
} StrStrNW_cases[] =
{
{emptyW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
{deadW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW},
{dead_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
{adbeW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 2},
{adbe_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
{beefW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 4},
{beef_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
{emptyW, ARRAY_SIZE(deadbeefW), NULL},
{deadW, ARRAY_SIZE(deadbeefW), deadbeefW},
{dead_lowerW, ARRAY_SIZE(deadbeefW), NULL},
{adbeW, ARRAY_SIZE(deadbeefW), deadbeefW + 2},
{adbe_lowerW, ARRAY_SIZE(deadbeefW), NULL},
{beefW, ARRAY_SIZE(deadbeefW), deadbeefW + 4},
{beef_lowerW, ARRAY_SIZE(deadbeefW), NULL},
{beefW, 0, NULL},
{beefW, 1, NULL},
{beefW, 2, NULL},
......@@ -1386,7 +1386,7 @@ static void test_StrStrNW(void)
ret = pStrStrNW(emptyW, emptyW, 10);
ok(!ret, "Expected StrStrNW to return NULL, got %p\n", ret);
for (i = 0; i < sizeof(StrStrNW_cases)/sizeof(StrStrNW_cases[0]); i++)
for (i = 0; i < ARRAY_SIZE(StrStrNW_cases); i++)
{
ret = pStrStrNW(deadbeefW, StrStrNW_cases[i].search, StrStrNW_cases[i].count);
ok(ret == StrStrNW_cases[i].expect,
......@@ -1426,14 +1426,14 @@ static void test_StrStrNIW(void)
const WCHAR *expect;
} StrStrNIW_cases[] =
{
{emptyW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
{deadW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW},
{dead_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW},
{adbeW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 2},
{adbe_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 2},
{beefW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 4},
{beef_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 4},
{cafeW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
{emptyW, ARRAY_SIZE(deadbeefW), NULL},
{deadW, ARRAY_SIZE(deadbeefW), deadbeefW},
{dead_lowerW, ARRAY_SIZE(deadbeefW), deadbeefW},
{adbeW, ARRAY_SIZE(deadbeefW), deadbeefW + 2},
{adbe_lowerW, ARRAY_SIZE(deadbeefW), deadbeefW + 2},
{beefW, ARRAY_SIZE(deadbeefW), deadbeefW + 4},
{beef_lowerW, ARRAY_SIZE(deadbeefW), deadbeefW + 4},
{cafeW, ARRAY_SIZE(deadbeefW), NULL},
{beefW, 0, NULL},
{beefW, 1, NULL},
{beefW, 2, NULL},
......@@ -1480,7 +1480,7 @@ static void test_StrStrNIW(void)
ret = pStrStrNIW(emptyW, emptyW, 10);
ok(!ret, "Expected StrStrNIW to return NULL, got %p\n", ret);
for (i = 0; i < sizeof(StrStrNIW_cases)/sizeof(StrStrNIW_cases[0]); i++)
for (i = 0; i < ARRAY_SIZE(StrStrNIW_cases); i++)
{
ret = pStrStrNIW(deadbeefW, StrStrNIW_cases[i].search, StrStrNIW_cases[i].count);
ok(ret == StrStrNIW_cases[i].expect,
......
......@@ -539,7 +539,7 @@ static void test_UrlApplyScheme(void)
return;
}
for(i = 0; i < sizeof(TEST_APPLY)/sizeof(TEST_APPLY[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_APPLY); i++) {
len = TEST_APPLY_MAX_LENGTH;
lstrcpyA(newurl, untouchedA);
res = pUrlApplySchemeA(TEST_APPLY[i].url, newurl, &len, TEST_APPLY[i].flags);
......@@ -916,7 +916,7 @@ static void test_UrlEscapeA(void)
"got %d, expected %d\n", size, 1);
ok(empty_string[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string[0]);
for(i=0; i<sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_ESCAPE); i++) {
CHAR ret_url[INTERNET_MAX_URL_LENGTH];
size = INTERNET_MAX_URL_LENGTH;
......@@ -983,7 +983,7 @@ static void test_UrlEscapeW(void)
/* Check actual escaping */
size = sizeof(overwrite)/sizeof(WCHAR);
size = ARRAY_SIZE(overwrite);
ret = pUrlEscapeW(overwrite, overwrite, &size, URL_ESCAPE_SPACES_ONLY);
ok(ret == S_OK, "got %x, expected S_OK\n", ret);
ok(size == 9, "got %d, expected 9\n", size);
......@@ -997,12 +997,12 @@ static void test_UrlEscapeW(void)
ok(wc == 127, "String has changed, wc = %d\n", wc);
/* non-ASCII range */
size = sizeof(ret_urlW)/sizeof(WCHAR);
size = ARRAY_SIZE(ret_urlW);
ret = pUrlEscapeW(naW, ret_urlW, &size, 0);
ok(ret == S_OK, "got %x, expected S_OK\n", ret);
ok(!lstrcmpW(naescapedW, ret_urlW), "got %s, expected %s\n", wine_dbgstr_w(ret_urlW), wine_dbgstr_w(naescapedW));
for (i = 0; i < sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_ESCAPE); i++) {
WCHAR *urlW, *expected_urlW;
......@@ -1018,7 +1018,7 @@ static void test_UrlEscapeW(void)
FreeWideString(expected_urlW);
}
for(i=0; i<sizeof(TEST_ESCAPEW)/sizeof(TEST_ESCAPEW[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_ESCAPEW); i++) {
WCHAR ret_url[INTERNET_MAX_URL_LENGTH];
size = INTERNET_MAX_URL_LENGTH;
......@@ -1113,7 +1113,7 @@ static void test_UrlCanonicalizeA(void)
test_url_canonicalize(-1, "", 0, S_OK, S_FALSE /* Vista/win2k8 */, "", FALSE);
/* test url-modification */
for(i=0; i<sizeof(TEST_CANONICALIZE)/sizeof(TEST_CANONICALIZE[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_CANONICALIZE); i++) {
test_url_canonicalize(i, TEST_CANONICALIZE[i].url, TEST_CANONICALIZE[i].flags,
TEST_CANONICALIZE[i].expectret, TEST_CANONICALIZE[i].expectret, TEST_CANONICALIZE[i].expecturl,
TEST_CANONICALIZE[i].todo);
......@@ -1185,7 +1185,7 @@ static void test_UrlCanonicalizeW(void)
BOOL choped;
int pos;
MultiByteToWideChar(CP_ACP, 0, "http://www.winehq.org/X", -1, szUrl, sizeof(szUrl)/sizeof(szUrl[0]));
MultiByteToWideChar(CP_ACP, 0, "http://www.winehq.org/X", -1, szUrl, ARRAY_SIZE(szUrl));
pos = lstrlenW(szUrl) - 1;
szUrl[pos] = i;
urllen = INTERNET_MAX_URL_LENGTH;
......@@ -1267,7 +1267,7 @@ static void test_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFla
static void test_UrlCombine(void)
{
unsigned int i;
for(i=0; i<sizeof(TEST_COMBINE)/sizeof(TEST_COMBINE[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_COMBINE); i++) {
test_url_combine(TEST_COMBINE[i].url1, TEST_COMBINE[i].url2, TEST_COMBINE[i].flags,
TEST_COMBINE[i].expectret, TEST_COMBINE[i].expecturl);
}
......@@ -1288,7 +1288,7 @@ static void test_UrlCreateFromPath(void)
return;
}
for(i = 0; i < sizeof(TEST_URLFROMPATH) / sizeof(TEST_URLFROMPATH[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_URLFROMPATH); i++) {
len = INTERNET_MAX_URL_LENGTH;
ret = pUrlCreateFromPathA(TEST_URLFROMPATH[i].path, ret_url, &len, 0);
ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path %s\n", ret, TEST_URLFROMPATH[i].path);
......@@ -1342,8 +1342,8 @@ static void test_UrlIs(void)
test_UrlIs_null(URLIS_OPAQUE);
test_UrlIs_null(URLIS_URL);
for(i = 0; i < sizeof(TEST_PATH_IS_URL) / sizeof(TEST_PATH_IS_URL[0]); i++) {
MultiByteToWideChar(CP_ACP, 0, TEST_PATH_IS_URL[i].path, -1, wurl, sizeof(wurl)/sizeof(*wurl));
for (i = 0; i < ARRAY_SIZE(TEST_PATH_IS_URL); i++) {
MultiByteToWideChar(CP_ACP, 0, TEST_PATH_IS_URL[i].path, -1, wurl, ARRAY_SIZE(wurl));
ret = pUrlIsA( TEST_PATH_IS_URL[i].path, URLIS_URL );
ok( ret == TEST_PATH_IS_URL[i].expect,
......@@ -1357,8 +1357,8 @@ static void test_UrlIs(void)
TEST_PATH_IS_URL[i].path, TEST_PATH_IS_URL[i].expect );
}
}
for(i = 0; i < sizeof(TEST_URLIS_ATTRIBS) / sizeof(TEST_URLIS_ATTRIBS[0]); i++) {
MultiByteToWideChar(CP_ACP, 0, TEST_URLIS_ATTRIBS[i].url, -1, wurl, sizeof(wurl)/sizeof(*wurl));
for (i = 0; i < ARRAY_SIZE(TEST_URLIS_ATTRIBS); i++) {
MultiByteToWideChar(CP_ACP, 0, TEST_URLIS_ATTRIBS[i].url, -1, wurl, ARRAY_SIZE(wurl));
ret = pUrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_OPAQUE);
ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque,
......@@ -1403,7 +1403,7 @@ static void test_UrlUnescape(void)
win_skip("UrlUnescapeA not found\n");
return;
}
for(i=0; i<sizeof(TEST_URL_UNESCAPE)/sizeof(TEST_URL_UNESCAPE[0]); i++) {
for (i = 0; i < ARRAY_SIZE(TEST_URL_UNESCAPE); i++) {
dwEscaped=INTERNET_MAX_URL_LENGTH;
res = pUrlUnescapeA(TEST_URL_UNESCAPE[i].url, szReturnUrl, &dwEscaped, 0);
ok(res == S_OK,
......@@ -1494,7 +1494,7 @@ static void test_ParseURL(void)
PARSEDURLW parsedw;
HRESULT hres;
for(test = parse_url_tests; test < parse_url_tests + sizeof(parse_url_tests)/sizeof(*parse_url_tests); test++) {
for (test = parse_url_tests; test < parse_url_tests + ARRAY_SIZE(parse_url_tests); test++) {
memset(&parseda, 0xd0, sizeof(parseda));
parseda.cbSize = sizeof(parseda);
hres = pParseURLA(test->url, &parseda);
......@@ -1516,7 +1516,7 @@ static void test_ParseURL(void)
ok(parseda.nScheme == 0xd0d0d0d0, "nScheme = %d\n", parseda.nScheme);
}
MultiByteToWideChar(CP_ACP, 0, test->url, -1, url, sizeof(url)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, test->url, -1, url, ARRAY_SIZE(url));
memset(&parsedw, 0xd0, sizeof(parsedw));
parsedw.cbSize = sizeof(parsedw);
......@@ -1595,23 +1595,23 @@ static void test_HashData(void)
"Expected HashData to return E_INVALIDARG, got 0x%08x\n", res);
/* Test passing valid pointers with sizes of zero. */
for (i = 0; i < sizeof(input)/sizeof(BYTE); i++)
for (i = 0; i < ARRAY_SIZE(input); i++)
input[i] = 0x00;
for (i = 0; i < sizeof(output)/sizeof(BYTE); i++)
for (i = 0; i < ARRAY_SIZE(output); i++)
output[i] = 0xFF;
res = pHashData(input, 0, output, 0);
ok(res == S_OK, "Expected HashData to return S_OK, got 0x%08x\n", res);
/* The buffers should be unchanged. */
for (i = 0; i < sizeof(input)/sizeof(BYTE); i++)
for (i = 0; i < ARRAY_SIZE(input); i++)
{
ok(input[i] == 0x00, "Expected the input buffer to be unchanged\n");
if(input[i] != 0x00) break;
}
for (i = 0; i < sizeof(output)/sizeof(BYTE); i++)
for (i = 0; i < ARRAY_SIZE(output); i++)
{
ok(output[i] == 0xFF, "Expected the output buffer to be unchanged\n");
if(output[i] != 0xFF) break;
......
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