Commit 1694ab08 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

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

parent b03e800f
...@@ -169,7 +169,7 @@ static void ClassTest(HINSTANCE hInstance, BOOL global) ...@@ -169,7 +169,7 @@ static void ClassTest(HINSTANCE hInstance, BOOL global)
} }
/* check GetClassName */ /* check GetClassName */
i = GetClassNameW(hTestWnd, str, sizeof(str)/sizeof(str[0])); i = GetClassNameW(hTestWnd, str, ARRAY_SIZE(str));
ok(i == lstrlenW(className), ok(i == lstrlenW(className),
"GetClassName returned incorrect length\n"); "GetClassName returned incorrect length\n");
ok(!lstrcmpW(className,str), ok(!lstrcmpW(className,str),
...@@ -725,7 +725,7 @@ static void test_builtinproc(void) ...@@ -725,7 +725,7 @@ static void test_builtinproc(void)
ok(IsWindowUnicode(hwnd) || ok(IsWindowUnicode(hwnd) ||
broken(!IsWindowUnicode(hwnd)) /* Windows 8 and 10 */, broken(!IsWindowUnicode(hwnd)) /* Windows 8 and 10 */,
"Windows should be Unicode\n"); "Windows should be Unicode\n");
SendMessageW(hwnd, WM_GETTEXT, sizeof(buf) / sizeof(buf[0]), (LPARAM)buf); SendMessageW(hwnd, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf);
if (IsWindowUnicode(hwnd)) if (IsWindowUnicode(hwnd))
ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n"); ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
else else
...@@ -939,7 +939,7 @@ static const struct ...@@ -939,7 +939,7 @@ static const struct
static void test_extra_values(void) static void test_extra_values(void)
{ {
int i; int i;
for(i=0; i< sizeof(extra_values)/sizeof(extra_values[0]); i++) for(i = 0; i < ARRAY_SIZE(extra_values); i++)
{ {
WNDCLASSEXA wcx; WNDCLASSEXA wcx;
BOOL ret = GetClassInfoExA(NULL,extra_values[i].name,&wcx); BOOL ret = GetClassInfoExA(NULL,extra_values[i].name,&wcx);
...@@ -1133,7 +1133,7 @@ static void test_comctl32_class( const char *name ) ...@@ -1133,7 +1133,7 @@ static void test_comctl32_class( const char *name )
name++; name++;
GetTempPathA(sizeof(path)/sizeof(path[0]), path); GetTempPathA(ARRAY_SIZE(path), path);
strcat(path, "comctl32_class.manifest"); strcat(path, "comctl32_class.manifest");
create_manifest_file(path, comctl32_manifest); create_manifest_file(path, comctl32_manifest);
...@@ -1161,7 +1161,7 @@ static void test_comctl32_class( const char *name ) ...@@ -1161,7 +1161,7 @@ static void test_comctl32_class( const char *name )
if (!ret) if (!ret)
goto skiptest; goto skiptest;
MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE(nameW));
ret = GetClassInfoW( 0, nameW, &wcW ); ret = GetClassInfoW( 0, nameW, &wcW );
ok( ret, "GetClassInfoW failed for %s\n", name ); ok( ret, "GetClassInfoW failed for %s\n", name );
module = GetModuleHandleA( "comctl32" ); module = GetModuleHandleA( "comctl32" );
...@@ -1187,7 +1187,7 @@ static void test_comctl32_class( const char *name ) ...@@ -1187,7 +1187,7 @@ static void test_comctl32_class( const char *name )
ret = GetClassInfoA( 0, name, &wcA ); ret = GetClassInfoA( 0, name, &wcA );
ok( ret || broken(!ret) /* <= winxp */, "GetClassInfoA failed for %s\n", name ); ok( ret || broken(!ret) /* <= winxp */, "GetClassInfoA failed for %s\n", name );
if (!ret) return; if (!ret) return;
MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE(nameW));
ret = GetClassInfoW( 0, nameW, &wcW ); ret = GetClassInfoW( 0, nameW, &wcW );
ok( ret, "GetClassInfoW failed for %s\n", name ); ok( ret, "GetClassInfoW failed for %s\n", name );
module = GetModuleHandleA( "comctl32" ); module = GetModuleHandleA( "comctl32" );
...@@ -1243,7 +1243,7 @@ static void test_comctl32_classes(void) ...@@ -1243,7 +1243,7 @@ static void test_comctl32_classes(void)
}; };
winetest_get_mainargs( &argv ); winetest_get_mainargs( &argv );
for (i = 0; i < sizeof(classes) / sizeof(classes[0]); i++) for (i = 0; i < ARRAY_SIZE(classes); i++)
{ {
memset( &startup, 0, sizeof(startup) ); memset( &startup, 0, sizeof(startup) );
startup.cb = sizeof( startup ); startup.cb = sizeof( startup );
...@@ -1322,7 +1322,7 @@ static void test_actctx_classes(void) ...@@ -1322,7 +1322,7 @@ static void test_actctx_classes(void)
HWND hwnd; HWND hwnd;
char path[MAX_PATH]; char path[MAX_PATH];
GetTempPathA(sizeof(path)/sizeof(path[0]), path); GetTempPathA(ARRAY_SIZE(path), path);
strcat(path, "actctx_classes.manifest"); strcat(path, "actctx_classes.manifest");
create_manifest_file(path, main_manifest); create_manifest_file(path, main_manifest);
......
...@@ -711,7 +711,7 @@ static void test_synthesized(void) ...@@ -711,7 +711,7 @@ static void test_synthesized(void)
r = CloseClipboard(); r = CloseClipboard();
ok(r, "gle %d\n", GetLastError()); ok(r, "gle %d\n", GetLastError());
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) for (i = 0; i < ARRAY_SIZE(tests); i++)
{ {
r = OpenClipboard(NULL); r = OpenClipboard(NULL);
ok(r, "%u: gle %d\n", i, GetLastError()); ok(r, "%u: gle %d\n", i, GetLastError());
...@@ -2044,7 +2044,7 @@ static void test_string_data(void) ...@@ -2044,7 +2044,7 @@ static void test_string_data(void)
char bufferA[12]; char bufferA[12];
WCHAR bufferW[12]; WCHAR bufferW[12];
for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) for (i = 0; i < ARRAY_SIZE(test_data); i++)
{ {
/* 1-byte Unicode strings crash on Win64 */ /* 1-byte Unicode strings crash on Win64 */
#ifdef _WIN64 #ifdef _WIN64
......
...@@ -291,7 +291,7 @@ static void test_WM_LBUTTONDOWN(void) ...@@ -291,7 +291,7 @@ static void test_WM_LBUTTONDOWN(void)
hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|CBS_DROPDOWN, hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|CBS_DROPDOWN,
0, 0, 200, 150, hMainWnd, (HMENU)COMBO_ID, NULL, 0); 0, 0, 200, 150, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
for (i = 0; i < sizeof(choices)/sizeof(UINT); i++){ for (i = 0; i < ARRAY_SIZE(choices); i++){
sprintf(buffer, stringFormat, choices[i]); sprintf(buffer, stringFormat, choices[i]);
result = SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)buffer); result = SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)buffer);
ok(result == i, ok(result == i,
...@@ -709,7 +709,7 @@ static void test_listbox_size(DWORD style) ...@@ -709,7 +709,7 @@ static void test_listbox_size(DWORD style)
{10, 100, TRUE}, {10, 100, TRUE},
}; };
for(test = 0; test < sizeof(info_height) / sizeof(info_height[0]); test++) for(test = 0; test < ARRAY_SIZE(info_height); test++)
{ {
const struct list_size_info *info_test = &info_height[test]; const struct list_size_info *info_test = &info_height[test];
int height_item; /* Height of a list item */ int height_item; /* Height of a list item */
......
...@@ -2533,7 +2533,7 @@ static void test_PrivateExtractIcons(void) ...@@ -2533,7 +2533,7 @@ static void test_PrivateExtractIcons(void)
static const test_icon_entries_t icon_desc[] = {{0,0,TRUE}, {16,16,TRUE}, {32,32}, {64,64,TRUE}}; static const test_icon_entries_t icon_desc[] = {{0,0,TRUE}, {16,16,TRUE}, {32,32}, {64,64,TRUE}};
create_ico_file("extract.ico", icon_desc, sizeof(icon_desc)/sizeof(*icon_desc)); create_ico_file("extract.ico", icon_desc, ARRAY_SIZE(icon_desc));
ret = PrivateExtractIconsA("extract.ico", 0, 32, 32, &icon, NULL, 1, 0); ret = PrivateExtractIconsA("extract.ico", 0, 32, 32, &icon, NULL, 1, 0);
ok(ret == 1, "PrivateExtractIconsA returned %u\n", ret); ok(ret == 1, "PrivateExtractIconsA returned %u\n", ret);
......
...@@ -2396,7 +2396,7 @@ static WCHAR test_cmd_w_to_w[][32] = { ...@@ -2396,7 +2396,7 @@ static WCHAR test_cmd_w_to_w[][32] = {
{ 0x4efa, 0x4efc, 0x0061, 0x4efe, 0 }, /* some Chinese chars */ { 0x4efa, 0x4efc, 0x0061, 0x4efe, 0 }, /* some Chinese chars */
{ 0x0061, 0x0062, 0x0063, 0x9152, 0 }, /* Chinese with latin characters begin */ { 0x0061, 0x0062, 0x0063, 0x9152, 0 }, /* Chinese with latin characters begin */
}; };
static const int nb_callbacks = 5 + sizeof(test_cmd_w_to_w)/sizeof(test_cmd_w_to_w[0]); static const int nb_callbacks = 5 + ARRAY_SIZE(test_cmd_w_to_w);
static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV hconv, static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV hconv,
HSZ hsz1, HSZ hsz2, HDDEDATA hdata, HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
...@@ -2480,7 +2480,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV ...@@ -2480,7 +2480,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV
size_a = strlen(test_cmd_a_to_a) + 1; size_a = strlen(test_cmd_a_to_a) + 1;
size_w = (lstrlenW(cmd_w) + 1) * sizeof(WCHAR); size_w = (lstrlenW(cmd_w) + 1) * sizeof(WCHAR);
size_a_to_w = MultiByteToWideChar( CP_ACP, 0, test_cmd_a_to_a, -1, test_cmd_a_to_w, size_a_to_w = MultiByteToWideChar( CP_ACP, 0, test_cmd_a_to_a, -1, test_cmd_a_to_w,
sizeof(test_cmd_a_to_w)/sizeof(WCHAR) ) * sizeof(WCHAR); ARRAY_SIZE(test_cmd_a_to_w)) * sizeof(WCHAR);
size_w_to_a = WideCharToMultiByte( CP_ACP, 0, cmd_w, -1, size_w_to_a = WideCharToMultiByte( CP_ACP, 0, cmd_w, -1,
test_cmd_w_to_a, sizeof(test_cmd_w_to_a), NULL, NULL ); test_cmd_w_to_a, sizeof(test_cmd_w_to_a), NULL, NULL );
switch (str_index) switch (str_index)
...@@ -2528,7 +2528,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV ...@@ -2528,7 +2528,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV
/* double A->W mapping */ /* double A->W mapping */
/* NT uses the full size, XP+ only until the first null */ /* NT uses the full size, XP+ only until the first null */
DWORD nt_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, size_w, test_cmd_a_to_w, DWORD nt_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, size_w, test_cmd_a_to_w,
sizeof(test_cmd_a_to_w)/sizeof(WCHAR) ) * sizeof(WCHAR); ARRAY_SIZE(test_cmd_a_to_w)) * sizeof(WCHAR);
DWORD xp_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, -1, NULL, 0 ) * sizeof(WCHAR); DWORD xp_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, -1, NULL, 0 ) * sizeof(WCHAR);
ok(size == xp_size || broken(size == nt_size) || ok(size == xp_size || broken(size == nt_size) ||
broken(str_index == 4 && IsDBCSLeadByte(cmd_w[0])) /* East Asian */, broken(str_index == 4 && IsDBCSLeadByte(cmd_w[0])) /* East Asian */,
...@@ -2554,7 +2554,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV ...@@ -2554,7 +2554,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV
{ {
todo_wine ok(size == size_w, "Wrong size %d expected %d, msg_index=%d\n", size, size_w, msg_index); todo_wine ok(size == size_w, "Wrong size %d expected %d, msg_index=%d\n", size, size_w, msg_index);
MultiByteToWideChar(CP_ACP, 0, test_cmd_w_to_a, size_w, test_cmd_a_to_w, MultiByteToWideChar(CP_ACP, 0, test_cmd_w_to_a, size_w, test_cmd_a_to_w,
sizeof(test_cmd_a_to_w)/sizeof(WCHAR)); ARRAY_SIZE(test_cmd_a_to_w));
todo_wine ok(!lstrcmpW((WCHAR*)buffer, cmd_w), todo_wine ok(!lstrcmpW((WCHAR*)buffer, cmd_w),
"Expected %s got %s, msg_index=%d\n", wine_dbgstr_w(cmd_w), wine_dbgstr_w((WCHAR *)buffer), msg_index); "Expected %s got %s, msg_index=%d\n", wine_dbgstr_w(cmd_w), wine_dbgstr_w((WCHAR *)buffer), msg_index);
} }
...@@ -2562,7 +2562,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV ...@@ -2562,7 +2562,7 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV
{ {
todo_wine ok(size == size_w, "Wrong size %d expected %d, msg_index=%d\n", size, size_w, msg_index); todo_wine ok(size == size_w, "Wrong size %d expected %d, msg_index=%d\n", size, size_w, msg_index);
MultiByteToWideChar(CP_ACP, 0, test_cmd_w_to_a, size_w, test_cmd_a_to_w, MultiByteToWideChar(CP_ACP, 0, test_cmd_w_to_a, size_w, test_cmd_a_to_w,
sizeof(test_cmd_a_to_w)/sizeof(WCHAR)); ARRAY_SIZE(test_cmd_a_to_w));
if (!is_cjk()) if (!is_cjk())
todo_wine ok(!lstrcmpW((WCHAR*)buffer, test_cmd_a_to_w), "Expected %s, got %s, msg_index=%d\n", todo_wine ok(!lstrcmpW((WCHAR*)buffer, test_cmd_a_to_w), "Expected %s, got %s, msg_index=%d\n",
wine_dbgstr_w(test_cmd_a_to_w), wine_dbgstr_w((WCHAR*)buffer), msg_index); wine_dbgstr_w(test_cmd_a_to_w), wine_dbgstr_w((WCHAR*)buffer), msg_index);
...@@ -2663,7 +2663,7 @@ static void test_end_to_end_client(BOOL type_a) ...@@ -2663,7 +2663,7 @@ static void test_end_to_end_client(BOOL type_a)
err = DdeGetLastError(client_pid); err = DdeGetLastError(client_pid);
ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err); ok(err == DMLERR_NO_ERROR, "wrong dde error %x\n", err);
for (i = 0; i < sizeof(test_cmd_w_to_w)/sizeof(test_cmd_w_to_w[0]); i++) for (i = 0; i < ARRAY_SIZE(test_cmd_w_to_w); i++)
{ {
hdata = DdeClientTransaction((LPBYTE)test_cmd_w_to_w[i], hdata = DdeClientTransaction((LPBYTE)test_cmd_w_to_w[i],
(lstrlenW(test_cmd_w_to_w[i]) + 1) * sizeof(WCHAR), (lstrlenW(test_cmd_w_to_w[i]) + 1) * sizeof(WCHAR),
......
...@@ -161,7 +161,7 @@ static BOOL CreateWindows (HINSTANCE hinst) ...@@ -161,7 +161,7 @@ static BOOL CreateWindows (HINSTANCE hinst)
*/ */
if (p->id >= numwnds) if (p->id >= numwnds)
{ {
if (p->id >= sizeof(hwnd)/sizeof(hwnd[0])) if (p->id >= ARRAY_SIZE(hwnd))
{ {
trace ("Control %ld is out of range\n", p->id); trace ("Control %ld is out of range\n", p->id);
return FALSE; return FALSE;
...@@ -1045,7 +1045,7 @@ static void test_GetDlgItemText(void) ...@@ -1045,7 +1045,7 @@ static void test_GetDlgItemText(void)
BOOL ret; BOOL ret;
strcpy(string, "Overwrite Me"); strcpy(string, "Overwrite Me");
ret = GetDlgItemTextA(NULL, 0, string, sizeof(string)/sizeof(string[0])); ret = GetDlgItemTextA(NULL, 0, string, ARRAY_SIZE(string));
ok(!ret, "GetDlgItemText(NULL) shouldn't have succeeded\n"); ok(!ret, "GetDlgItemText(NULL) shouldn't have succeeded\n");
ok(string[0] == '\0' || broken(!strcmp(string, "Overwrite Me")), ok(string[0] == '\0' || broken(!strcmp(string, "Overwrite Me")),
...@@ -1461,7 +1461,7 @@ static INT_PTR CALLBACK test_aw_conversion_dlgproc(HWND hdlg, UINT msg, WPARAM w ...@@ -1461,7 +1461,7 @@ static INT_PTR CALLBACK test_aw_conversion_dlgproc(HWND hdlg, UINT msg, WPARAM w
(BYTE)buff[0], (BYTE)buff[1], len); (BYTE)buff[0], (BYTE)buff[1], len);
memset(buffW, 0xff, sizeof(buffW)); memset(buffW, 0xff, sizeof(buffW));
len = GetWindowTextW(hdlg, buffW, sizeof(buffW)/sizeof(buffW[0])); len = GetWindowTextW(hdlg, buffW, ARRAY_SIZE(buffW));
ok(buffW[0] == 'W' && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n", ok(buffW[0] == 'W' && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n",
buffW[0], buffW[1], len); buffW[0], buffW[1], len);
...@@ -1567,7 +1567,7 @@ static INT_PTR CALLBACK test_aw_conversion_dlgproc2(HWND hdlg, UINT msg, WPARAM ...@@ -1567,7 +1567,7 @@ static INT_PTR CALLBACK test_aw_conversion_dlgproc2(HWND hdlg, UINT msg, WPARAM
ok(!strcmp(buff, testtext) && len == 0, "Unexpected window text %s, len %d\n", buff, len); ok(!strcmp(buff, testtext) && len == 0, "Unexpected window text %s, len %d\n", buff, len);
memset(buffW, 0xff, sizeof(buffW)); memset(buffW, 0xff, sizeof(buffW));
len = GetWindowTextW(hdlg, buffW, sizeof(buffW)/sizeof(buffW[0])); len = GetWindowTextW(hdlg, buffW, ARRAY_SIZE(buffW));
ok(buffW[0] == 0 && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n", ok(buffW[0] == 0 && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n",
buffW[0], buffW[1], len); buffW[0], buffW[1], len);
......
...@@ -2956,7 +2956,7 @@ static void test_EM_GETLINE(void) ...@@ -2956,7 +2956,7 @@ static void test_EM_GETLINE(void)
hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
hwnd[1] = create_editcontrolW(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); hwnd[1] = create_editcontrolW(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
for (i = 0; i < sizeof(hwnd)/sizeof(hwnd[0]); i++) for (i = 0; i < ARRAY_SIZE(hwnd); i++)
{ {
static const WCHAR strW[] = {'t','e','x','t',0}; static const WCHAR strW[] = {'t','e','x','t',0};
static const char *str = "text"; static const char *str = "text";
...@@ -2984,13 +2984,13 @@ static void test_EM_GETLINE(void) ...@@ -2984,13 +2984,13 @@ static void test_EM_GETLINE(void)
ok(!strcmp(buff, str), "Unexpected line data %s.\n", buff); ok(!strcmp(buff, str), "Unexpected line data %s.\n", buff);
memset(buffW, 0, sizeof(buffW)); memset(buffW, 0, sizeof(buffW));
*(WORD *)buffW = sizeof(buffW)/sizeof(buffW[0]); *(WORD *)buffW = ARRAY_SIZE(buffW);
r = SendMessageW(hwnd[i], EM_GETLINE, 0, (LPARAM)buffW); r = SendMessageW(hwnd[i], EM_GETLINE, 0, (LPARAM)buffW);
ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r); ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r);
ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW)); ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW));
memset(buffW, 0, sizeof(buffW)); memset(buffW, 0, sizeof(buffW));
*(WORD *)buffW = sizeof(buffW)/sizeof(buffW[0]); *(WORD *)buffW = ARRAY_SIZE(buffW);
r = SendMessageW(hwnd[i], EM_GETLINE, 1, (LPARAM)buffW); r = SendMessageW(hwnd[i], EM_GETLINE, 1, (LPARAM)buffW);
ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r); ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r);
ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW)); ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW));
......
...@@ -943,8 +943,7 @@ static void test_Input_blackbox(void) ...@@ -943,8 +943,7 @@ static void test_Input_blackbox(void)
i.u.ki.time = 0; i.u.ki.time = 0;
i.u.ki.dwExtraInfo = 0; i.u.ki.dwExtraInfo = 0;
for (ii = 0; ii < sizeof(sendinput_test)/sizeof(struct sendinput_test_s)-1; for (ii = 0; ii < ARRAY_SIZE(sendinput_test)-1; ii++) {
ii++) {
GetKeyboardState(ks1); GetKeyboardState(ks1);
i.u.ki.wScan = ii+1 /* useful for debugging */; i.u.ki.wScan = ii+1 /* useful for debugging */;
i.u.ki.dwFlags = sendinput_test[ii].dwFlags; i.u.ki.dwFlags = sendinput_test[ii].dwFlags;
...@@ -1520,12 +1519,12 @@ static void test_GetRawInputDeviceList(void) ...@@ -1520,12 +1519,12 @@ static void test_GetRawInputDeviceList(void)
ok(ret > 0, "expected non-zero\n"); ok(ret > 0, "expected non-zero\n");
/* check if variable changes from larger to smaller value */ /* check if variable changes from larger to smaller value */
devcount = odevcount = sizeof(devices) / sizeof(devices[0]); devcount = odevcount = ARRAY_SIZE(devices);
oret = ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0])); oret = ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0]));
ok(ret > 0, "expected non-zero\n"); ok(ret > 0, "expected non-zero\n");
ok(devcount == odevcount, "expected %d, got %d\n", devcount, odevcount); ok(devcount == odevcount, "expected %d, got %d\n", devcount, odevcount);
devcount = odevcount; devcount = odevcount;
odevcount = sizeof(devices) / sizeof(devices[0]); odevcount = ARRAY_SIZE(devices);
ret = pGetRawInputDeviceList(NULL, &odevcount, sizeof(devices[0])); ret = pGetRawInputDeviceList(NULL, &odevcount, sizeof(devices[0]));
ok(ret == 0, "expected 0, got %d\n", ret); ok(ret == 0, "expected 0, got %d\n", ret);
ok(odevcount == oret, "expected %d, got %d\n", oret, odevcount); ok(odevcount == oret, "expected %d, got %d\n", oret, odevcount);
...@@ -1567,7 +1566,7 @@ static void test_key_map(void) ...@@ -1567,7 +1566,7 @@ static void test_key_map(void)
"Scan code -> vKey = %x (not VK_RSHIFT)\n", kR); "Scan code -> vKey = %x (not VK_RSHIFT)\n", kR);
/* test that MAPVK_VSC_TO_VK prefers the non-numpad vkey if there's ambiguity */ /* test that MAPVK_VSC_TO_VK prefers the non-numpad vkey if there's ambiguity */
for (i = 0; i < sizeof(numpad_collisions)/sizeof(numpad_collisions[0]); i++) for (i = 0; i < ARRAY_SIZE(numpad_collisions); i++)
{ {
UINT numpad_scan = MapVirtualKeyExA(numpad_collisions[i][0], MAPVK_VK_TO_VSC, kl); UINT numpad_scan = MapVirtualKeyExA(numpad_collisions[i][0], MAPVK_VK_TO_VSC, kl);
UINT other_scan = MapVirtualKeyExA(numpad_collisions[i][1], MAPVK_VK_TO_VSC, kl); UINT other_scan = MapVirtualKeyExA(numpad_collisions[i][1], MAPVK_VK_TO_VSC, kl);
...@@ -1665,7 +1664,7 @@ static void test_ToUnicode(void) ...@@ -1665,7 +1664,7 @@ static void test_ToUnicode(void)
"ToUnicode didn't null-terminate the buffer when there was room.\n"); "ToUnicode didn't null-terminate the buffer when there was room.\n");
} }
for (i = 0; i < sizeof(utests) / sizeof(utests[0]); i++) for (i = 0; i < ARRAY_SIZE(utests); i++)
{ {
UINT vk = utests[i].vk, mod = utests[i].modifiers, scan; UINT vk = utests[i].vk, mod = utests[i].modifiers, scan;
...@@ -1808,7 +1807,7 @@ static void test_key_names(void) ...@@ -1808,7 +1807,7 @@ static void test_key_names(void)
ok( buffer[0] == 0, "wrong string '%s'\n", buffer ); ok( buffer[0] == 0, "wrong string '%s'\n", buffer );
memset( bufferW, 0xcc, sizeof(bufferW) ); memset( bufferW, 0xcc, sizeof(bufferW) );
ret = GetKeyNameTextW( lparam, bufferW, sizeof(bufferW)/sizeof(WCHAR) ); ret = GetKeyNameTextW( lparam, bufferW, ARRAY_SIZE(bufferW));
ok( ret > 0, "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) ); ok( ret > 0, "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) );
ok( ret == lstrlenW(bufferW), "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) ); ok( ret == lstrlenW(bufferW), "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) );
......
...@@ -51,7 +51,7 @@ static int strcmp_aw(LPCWSTR strw, const char *stra) ...@@ -51,7 +51,7 @@ static int strcmp_aw(LPCWSTR strw, const char *stra)
WCHAR buf[1024]; WCHAR buf[1024];
if (!stra) return 1; if (!stra) return 1;
MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf));
return lstrcmpW(strw, buf); return lstrcmpW(strw, buf);
} }
......
...@@ -668,7 +668,7 @@ static void test_menu_ownerdraw(void) ...@@ -668,7 +668,7 @@ static void test_menu_ownerdraw(void)
ok( ret, "AppendMenu failed for %d\n", k-1); ok( ret, "AppendMenu failed for %d\n", k-1);
} }
MOD_maxid = k-1; MOD_maxid = k-1;
assert( k <= sizeof(MOD_rc)/sizeof(RECT)); assert( k <= ARRAY_SIZE(MOD_rc));
/* display the menu */ /* display the menu */
TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
...@@ -986,14 +986,14 @@ static void test_menu_bmp_and_string(void) ...@@ -986,14 +986,14 @@ static void test_menu_bmp_and_string(void)
for( ispop=1; ispop >= 0; ispop--){ for( ispop=1; ispop >= 0; ispop--){
static SIZE bmsizes[]= { static SIZE bmsizes[]= {
{10,10},{38,38},{1,30},{55,5}}; {10,10},{38,38},{1,30},{55,5}};
for( szidx=0; szidx < sizeof( bmsizes) / sizeof( SIZE); szidx++) { for( szidx=0; szidx < ARRAY_SIZE(bmsizes); szidx++) {
HBITMAP hbm = CreateBitmap( bmsizes[szidx].cx, bmsizes[szidx].cy,1,1,bmfill); HBITMAP hbm = CreateBitmap( bmsizes[szidx].cx, bmsizes[szidx].cy,1,1,bmfill);
HBITMAP bitmaps[] = { HBMMENU_CALLBACK, hbm, HBMMENU_POPUP_CLOSE, NULL }; HBITMAP bitmaps[] = { HBMMENU_CALLBACK, hbm, HBMMENU_POPUP_CLOSE, NULL };
ok( hbm != 0, "CreateBitmap failed err %d\n", GetLastError()); ok( hbm != 0, "CreateBitmap failed err %d\n", GetLastError());
for( txtidx = 0; txtidx < sizeof(MOD_txtsizes)/sizeof(MOD_txtsizes[0]); txtidx++) { for( txtidx = 0; txtidx < ARRAY_SIZE(MOD_txtsizes); txtidx++) {
for( hassub = 0; hassub < 2 ; hassub++) { /* add submenu item */ for( hassub = 0; hassub < 2 ; hassub++) { /* add submenu item */
for( mnuopt = 0; mnuopt < 3 ; mnuopt++){ /* test MNS_NOCHECK/MNS_CHECKORBMP */ for( mnuopt = 0; mnuopt < 3 ; mnuopt++){ /* test MNS_NOCHECK/MNS_CHECKORBMP */
for( bmpidx = 0; bmpidx <sizeof(bitmaps)/sizeof(HBITMAP); bmpidx++) { for( bmpidx = 0; bmpidx <ARRAY_SIZE(bitmaps); bmpidx++) {
/* no need to test NULL bitmaps of several sizes */ /* no need to test NULL bitmaps of several sizes */
if( !bitmaps[bmpidx] && szidx > 0) continue; if( !bitmaps[bmpidx] && szidx > 0) continue;
/* the HBMMENU_POPUP not to test for menu bars */ /* the HBMMENU_POPUP not to test for menu bars */
...@@ -2757,9 +2757,8 @@ static void test_menu_resource_layout(void) ...@@ -2757,9 +2757,8 @@ static void test_menu_resource_layout(void)
ok(ret, "AppendMenu failed\n"); ok(ret, "AppendMenu failed\n");
count = GetMenuItemCount(hmenu); count = GetMenuItemCount(hmenu);
ok(count == sizeof(menu_data)/sizeof(menu_data[0]), ok(count == ARRAY_SIZE(menu_data), "expected %u menu items, got %u\n",
"expected %u menu items, got %u\n", (UINT) ARRAY_SIZE(menu_data), count);
(UINT)(sizeof(menu_data)/sizeof(menu_data[0])), count);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
...@@ -2978,9 +2977,9 @@ static void test_InsertMenu(void) ...@@ -2978,9 +2977,9 @@ static void test_InsertMenu(void)
}; };
HMENU hmenu; HMENU hmenu;
#define create_menu(a) create_menu_from_data((a), sizeof(a)/sizeof((a)[0])) #define create_menu(a) create_menu_from_data((a), ARRAY_SIZE(a))
#define create_menuitem(a) create_menuitem_from_data((a), sizeof(a)/sizeof((a)[0])) #define create_menuitem(a) create_menuitem_from_data((a), ARRAY_SIZE(a))
#define compare_menu(h, a) compare_menu_data((h), (a), sizeof(a)/sizeof((a)[0])) #define compare_menu(h, a) compare_menu_data((h), (a), ARRAY_SIZE(a))
hmenu = create_menu(in1); hmenu = create_menu(in1);
compare_menu(hmenu, out1); compare_menu(hmenu, out1);
......
...@@ -398,7 +398,7 @@ static void test_monitors(void) ...@@ -398,7 +398,7 @@ static void test_monitors(void)
/* tests for cbSize in MONITORINFO */ /* tests for cbSize in MONITORINFO */
monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY ); monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY );
for (i = 0; i < (sizeof(testdatami) / sizeof(testdatami[0])); i++) for (i = 0; i < ARRAY_SIZE(testdatami); i++)
{ {
memset( &mi, 0, sizeof(mi) ); memset( &mi, 0, sizeof(mi) );
mi.cbSize = testdatami[i].cbSize; mi.cbSize = testdatami[i].cbSize;
...@@ -420,7 +420,7 @@ static void test_monitors(void) ...@@ -420,7 +420,7 @@ static void test_monitors(void)
} }
/* tests for cbSize in MONITORINFOEXA */ /* tests for cbSize in MONITORINFOEXA */
for (i = 0; i < (sizeof(testdatamiexa) / sizeof(testdatamiexa[0])); i++) for (i = 0; i < ARRAY_SIZE(testdatamiexa); i++)
{ {
memset( &miexa, 0, sizeof(miexa) ); memset( &miexa, 0, sizeof(miexa) );
miexa.cbSize = testdatamiexa[i].cbSize; miexa.cbSize = testdatamiexa[i].cbSize;
...@@ -433,7 +433,7 @@ static void test_monitors(void) ...@@ -433,7 +433,7 @@ static void test_monitors(void)
} }
/* tests for cbSize in MONITORINFOEXW */ /* tests for cbSize in MONITORINFOEXW */
for (i = 0; i < (sizeof(testdatamiexw) / sizeof(testdatamiexw[0])); i++) for (i = 0; i < ARRAY_SIZE(testdatamiexw); i++)
{ {
memset( &miexw, 0, sizeof(miexw) ); memset( &miexw, 0, sizeof(miexw) );
miexw.cbSize = testdatamiexw[i].cbSize; miexw.cbSize = testdatamiexw[i].cbSize;
......
...@@ -5062,7 +5062,7 @@ static void test_WM_DEVICECHANGE(HWND hwnd) ...@@ -5062,7 +5062,7 @@ static void test_WM_DEVICECHANGE(HWND hwnd)
DBT_DEVICETYPESPECIFIC, DBT_DEVICETYPESPECIFIC,
DBT_CUSTOMEVENT}; DBT_CUSTOMEVENT};
for (i = 0; i < sizeof(wparams)/sizeof(wparams[0]); i++) for (i = 0; i < ARRAY_SIZE(wparams); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = PostMessageA(hwnd, WM_DEVICECHANGE, wparams[i], 0); ret = PostMessageA(hwnd, WM_DEVICECHANGE, wparams[i], 0);
...@@ -6369,7 +6369,7 @@ static void test_button_messages(void) ...@@ -6369,7 +6369,7 @@ static void test_button_messages(void)
hfont2 = CreateFontIndirectA(&logfont); hfont2 = CreateFontIndirectA(&logfont);
ok(hfont2 != NULL, "Failed to create Tahoma font\n"); ok(hfont2 != NULL, "Failed to create Tahoma font\n");
for (i = 0; i < sizeof(button)/sizeof(button[0]); i++) for (i = 0; i < ARRAY_SIZE(button); i++)
{ {
MSG msg; MSG msg;
DWORD style, state; DWORD style, state;
...@@ -6782,7 +6782,7 @@ static void test_static_messages(void) ...@@ -6782,7 +6782,7 @@ static void test_static_messages(void)
subclass_static(); subclass_static();
for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++) for (i = 0; i < ARRAY_SIZE(static_ctrl); i++)
{ {
hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP, hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
0, 0, 50, 14, 0, 0, 0, NULL); 0, 0, 50, 14, 0, 0, 0, NULL);
...@@ -9825,13 +9825,13 @@ static void test_timers_no_wnd(void) ...@@ -9825,13 +9825,13 @@ static void test_timers_no_wnd(void)
win_skip("SetCoalescableTimer not available.\n"); win_skip("SetCoalescableTimer not available.\n");
/* Check what happens when we're running out of timers */ /* Check what happens when we're running out of timers */
for (i=0; i<sizeof(ids)/sizeof(ids[0]); i++) for (i = 0; i < ARRAY_SIZE(ids); i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ids[i] = SetTimer(NULL, 0, USER_TIMER_MAXIMUM, tfunc); ids[i] = SetTimer(NULL, 0, USER_TIMER_MAXIMUM, tfunc);
if (!ids[i]) break; if (!ids[i]) break;
} }
ok(i != sizeof(ids)/sizeof(ids[0]), "all timers were created successfully\n"); ok(i != ARRAY_SIZE(ids), "all timers were created successfully\n");
ok(GetLastError()==ERROR_NO_MORE_USER_HANDLES || broken(GetLastError()==0xdeadbeef), ok(GetLastError()==ERROR_NO_MORE_USER_HANDLES || broken(GetLastError()==0xdeadbeef),
"GetLastError() = %d\n", GetLastError()); "GetLastError() = %d\n", GetLastError());
while (i > 0) KillTimer(NULL, ids[--i]); while (i > 0) KillTimer(NULL, ids[--i]);
...@@ -10209,7 +10209,7 @@ static void test_winevents(void) ...@@ -10209,7 +10209,7 @@ static void test_winevents(void)
ok_sequence(WmEmptySeq, "empty notify winevents", FALSE); ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
} }
for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++) for (i = 0; i < ARRAY_SIZE(WmWinEventsSeq); i++)
pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam); pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
ok_sequence(WmWinEventsSeq, "notify winevents", FALSE); ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
...@@ -12893,7 +12893,7 @@ static void test_ShowWindow(void) ...@@ -12893,7 +12893,7 @@ static void test_ShowWindow(void)
ok(EqualRect(&win_rc, &wp.rcNormalPosition), "expected %s got %s\n", wine_dbgstr_rect(&win_rc), ok(EqualRect(&win_rc, &wp.rcNormalPosition), "expected %s got %s\n", wine_dbgstr_rect(&win_rc),
wine_dbgstr_rect(&wp.rcNormalPosition)); wine_dbgstr_rect(&wp.rcNormalPosition));
for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++) for (i = 0; i < ARRAY_SIZE(sw); i++)
{ {
static const char * const sw_cmd_name[13] = static const char * const sw_cmd_name[13] =
{ {
...@@ -14871,20 +14871,20 @@ static void test_defwinproc(void) ...@@ -14871,20 +14871,20 @@ static void test_defwinproc(void)
flush_events(); flush_events();
buffA[0] = 0; buffA[0] = 0;
GetWindowTextA(hwnd, buffA, sizeof(buffA)/sizeof(*buffA)); GetWindowTextA(hwnd, buffA, ARRAY_SIZE(buffA));
ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA); ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA);
/* Zero high word of the lParam */ /* Zero high word of the lParam */
res = DefWindowProcA(hwnd, WM_SETTEXT, 0, 0x1234); res = DefWindowProcA(hwnd, WM_SETTEXT, 0, 0x1234);
ok(res == 0, "WM_SETTEXT was expected to fail, %ld\n", res); ok(res == 0, "WM_SETTEXT was expected to fail, %ld\n", res);
GetWindowTextA(hwnd, buffA, sizeof(buffA)/sizeof(*buffA)); GetWindowTextA(hwnd, buffA, ARRAY_SIZE(buffA));
ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA); ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA);
res = DefWindowProcW(hwnd, WM_SETTEXT, 0, 0x1234); res = DefWindowProcW(hwnd, WM_SETTEXT, 0, 0x1234);
ok(res == 0, "WM_SETTEXT was expected to fail, %ld\n", res); ok(res == 0, "WM_SETTEXT was expected to fail, %ld\n", res);
GetWindowTextA(hwnd, buffA, sizeof(buffA)/sizeof(*buffA)); GetWindowTextA(hwnd, buffA, ARRAY_SIZE(buffA));
ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA); ok(!strcmp(buffA, "test_defwndproc"), "unexpected window text, %s\n", buffA);
GetCursorPos(&pos); GetCursorPos(&pos);
...@@ -15144,7 +15144,7 @@ static void test_PostMessage(void) ...@@ -15144,7 +15144,7 @@ static void test_PostMessage(void)
PostMessageA(hwnd, WM_USER+1, 0x1234, 0x5678); PostMessageA(hwnd, WM_USER+1, 0x1234, 0x5678);
PostMessageA(0, WM_USER+2, 0x5678, 0x1234); PostMessageA(0, WM_USER+2, 0x5678, 0x1234);
for (i = 0; i < sizeof(data)/sizeof(data[0]); i++) for (i = 0; i < ARRAY_SIZE(data); i++)
{ {
memset(&msg, 0xab, sizeof(msg)); memset(&msg, 0xab, sizeof(msg));
ret = PeekMessageA(&msg, data[i].hwnd, 0, 0, PM_NOREMOVE); ret = PeekMessageA(&msg, data[i].hwnd, 0, 0, PM_NOREMOVE);
...@@ -15202,7 +15202,7 @@ static void test_broadcast(void) ...@@ -15202,7 +15202,7 @@ static void test_broadcast(void)
oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)broadcast_test_proc); oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)broadcast_test_proc);
SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
for (i = 0; i < sizeof(messages)/sizeof(messages[0]); i++) for (i = 0; i < ARRAY_SIZE(messages); i++)
{ {
BOOL ret; BOOL ret;
MSG msg; MSG msg;
...@@ -15532,7 +15532,7 @@ static void test_WaitForInputIdle( char *argv0 ) ...@@ -15532,7 +15532,7 @@ static void test_WaitForInputIdle( char *argv0 )
thread = CreateThread( NULL, 0, wait_idle_thread, NULL, 0, &id ); thread = CreateThread( NULL, 0, wait_idle_thread, NULL, 0, &id );
for (i = 0; i < sizeof(wait_idle_expect)/sizeof(wait_idle_expect[0]); i++) for (i = 0; i < ARRAY_SIZE(wait_idle_expect); i++)
{ {
ResetEvent( start_event ); ResetEvent( start_event );
ResetEvent( end_event ); ResetEvent( end_event );
......
...@@ -50,7 +50,7 @@ static void test_LoadStringW(void) ...@@ -50,7 +50,7 @@ static void test_LoadStringW(void)
win_skip( "LoadStringW does not return a pointer to the resource\n" ); win_skip( "LoadStringW does not return a pointer to the resource\n" );
return; return;
} }
length2 = LoadStringW(hInst, 2, returnedstringw, sizeof(returnedstringw) /sizeof(WCHAR)); /* get resource string */ length2 = LoadStringW(hInst, 2, returnedstringw, ARRAY_SIZE(returnedstringw)); /* get resource string */
ok(length2 > 0, "LoadStringW failed to load resource 2, ret %d, err %d\n", length2, GetLastError()); ok(length2 > 0, "LoadStringW failed to load resource 2, ret %d, err %d\n", length2, GetLastError());
ok(length1 == length2, "LoadStringW returned different values dependent on buflen. ret1 %d, ret2 %d\n", ok(length1 == length2, "LoadStringW returned different values dependent on buflen. ret1 %d, ret2 %d\n",
length1, length2); length1, length2);
...@@ -93,7 +93,7 @@ static void test_LoadStringA (void) ...@@ -93,7 +93,7 @@ static void test_LoadStringA (void)
int ret, ret2; int ret, ret2;
assert (sizeof str < sizeof buf); assert (sizeof str < sizeof buf);
for (i = 0; i < sizeof tests / sizeof tests[0]; i++) { for (i = 0; i < ARRAY_SIZE(tests); i++) {
const unsigned int bufsiz = tests[i].bufsiz; const unsigned int bufsiz = tests[i].bufsiz;
const unsigned int expected = tests[i].expected; const unsigned int expected = tests[i].expected;
const int len = LoadStringA (hInst, 0, buf, bufsiz); const int len = LoadStringA (hInst, 0, buf, bufsiz);
......
...@@ -514,7 +514,7 @@ static void scrollbar_test_init(void) ...@@ -514,7 +514,7 @@ static void scrollbar_test_init(void)
wc.lpfnWndProc = scroll_init_proc; wc.lpfnWndProc = scroll_init_proc;
RegisterClassExA(&wc); RegisterClassExA(&wc);
for(i = 0; i < sizeof style / sizeof style[0]; i++) for(i = 0; i < ARRAY_SIZE(style); i++)
{ {
/* need not to destroy these windows due creation abort */ /* need not to destroy these windows due creation abort */
CreateWindowExA(0, cls_name, NULL, style[i], CreateWindowExA(0, cls_name, NULL, style[i],
......
...@@ -710,7 +710,7 @@ static void test_SPI_SETMOUSE( void ) /* 4 */ ...@@ -710,7 +710,7 @@ static void test_SPI_SETMOUSE( void ) /* 4 */
POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} }; POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} }; POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
int nchange = sizeof( req_change ) / sizeof( POINT ); int nchange = ARRAY_SIZE(req_change);
trace("testing SPI_{GET,SET}MOUSE\n"); trace("testing SPI_{GET,SET}MOUSE\n");
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
...@@ -875,7 +875,7 @@ static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */ ...@@ -875,7 +875,7 @@ static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */
if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDSPEED")) if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDSPEED"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
char buf[10]; char buf[10];
...@@ -964,7 +964,7 @@ static void test_SPI_SETSCREENSAVETIMEOUT( void ) /* 14 */ ...@@ -964,7 +964,7 @@ static void test_SPI_SETSCREENSAVETIMEOUT( void ) /* 14 */
if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVETIMEOUT")) if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVETIMEOUT"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
char buf[10]; char buf[10];
...@@ -1001,7 +1001,7 @@ static void test_SPI_SETSCREENSAVEACTIVE( void ) /* 17 */ ...@@ -1001,7 +1001,7 @@ static void test_SPI_SETSCREENSAVEACTIVE( void ) /* 17 */
if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVEACTIVE")) if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVEACTIVE"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
...@@ -1042,7 +1042,7 @@ static void test_SPI_SETKEYBOARDDELAY( void ) /* 23 */ ...@@ -1042,7 +1042,7 @@ static void test_SPI_SETKEYBOARDDELAY( void ) /* 23 */
if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDDELAY")) if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDDELAY"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT delay; UINT delay;
char buf[10]; char buf[10];
...@@ -1143,7 +1143,7 @@ static void test_SPI_SETICONTITLEWRAP( void ) /* 26 */ ...@@ -1143,7 +1143,7 @@ static void test_SPI_SETICONTITLEWRAP( void ) /* 26 */
if (!test_error_msg(rc,"SPI_{GET,SET}ICONTITLEWRAP")) if (!test_error_msg(rc,"SPI_{GET,SET}ICONTITLEWRAP"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
UINT regval; UINT regval;
...@@ -1187,7 +1187,7 @@ static void test_SPI_SETMENUDROPALIGNMENT( void ) /* 28 */ ...@@ -1187,7 +1187,7 @@ static void test_SPI_SETMENUDROPALIGNMENT( void ) /* 28 */
if (!test_error_msg(rc,"SPI_{GET,SET}MENUDROPALIGNMENT")) if (!test_error_msg(rc,"SPI_{GET,SET}MENUDROPALIGNMENT"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
...@@ -1223,7 +1223,7 @@ static void test_SPI_SETDOUBLECLKWIDTH( void ) /* 29 */ ...@@ -1223,7 +1223,7 @@ static void test_SPI_SETDOUBLECLKWIDTH( void ) /* 29 */
trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n"); trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n");
old_width = GetSystemMetrics( SM_CXDOUBLECLK ); old_width = GetSystemMetrics( SM_CXDOUBLECLK );
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
char buf[10]; char buf[10];
...@@ -1257,7 +1257,7 @@ static void test_SPI_SETDOUBLECLKHEIGHT( void ) /* 30 */ ...@@ -1257,7 +1257,7 @@ static void test_SPI_SETDOUBLECLKHEIGHT( void ) /* 30 */
trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n"); trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n");
old_height = GetSystemMetrics( SM_CYDOUBLECLK ); old_height = GetSystemMetrics( SM_CYDOUBLECLK );
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
char buf[10]; char buf[10];
...@@ -1347,7 +1347,7 @@ static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */ ...@@ -1347,7 +1347,7 @@ static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n"); trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
old_b = GetSystemMetrics( SM_SWAPBUTTON ); old_b = GetSystemMetrics( SM_SWAPBUTTON );
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0, rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0,
...@@ -1402,7 +1402,7 @@ static void test_SPI_SETDRAGFULLWINDOWS( void ) /* 37 */ ...@@ -1402,7 +1402,7 @@ static void test_SPI_SETDRAGFULLWINDOWS( void ) /* 37 */
if (!test_error_msg(rc,"SPI_{GET,SET}DRAGFULLWINDOWS")) if (!test_error_msg(rc,"SPI_{GET,SET}DRAGFULLWINDOWS"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
...@@ -1925,7 +1925,7 @@ static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */ ...@@ -1925,7 +1925,7 @@ static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */
if (!test_error_msg(rc,"SPI_{GET,SET}SHOWSOUNDS")) if (!test_error_msg(rc,"SPI_{GET,SET}SHOWSOUNDS"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
...@@ -1962,7 +1962,7 @@ static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */ ...@@ -1962,7 +1962,7 @@ static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDPREF")) if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDPREF"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
BOOL v; BOOL v;
...@@ -1997,7 +1997,7 @@ static void test_SPI_SETSCREENREADER( void ) /* 71 */ ...@@ -1997,7 +1997,7 @@ static void test_SPI_SETSCREENREADER( void ) /* 71 */
if (!test_error_msg(rc,"SPI_{GET,SET}SCREENREADER")) if (!test_error_msg(rc,"SPI_{GET,SET}SCREENREADER"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
BOOL v; BOOL v;
...@@ -2036,7 +2036,7 @@ static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */ ...@@ -2036,7 +2036,7 @@ static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */
SystemParametersInfoA( SPI_GETFONTSMOOTHINGCONTRAST, 0, &old_contrast, 0 ); SystemParametersInfoA( SPI_GETFONTSMOOTHINGCONTRAST, 0, &old_contrast, 0 );
SystemParametersInfoA( SPI_GETFONTSMOOTHINGORIENTATION, 0, &old_orient, 0 ); SystemParametersInfoA( SPI_GETFONTSMOOTHINGORIENTATION, 0, &old_orient, 0 );
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
...@@ -2113,7 +2113,7 @@ static void test_SPI_SETLOWPOWERACTIVE( void ) /* 85 */ ...@@ -2113,7 +2113,7 @@ static void test_SPI_SETLOWPOWERACTIVE( void ) /* 85 */
if (!test_error_msg(rc,"SPI_{GET,SET}LOWPOWERACTIVE")) if (!test_error_msg(rc,"SPI_{GET,SET}LOWPOWERACTIVE"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
...@@ -2151,7 +2151,7 @@ static void test_SPI_SETPOWEROFFACTIVE( void ) /* 86 */ ...@@ -2151,7 +2151,7 @@ static void test_SPI_SETPOWEROFFACTIVE( void ) /* 86 */
if (!test_error_msg(rc,"SPI_{GET,SET}POWEROFFACTIVE")) if (!test_error_msg(rc,"SPI_{GET,SET}POWEROFFACTIVE"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
...@@ -2189,7 +2189,7 @@ static void test_SPI_SETSNAPTODEFBUTTON( void ) /* 95 */ ...@@ -2189,7 +2189,7 @@ static void test_SPI_SETSNAPTODEFBUTTON( void ) /* 95 */
if (!test_error_msg(rc,"SPI_GETSNAPTODEFBUTTON")) if (!test_error_msg(rc,"SPI_GETSNAPTODEFBUTTON"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
...@@ -2224,7 +2224,7 @@ static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */ ...@@ -2224,7 +2224,7 @@ static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */
if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERWIDTH")) if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERWIDTH"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
char buf[10]; char buf[10];
...@@ -2261,7 +2261,7 @@ static void test_SPI_SETMOUSEHOVERHEIGHT( void ) /* 101 */ ...@@ -2261,7 +2261,7 @@ static void test_SPI_SETMOUSEHOVERHEIGHT( void ) /* 101 */
if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERHEIGHT")) if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERHEIGHT"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
char buf[10]; char buf[10];
...@@ -2302,7 +2302,7 @@ static void test_SPI_SETMOUSEHOVERTIME( void ) /* 103 */ ...@@ -2302,7 +2302,7 @@ static void test_SPI_SETMOUSEHOVERTIME( void ) /* 103 */
if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERTIME")) if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERTIME"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
char buf[10]; char buf[10];
...@@ -2341,7 +2341,7 @@ static void test_SPI_SETWHEELSCROLLLINES( void ) /* 105 */ ...@@ -2341,7 +2341,7 @@ static void test_SPI_SETWHEELSCROLLLINES( void ) /* 105 */
if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLLINES")) if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLLINES"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
char buf[10]; char buf[10];
...@@ -2380,7 +2380,7 @@ static void test_SPI_SETMENUSHOWDELAY( void ) /* 107 */ ...@@ -2380,7 +2380,7 @@ static void test_SPI_SETMENUSHOWDELAY( void ) /* 107 */
if (!test_error_msg(rc,"SPI_{GET,SET}MENUSHOWDELAY")) if (!test_error_msg(rc,"SPI_{GET,SET}MENUSHOWDELAY"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
char buf[10]; char buf[10];
...@@ -2419,7 +2419,7 @@ static void test_SPI_SETWHEELSCROLLCHARS( void ) /* 108 */ ...@@ -2419,7 +2419,7 @@ static void test_SPI_SETWHEELSCROLLCHARS( void ) /* 108 */
if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLCHARS")) if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLCHARS"))
return; return;
for (i=0;i<sizeof(vals)/sizeof(*vals);i++) for (i=0;i<ARRAY_SIZE(vals);i++)
{ {
UINT v; UINT v;
char buf[10]; char buf[10];
...@@ -2489,7 +2489,7 @@ static void test_WM_DISPLAYCHANGE(void) ...@@ -2489,7 +2489,7 @@ static void test_WM_DISPLAYCHANGE(void)
displaychange_sem = CreateSemaphoreW(NULL, 0, 1, NULL); displaychange_sem = CreateSemaphoreW(NULL, 0, 1, NULL);
for(i = 0; i < sizeof(test_bpps)/sizeof(test_bpps[0]); i++) { for(i = 0; i < ARRAY_SIZE(test_bpps); i++) {
last_bpp = -1; last_bpp = -1;
memset(&mode, 0, sizeof(mode)); memset(&mode, 0, sizeof(mode));
......
...@@ -765,7 +765,7 @@ static void test_CharToOem_OemToChar(void) ...@@ -765,7 +765,7 @@ static void test_CharToOem_OemToChar(void)
char oem; char oem;
WCHAR uni, expect; WCHAR uni, expect;
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) for (i = 0; i < ARRAY_SIZE(tests); i++)
{ {
const char *expected = tests[i].ret ? helloWorld : ""; const char *expected = tests[i].ret ? helloWorld : "";
const char *src = tests[i].src ? helloWorld : NULL; const char *src = tests[i].src ? helloWorld : NULL;
...@@ -792,7 +792,7 @@ static void test_CharToOem_OemToChar(void) ...@@ -792,7 +792,7 @@ static void test_CharToOem_OemToChar(void)
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf); ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
} }
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) for (i = 0; i < ARRAY_SIZE(tests); i++)
{ {
const char *expected = tests[i].ret ? helloWorld : ""; const char *expected = tests[i].ret ? helloWorld : "";
const WCHAR *src = tests[i].src ? helloWorldW : NULL; const WCHAR *src = tests[i].src ? helloWorldW : NULL;
...@@ -804,12 +804,12 @@ static void test_CharToOem_OemToChar(void) ...@@ -804,12 +804,12 @@ static void test_CharToOem_OemToChar(void)
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf); ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
ret = CharToOemBuffW(src, dst, sizeof(helloWorldW)/sizeof(WCHAR)); ret = CharToOemBuffW(src, dst, ARRAY_SIZE(helloWorldW));
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret); ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf); ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
} }
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) for (i = 0; i < ARRAY_SIZE(tests); i++)
{ {
const WCHAR *expected = tests[i].ret ? helloWorldW : emptyW; const WCHAR *expected = tests[i].ret ? helloWorldW : emptyW;
const char *src = tests[i].src ? helloWorld : NULL; const char *src = tests[i].src ? helloWorld : NULL;
......
...@@ -175,7 +175,7 @@ static void test_IsRectEmpty(void) ...@@ -175,7 +175,7 @@ static void test_IsRectEmpty(void)
{{-109, -107, -103, -101}, FALSE}, {{-109, -107, -103, -101}, FALSE},
}; };
for (i = 0; i < sizeof(rtest)/sizeof(rtest[0]); i++) { for (i = 0; i < ARRAY_SIZE(rtest); i++) {
ret = IsRectEmpty(&rtest[i].rect); ret = IsRectEmpty(&rtest[i].rect);
ok(ret == rtest[i].ret, "Test %d: IsRectEmpty returned %s for %s\n", i, ok(ret == rtest[i].ret, "Test %d: IsRectEmpty returned %s for %s\n", i,
ret ? "TRUE" : "FALSE", wine_dbgstr_rect(&rtest[i].rect)); ret ? "TRUE" : "FALSE", wine_dbgstr_rect(&rtest[i].rect));
......
...@@ -66,7 +66,7 @@ static void wsprintfATest(void) ...@@ -66,7 +66,7 @@ static void wsprintfATest(void)
win_skip( "I64 formats not supported\n" ); win_skip( "I64 formats not supported\n" );
return; return;
} }
for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++) for (i = 0; i < ARRAY_SIZE(i64_formats); i++)
{ {
rc = wsprintfA(buf, i64_formats[i].fmt, i64_formats[i].value); rc = wsprintfA(buf, i64_formats[i].fmt, i64_formats[i].value);
ok(rc == strlen(i64_formats[i].res), "%u: wsprintfA length failure: rc=%d\n", i, rc); ok(rc == strlen(i64_formats[i].res), "%u: wsprintfA length failure: rc=%d\n", i, rc);
...@@ -98,10 +98,10 @@ static void wsprintfWTest(void) ...@@ -98,10 +98,10 @@ static void wsprintfWTest(void)
win_skip( "I64 formats not supported\n" ); win_skip( "I64 formats not supported\n" );
return; return;
} }
for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++) for (i = 0; i < ARRAY_SIZE(i64_formats); i++)
{ {
MultiByteToWideChar( CP_ACP, 0, i64_formats[i].fmt, -1, fmt, sizeof(fmt)/sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, i64_formats[i].fmt, -1, fmt, ARRAY_SIZE(fmt));
MultiByteToWideChar( CP_ACP, 0, i64_formats[i].res, -1, res, sizeof(res)/sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, i64_formats[i].res, -1, res, ARRAY_SIZE(res));
rc = wsprintfW(buf, fmt, i64_formats[i].value); rc = wsprintfW(buf, fmt, i64_formats[i].value);
ok(rc == lstrlenW(res), "%u: wsprintfW length failure: rc=%d\n", i, rc); ok(rc == lstrlenW(res), "%u: wsprintfW length failure: rc=%d\n", i, rc);
ok(!lstrcmpW(buf, res), "%u: wrong result [%s]\n", i, wine_dbgstr_w(buf)); ok(!lstrcmpW(buf, res), "%u: wrong result [%s]\n", i, wine_dbgstr_w(buf));
......
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