https://git.reactos.org/?p=reactos.git;a=commitdiff;h=952bc47ba001c644f9524…
commit 952bc47ba001c644f95240853ce8a4ef991b3fb3
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Mon Feb 4 13:01:30 2019 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Mon Feb 4 13:01:30 2019 +0100
[SHLWAPI_WINETEST] Sync with Wine Staging 4.0. CORE-15682
---
modules/rostests/winetests/shlwapi/assoc.c | 8 +--
modules/rostests/winetests/shlwapi/clist.c | 6 +--
modules/rostests/winetests/shlwapi/istream.c | 80 ++++++++++++++++++++++++++--
modules/rostests/winetests/shlwapi/ordinal.c | 68 +++++++++++------------
modules/rostests/winetests/shlwapi/path.c | 22 ++++----
modules/rostests/winetests/shlwapi/string.c | 64 +++++++++++-----------
modules/rostests/winetests/shlwapi/url.c | 42 +++++++--------
7 files changed, 181 insertions(+), 109 deletions(-)
diff --git a/modules/rostests/winetests/shlwapi/assoc.c
b/modules/rostests/winetests/shlwapi/assoc.c
index 080e352a59..c4234de047 100644
--- a/modules/rostests/winetests/shlwapi/assoc.c
+++ b/modules/rostests/winetests/shlwapi/assoc.c
@@ -63,7 +63,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
*/ ||
@@ -71,8 +71,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;
@@ -106,7 +106,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;
diff --git a/modules/rostests/winetests/shlwapi/clist.c
b/modules/rostests/winetests/shlwapi/clist.c
index 309b3335ec..b908235271 100644
--- a/modules/rostests/winetests/shlwapi/clist.c
+++ b/modules/rostests/winetests/shlwapi/clist.c
@@ -363,8 +363,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");
}
@@ -430,8 +429,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");
diff --git a/modules/rostests/winetests/shlwapi/istream.c
b/modules/rostests/winetests/shlwapi/istream.c
index 926f2f8157..560a822e2c 100644
--- a/modules/rostests/winetests/shlwapi/istream.c
+++ b/modules/rostests/winetests/shlwapi/istream.c
@@ -191,6 +191,7 @@ static void test_stream_read_write(IStream *stream, DWORD mode)
HRESULT ret;
unsigned char buf[16];
DWORD written, count;
+ STATSTG statstg;
/* IStream_Read/Write from the COBJMACROS is undefined by shlwapi.h */
@@ -245,6 +246,38 @@ static void test_stream_read_write(IStream *stream, DWORD mode)
ok(count == written, "expected %u, got %u\n", written, count);
if (count)
ok(buf[0] == 0x5e && buf[1] == 0xa7, "expected 5ea7, got
%02x%02x\n", buf[0], buf[1]);
+
+ memset(&statstg, 0xff, sizeof(statstg));
+ ret = IStream_Stat(stream, &statstg, 0);
+ ok(ret == S_OK, "Stat failed, hr %#x.\n", ret);
+ ok(statstg.pwcsName != NULL, "Unexpected name %s.\n",
wine_dbgstr_w(statstg.pwcsName));
+ CoTaskMemFree(statstg.pwcsName);
+
+ memset(&statstg, 0xff, sizeof(statstg));
+ ret = IStream_Stat(stream, &statstg, STATFLAG_NONAME);
+ ok(ret == S_OK, "Stat failed, hr %#x.\n", ret);
+ ok(statstg.pwcsName == NULL, "Unexpected name %s.\n",
wine_dbgstr_w(statstg.pwcsName));
+}
+
+static void test_stream_qi(IStream *stream)
+{
+ IUnknown *unk;
+ HRESULT hr;
+
+ hr = IStream_QueryInterface(stream, &IID_IStream, (void **)&unk);
+ ok(SUCCEEDED(hr), "Failed to get IStream interface, hr %#x.\n", hr);
+ IUnknown_Release(unk);
+
+ unk = NULL;
+ hr = IStream_QueryInterface(stream, &IID_ISequentialStream, (void **)&unk);
+todo_wine
+ ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* XP */, "Failed to get
ISequentialStream interface, hr %#x.\n", hr);
+ if (unk)
+ IUnknown_Release(unk);
+
+ hr = IStream_QueryInterface(stream, &IID_IUnknown, (void **)&unk);
+ ok(SUCCEEDED(hr), "Failed to get IUnknown interface, hr %#x.\n", hr);
+ IUnknown_Release(unk);
}
static void test_SHCreateStreamOnFileA(DWORD mode, DWORD stgm)
@@ -310,6 +343,7 @@ if (0) /* This test crashes on WinXP SP2 */
ok(stream != NULL, "SHCreateStreamOnFileA: expected a valid IStream object, got
NULL\n");
if (stream) {
+ test_stream_qi(stream);
test_IStream_invalid_operations(stream, mode);
refcount = IStream_Release(stream);
@@ -422,6 +456,7 @@ static void test_SHCreateStreamOnFileW(DWORD mode, DWORD stgm)
ok(stream != NULL, "SHCreateStreamOnFileW: expected a valid IStream object, got
NULL\n");
if (stream) {
+ test_stream_qi(stream);
test_IStream_invalid_operations(stream, mode);
refcount = IStream_Release(stream);
@@ -551,6 +586,7 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
ok(stream != NULL, "SHCreateStreamOnFileEx: expected a valid IStream object, got
NULL\n");
if (stream) {
+ test_stream_qi(stream);
test_IStream_invalid_operations(stream, mode);
refcount = IStream_Release(stream);
@@ -697,6 +733,43 @@ static void test_SHCreateStreamOnFileEx_CopyTo(void)
DeleteFileW( dstFileName );
}
+static void test_SHCreateMemStream(void)
+{
+ static const BYTE initial[10];
+ IStream *stream, *stream2;
+ IUnknown *unk;
+ char buff[10];
+ HRESULT hr;
+
+ stream = SHCreateMemStream(initial, 0);
+ ok(stream != NULL, "Failed to create a stream.\n");
+ IStream_Release(stream);
+
+ stream = SHCreateMemStream(NULL, 10);
+ ok(stream != NULL, "Failed to create a stream.\n");
+ IStream_Release(stream);
+
+ stream = SHCreateMemStream(NULL, 0);
+ ok(stream != NULL, "Failed to create a stream.\n");
+
+ hr = IStream_QueryInterface(stream, &IID_ISequentialStream, (void **)&unk);
+todo_wine
+ ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* WinXP */, "Failed to QI, hr
%#x.\n", hr);
+ if (unk)
+ IUnknown_Release(unk);
+
+ hr = IStream_Read(stream, buff, sizeof(buff), NULL);
+todo_wine
+ ok(hr == S_FALSE || broken(hr == S_OK) /* WinXP */, "Unexpected hr %#x.\n",
hr);
+
+ hr = IStream_Clone(stream, &stream2);
+todo_wine
+ ok(hr == S_OK || broken(hr == E_NOTIMPL) /* < Win8 */, "Failed to clone a
stream, hr %#x.\n", hr);
+ if (hr == S_OK)
+ IStream_Release(stream2);
+
+ IStream_Release(stream);
+}
START_TEST(istream)
{
@@ -726,15 +799,16 @@ 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]);
}
}
test_SHCreateStreamOnFileEx_CopyTo();
+ test_SHCreateMemStream();
}
diff --git a/modules/rostests/winetests/shlwapi/ordinal.c
b/modules/rostests/winetests/shlwapi/ordinal.c
index 8d42608130..cd9231351e 100644
--- a/modules/rostests/winetests/shlwapi/ordinal.c
+++ b/modules/rostests/winetests/shlwapi/ordinal.c
@@ -1861,14 +1861,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());
@@ -1876,7 +1876,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,
@@ -1884,67 +1884,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;
@@ -1962,15 +1962,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;
@@ -1988,25 +1988,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");
@@ -2067,7 +2067,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;
@@ -2731,8 +2731,8 @@ static void test_SHGetIniString(void)
if(0){
/* these crash on Windows */
pSHGetIniStringW(NULL, NULL, NULL, 0, NULL);
- pSHGetIniStringW(NULL, AKeyW, out, sizeof(out), pathW);
- pSHGetIniStringW(TestAppW, AKeyW, NULL, sizeof(out), pathW);
+ pSHGetIniStringW(NULL, AKeyW, out, ARRAY_SIZE(out), pathW);
+ pSHGetIniStringW(TestAppW, AKeyW, NULL, ARRAY_SIZE(out), pathW);
}
ret = pSHGetIniStringW(TestAppW, AKeyW, out, 0, pathW);
@@ -2741,21 +2741,21 @@ static void test_SHGetIniString(void)
/* valid arguments */
out[0] = 0;
SetLastError(0xdeadbeef);
- ret = pSHGetIniStringW(TestAppW, NULL, out, sizeof(out), pathW);
+ ret = pSHGetIniStringW(TestAppW, NULL, out, ARRAY_SIZE(out), pathW);
ok(ret == 4, "SHGetIniStringW should have given 4, instead: %d\n", ret);
ok(!lstrcmpW(out, AKeyW), "Expected %s, got: %s, %d\n",
wine_dbgstr_w(AKeyW), wine_dbgstr_w(out), GetLastError());
- ret = pSHGetIniStringW(TestAppW, AKeyW, out, sizeof(out), pathW);
+ ret = pSHGetIniStringW(TestAppW, AKeyW, out, ARRAY_SIZE(out), pathW);
ok(ret == 1, "SHGetIniStringW should have given 1, instead: %d\n", ret);
ok(!strcmp_wa(out, "1"), "Expected L\"1\", got: %s\n",
wine_dbgstr_w(out));
- ret = pSHGetIniStringW(TestAppW, AnotherKeyW, out, sizeof(out), pathW);
+ ret = pSHGetIniStringW(TestAppW, AnotherKeyW, out, ARRAY_SIZE(out), pathW);
ok(ret == 4, "SHGetIniStringW should have given 4, instead: %d\n", ret);
ok(!strcmp_wa(out, "asdf"), "Expected L\"asdf\", got:
%s\n", wine_dbgstr_w(out));
out[0] = 1;
- ret = pSHGetIniStringW(TestAppW, JunkKeyW, out, sizeof(out), pathW);
+ ret = pSHGetIniStringW(TestAppW, JunkKeyW, out, ARRAY_SIZE(out), pathW);
ok(ret == 0, "SHGetIniStringW should have given 0, instead: %d\n", ret);
ok(*out == 0, "Expected L\"\", got: %s\n", wine_dbgstr_w(out));
diff --git a/modules/rostests/winetests/shlwapi/path.c
b/modules/rostests/winetests/shlwapi/path.c
index 91c66b7ef3..4a6fbd91f6 100644
--- a/modules/rostests/winetests/shlwapi/path.c
+++ b/modules/rostests/winetests/shlwapi/path.c
@@ -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));
@@ -1595,7 +1595,7 @@ static void test_PathUnExpandEnvStrings(void)
buffW[0] = 0;
lstrcpyW(pathW, sysdrvW);
lstrcatW(pathW, sysdrvW);
- ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(buff)/sizeof(WCHAR));
+ ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(buffW));
ok(ret, "got %d\n", ret);
/* expected string */
lstrcpyW(pathW, sysdriveW);
@@ -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);
diff --git a/modules/rostests/winetests/shlwapi/string.c
b/modules/rostests/winetests/shlwapi/string.c
index 7f069a4849..9114ad88e1 100644
--- a/modules/rostests/winetests/shlwapi/string.c
+++ b/modules/rostests/winetests/shlwapi/string.c
@@ -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);
@@ -694,7 +694,7 @@ static void test_StrFormatKBSizeW(void)
while(result->value)
{
pStrFormatKBSizeW(result->value, szBuffW, 256);
-
WideCharToMultiByte(CP_ACP,0,szBuffW,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR),NULL,NULL);
+ WideCharToMultiByte(CP_ACP, 0, szBuffW, -1, szBuff, ARRAY_SIZE(szBuff), NULL, NULL);
ok(!strcmp(result->kb_size, szBuff), "Formatted %s wrong: got %s, expected
%s\n",
wine_dbgstr_longlong(result->value), szBuff, result->kb_size);
@@ -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,
diff --git a/modules/rostests/winetests/shlwapi/url.c
b/modules/rostests/winetests/shlwapi/url.c
index 7b275a9f20..2c1f044a99 100644
--- a/modules/rostests/winetests/shlwapi/url.c
+++ b/modules/rostests/winetests/shlwapi/url.c
@@ -557,7 +557,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);
@@ -934,7 +934,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;
@@ -1001,7 +1001,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);
@@ -1015,12 +1015,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;
@@ -1036,7 +1036,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;
@@ -1131,7 +1131,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);
@@ -1203,7 +1203,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;
@@ -1293,7 +1293,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,
TEST_COMBINE[i].todo);
}
@@ -1314,7 +1314,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);
@@ -1368,8 +1368,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,
@@ -1383,8 +1383,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,
@@ -1429,7 +1429,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,
@@ -1520,7 +1520,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);
@@ -1542,7 +1542,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);
@@ -1621,23 +1621,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;