Commit 77376000 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

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

parent 39bd2c96
......@@ -197,7 +197,7 @@ static BOOL create_manifest_file(const char *filename, const char *manifest)
WCHAR path[MAX_PATH];
MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH );
GetFullPathNameW(path, sizeof(manifest_path)/sizeof(WCHAR), manifest_path, NULL);
GetFullPathNameW(path, ARRAY_SIZE(manifest_path), manifest_path, NULL);
manifest_len = strlen(manifest);
file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
......@@ -2334,7 +2334,7 @@ static void test_OleRegGetUserType(void)
}
/* test using registered CLSID */
StringFromGUID2(&CLSID_non_existent, clsidW, sizeof(clsidW)/sizeof(clsidW[0]));
StringFromGUID2(&CLSID_non_existent, clsidW, ARRAY_SIZE(clsidW));
ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsidkeyW, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &clsidhkey, &disposition);
if (!ret)
......@@ -2522,7 +2522,7 @@ static void flush_messages(void)
static LRESULT CALLBACK cowait_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
if(cowait_msgs_last < sizeof(cowait_msgs)/sizeof(*cowait_msgs))
if(cowait_msgs_last < ARRAY_SIZE(cowait_msgs))
cowait_msgs[cowait_msgs_last++] = msg;
if(msg == WM_DDE_FIRST)
return 6;
......
......@@ -701,7 +701,7 @@ static void test_DoDragDrop(void)
GetWindowRect(hwnd, &rect);
ok(SetCursorPos(rect.left+50, rect.top+50), "SetCursorPos failed\n");
for (seq = 0; seq < sizeof(call_lists) / sizeof(call_lists[0]); seq++)
for (seq = 0; seq < ARRAY_SIZE(call_lists); seq++)
{
DWORD effect_in;
trace("%d\n", seq);
......
......@@ -3941,8 +3941,8 @@ static const char *debugstr_iid(REFIID riid)
WCHAR bufferW[39];
char buffer[39];
LONG name_size = sizeof(name);
StringFromGUID2(riid, bufferW, sizeof(bufferW)/sizeof(bufferW[0]));
WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer, sizeof(buffer), NULL, NULL);
StringFromGUID2(riid, bufferW, ARRAY_SIZE(bufferW));
WideCharToMultiByte(CP_ACP, 0, bufferW, ARRAY_SIZE(bufferW), buffer, sizeof(buffer), NULL, NULL);
if (RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_QUERY_VALUE, &hkeyInterface) != ERROR_SUCCESS)
{
memcpy(name, buffer, sizeof(buffer));
......
......@@ -38,7 +38,6 @@
#define ok_more_than_one_lock() ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)
#define ok_no_locks() ok(cLocks == 0, "Number of locks should be 0, but actually is %d\n", cLocks)
#define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)
#define COUNTOF(x) (sizeof(x) / sizeof(x[0]))
#define CHECK_EXPECTED_METHOD(method_name) \
do { \
......@@ -905,7 +904,7 @@ static void test_MkParseDisplayName(void)
hr = CreateBindCtx(0, &pbc);
ok_ole_success(hr, CreateBindCtx);
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
eaten = 0xdeadbeef;
pmk = (IMoniker *)0xdeadbeef;
......@@ -947,7 +946,7 @@ static void test_MkParseDisplayName(void)
pmk = NULL;
hr = MkParseDisplayName(pbc, wszDisplayName, &eaten, &pmk);
ok_ole_success(hr, MkParseDisplayName);
ok(eaten == sizeof(wszDisplayName)/sizeof(WCHAR) - 1,
ok(eaten == ARRAY_SIZE(wszDisplayName) - 1,
"Processed character count should have been 43 instead of %u\n", eaten);
if (pmk)
{
......@@ -969,7 +968,7 @@ static void test_MkParseDisplayName(void)
pmk = NULL;
hr = MkParseDisplayName(pbc, wszDisplayNameRunning, &eaten, &pmk);
ok_ole_success(hr, MkParseDisplayName);
ok(eaten == sizeof(wszDisplayNameRunning)/sizeof(WCHAR) - 1,
ok(eaten == ARRAY_SIZE(wszDisplayNameRunning) - 1,
"Processed character count should have been 15 instead of %u\n", eaten);
if (pmk)
{
......@@ -987,7 +986,7 @@ static void test_MkParseDisplayName(void)
expected_display_name = wszDisplayNameProgId1;
hr = MkParseDisplayName(pbc, wszDisplayNameProgId1, &eaten, &pmk);
ok_ole_success(hr, MkParseDisplayName);
ok(eaten == sizeof(wszDisplayNameProgId1)/sizeof(WCHAR) - 1,
ok(eaten == ARRAY_SIZE(wszDisplayNameProgId1) - 1,
"Processed character count should have been 8 instead of %u\n", eaten);
if (pmk)
{
......@@ -999,7 +998,7 @@ static void test_MkParseDisplayName(void)
expected_display_name = wszDisplayNameProgId2;
hr = MkParseDisplayName(pbc, wszDisplayNameProgId2, &eaten, &pmk);
ok_ole_success(hr, MkParseDisplayName);
ok(eaten == sizeof(wszDisplayNameProgId2)/sizeof(WCHAR) - 1,
ok(eaten == ARRAY_SIZE(wszDisplayNameProgId2) - 1,
"Processed character count should have been 8 instead of %u\n", eaten);
if (pmk)
{
......@@ -1021,7 +1020,8 @@ static void test_MkParseDisplayName(void)
GetSystemDirectoryA(szDisplayNameFile, sizeof(szDisplayNameFile));
strcat(szDisplayNameFile, "\\kernel32.dll");
len = MultiByteToWideChar(CP_ACP, 0, szDisplayNameFile, -1, wszDisplayNameFile, sizeof(wszDisplayNameFile)/sizeof(wszDisplayNameFile[0]));
len = MultiByteToWideChar(CP_ACP, 0, szDisplayNameFile, -1, wszDisplayNameFile,
ARRAY_SIZE(wszDisplayNameFile));
hr = MkParseDisplayName(pbc, wszDisplayNameFile, &eaten, &pmk);
ok_ole_success(hr, MkParseDisplayName);
ok(eaten == len - 1, "Processed character count should have been %d instead of %u\n", len - 1, eaten);
......@@ -1034,7 +1034,8 @@ static void test_MkParseDisplayName(void)
hr = MkParseDisplayName(pbc, wszDisplayName, &eaten, &pmk);
ok_ole_success(hr, MkParseDisplayName);
ok(eaten == sizeof(wszDisplayName)/sizeof(WCHAR) - 1, "Processed character count should have been 43 instead of %u\n", eaten);
ok(eaten == ARRAY_SIZE(wszDisplayName) - 1,
"Processed character count should have been 43 instead of %u\n", eaten);
if (pmk)
{
......@@ -1550,7 +1551,7 @@ static void test_file_monikers(void)
trace("ACP is %u\n", GetACP());
for (i = 0; i < COUNTOF(wszFile); ++i)
for (i = 0; i < ARRAY_SIZE(wszFile); ++i)
{
int j ;
if (i == 2)
......
......@@ -1728,7 +1728,7 @@ static void test_data_cache(void)
{ NULL, 0 }
};
GetSystemDirectoryA(szSystemDir, sizeof(szSystemDir)/sizeof(szSystemDir[0]));
GetSystemDirectoryA(szSystemDir, ARRAY_SIZE(szSystemDir));
expected_method_list = methods_cacheinitnew;
......@@ -1860,7 +1860,7 @@ static void test_data_cache(void)
hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
ok_ole_success(hr, "IOleCache_Cache");
MultiByteToWideChar(CP_ACP, 0, szSystemDir, -1, wszPath, sizeof(wszPath)/sizeof(wszPath[0]));
MultiByteToWideChar(CP_ACP, 0, szSystemDir, -1, wszPath, ARRAY_SIZE(wszPath));
memcpy(wszPath+lstrlenW(wszPath), wszShell32, sizeof(wszShell32));
fmtetc.cfFormat = CF_METAFILEPICT;
......@@ -2490,7 +2490,7 @@ static void test_data_cache_init(void)
{ &CLSID_Picture_EnhMetafile, 3, 1 }
};
for (i = 0; i < sizeof(data) / sizeof(data[0]); i++)
for (i = 0; i < ARRAY_SIZE(data); i++)
{
hr = CreateDataCache( NULL, data[i].clsid, &IID_IOleCache2, (void **)&cache );
ok( hr == S_OK, "got %08x\n", hr );
......@@ -4541,7 +4541,7 @@ static void test_data_cache_contents(void)
{ &stg_def_9, &stg_def_9_saved },
};
for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
for (i = 0; i < ARRAY_SIZE(test_data); i++)
{
if (winetest_debug > 1)
trace("start testing storage def %d\n", i);
......
......@@ -69,7 +69,7 @@ static const char *debugstr_guid(const GUID *guid)
if (!guid) return "(null)";
for (i = 0; i < sizeof(guid_name)/sizeof(guid_name[0]); i++)
for (i = 0; i < ARRAY_SIZE(guid_name); i++)
{
if (IsEqualIID(guid, guid_name[i].guid))
return guid_name[i].name;
......
......@@ -189,7 +189,7 @@ static void test_validtypes(void)
ok(U(propvar).uhVal.QuadPart == 0, "expected 0, got %#x/%#x\n",
U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
for (i = 0; i < sizeof(valid_types)/sizeof(valid_types[0]); i++)
for (i = 0; i < ARRAY_SIZE(valid_types); i++)
{
VARTYPE vt;
......
......@@ -2084,9 +2084,9 @@ static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD
{
int i, j, idx = 0;
for (i = 0; i < sizeof(access_modes)/sizeof(access_modes[0]); i++)
for (i = 0; i < ARRAY_SIZE(access_modes); i++)
{
for (j = 0; j < sizeof(share_modes)/sizeof(share_modes[0]); j++)
for (j = 0; j < ARRAY_SIZE(share_modes); j++)
{
DWORD lasterr;
HANDLE hfile;
......@@ -3490,7 +3490,7 @@ static void test_locking(void)
IStorage *stg;
HRESULT hr;
for (i=0; i<sizeof(lock_tests)/sizeof(lock_tests[0]); i++)
for (i = 0; i < ARRAY_SIZE(lock_tests); i++)
{
const struct lock_test *current = &lock_tests[i];
BOOL any_failure = FALSE;
......
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