[PATCH] comctl32/tests: Use the available ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Wed Jun 6 13:36:15 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
Same object is generated with or without this patch when adding
"-g0 -DNDEBUG -DWINETEST_NO_LINE_NUMBERS" to the CFLAGS.


 dlls/comctl32/tests/combo.c      |  4 ++--
 dlls/comctl32/tests/edit.c       |  6 +++---
 dlls/comctl32/tests/header.c     |  4 ++--
 dlls/comctl32/tests/imagelist.c  |  2 +-
 dlls/comctl32/tests/ipaddress.c  |  4 ++--
 dlls/comctl32/tests/listbox.c    |  2 +-
 dlls/comctl32/tests/listview.c   | 14 +++++++-------
 dlls/comctl32/tests/monthcal.c   |  7 +++----
 dlls/comctl32/tests/mru.c        |  4 ++--
 dlls/comctl32/tests/progress.c   |  2 +-
 dlls/comctl32/tests/rebar.c      |  4 ++--
 dlls/comctl32/tests/status.c     |  2 +-
 dlls/comctl32/tests/taskdialog.c |  3 +--
 dlls/comctl32/tests/toolbar.c    | 16 ++++++++--------
 dlls/comctl32/tests/tooltips.c   |  4 ++--
 dlls/comctl32/tests/treeview.c   | 14 +++++++-------
 dlls/comctl32/tests/updown.c     | 12 ++++++------
 17 files changed, 51 insertions(+), 53 deletions(-)

diff --git a/dlls/comctl32/tests/combo.c b/dlls/comctl32/tests/combo.c
index 83b36f212f..5fee206fd1 100644
--- a/dlls/comctl32/tests/combo.c
+++ b/dlls/comctl32/tests/combo.c
@@ -264,7 +264,7 @@ static void test_comboex_WM_LBUTTONDOWN(void)
             WS_VISIBLE|WS_CHILD|CBS_DROPDOWN, 0, 0, 200, 150,
             hComboExParentWnd, NULL, hMainHinst, NULL);
 
-    for (i = 0; i < sizeof(choices)/sizeof(UINT); i++){
+    for (i = 0; i < ARRAY_SIZE(choices); i++){
         COMBOBOXEXITEMW cbexItem;
         wsprintfW(buffer, stringFormat, choices[i]);
 
@@ -1169,7 +1169,7 @@ static void test_combo_dropdown_size(DWORD style)
         {15, 50, 3},
     };
 
-    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];
         int height_item; /* Height of a list item */
diff --git a/dlls/comctl32/tests/edit.c b/dlls/comctl32/tests/edit.c
index 7e9e7e7634..a5097d1cbb 100644
--- a/dlls/comctl32/tests/edit.c
+++ b/dlls/comctl32/tests/edit.c
@@ -2969,7 +2969,7 @@ static void test_EM_GETLINE(void)
     hwnd[0] = create_editcontrol(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 char *str = "text";
@@ -2994,13 +2994,13 @@ static void test_EM_GETLINE(void)
         ok(!strcmp(buff, str), "Unexpected line data %s.\n", buff);
 
         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);
         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));
 
         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);
         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));
diff --git a/dlls/comctl32/tests/header.c b/dlls/comctl32/tests/header.c
index 7ea80519a6..3428936cd7 100644
--- a/dlls/comctl32/tests/header.c
+++ b/dlls/comctl32/tests/header.c
@@ -1130,7 +1130,7 @@ static void test_hdm_index_messages(HWND hParent)
          ok_sequence(sequences, PARENT_SEQ_INDEX, add_header_to_parent_seq,
                                      "adder header control to parent", FALSE);
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
-    for (i = 0; i < sizeof(item_texts)/sizeof(item_texts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(item_texts); i++)
     {
         hdItem.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT;
         hdItem.pszText = (char*)item_texts[i];
@@ -1170,7 +1170,7 @@ static void test_hdm_index_messages(HWND hParent)
 
     hdItem.mask = HDI_TEXT | HDI_WIDTH;
     hdItem.pszText = buffA;
-    hdItem.cchTextMax = sizeof(buffA)/sizeof(buffA[0]);
+    hdItem.cchTextMax = ARRAY_SIZE(buffA);
     retVal = SendMessageA(hChild, HDM_GETITEMA, 0, (LPARAM) &hdItem);
     ok(retVal == TRUE, "Getting the 1st header item should return TRUE, got %d\n", retVal);
 
diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c
index 1c307e4ed3..3bb7902a13 100644
--- a/dlls/comctl32/tests/imagelist.c
+++ b/dlls/comctl32/tests/imagelist.c
@@ -1096,7 +1096,7 @@ static void image_list_init(HIMAGELIST himl, INT grow)
 
     check_iml_data(himl, BMP_CX, BMP_CX, 0, 2, grow, ILC_COLOR24, "total 0");
 
-    for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(td); i++)
     {
         image_list_add_bitmap(himl, td[i].grey, i + 1);
         check_iml_data(himl, td[i].cx, td[i].cy, td[i].cur, td[i].max, grow, td[i].bpp, td[i].comment);
diff --git a/dlls/comctl32/tests/ipaddress.c b/dlls/comctl32/tests/ipaddress.c
index 52581899a7..cc79b7bf11 100644
--- a/dlls/comctl32/tests/ipaddress.c
+++ b/dlls/comctl32/tests/ipaddress.c
@@ -50,12 +50,12 @@ static void test_get_set_text(void)
     }
 
     /* check text just after creation */
-    r = GetWindowTextA(hwnd, ip, sizeof(ip)/sizeof(CHAR));
+    r = GetWindowTextA(hwnd, ip, ARRAY_SIZE(ip));
     expect(7, r);
     ok(strcmp(ip, "0.0.0.0") == 0, "Expected null IP address, got %s\n", ip);
 
     SendMessageA(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(127, 0, 0, 1));
-    r = GetWindowTextA(hwnd, ip, sizeof(ip)/sizeof(CHAR));
+    r = GetWindowTextA(hwnd, ip, ARRAY_SIZE(ip));
     expect(9, r);
     ok(strcmp(ip, "127.0.0.1") == 0, "Expected 127.0.0.1, got %s\n", ip);
 
diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c
index 1513bea7f5..f44fdff77f 100644
--- a/dlls/comctl32/tests/listbox.c
+++ b/dlls/comctl32/tests/listbox.c
@@ -48,7 +48,7 @@ static int strcmp_aw(LPCWSTR strw, const char *stra)
     WCHAR buf[1024];
 
     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);
 }
 
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index c2d33c41f5..e9b715ee41 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2328,7 +2328,7 @@ static void test_multiselect(void)
     r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
     ok(r == 0, "got %d\n", r);
 
-    for (i = 0; i < sizeof(task_list)/sizeof(task_list[0]); i++) {
+    for (i = 0; i < ARRAY_SIZE(task_list); i++) {
         DWORD selected_count;
         LVITEMA item;
 
@@ -3481,7 +3481,7 @@ static void test_norecompute(void)
     item.mask  = LVIF_TEXT | LVIF_NORECOMPUTE;
     item.iItem = 0;
     item.pszText    = buff;
-    item.cchTextMax = sizeof(buff)/sizeof(CHAR);
+    item.cchTextMax = ARRAY_SIZE(buff);
     res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
     expect(TRUE, res);
     ok(lstrcmpA(buff, testA) == 0, "Expected (%s), got (%s)\n", testA, buff);
@@ -3495,7 +3495,7 @@ static void test_norecompute(void)
     item.mask  = LVIF_TEXT | LVIF_NORECOMPUTE;
     item.iItem = 1;
     item.pszText    = buff;
-    item.cchTextMax = sizeof(buff)/sizeof(CHAR);
+    item.cchTextMax = ARRAY_SIZE(buff);
 
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
     res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
@@ -3520,7 +3520,7 @@ static void test_norecompute(void)
     item.mask  = LVIF_TEXT | LVIF_NORECOMPUTE;
     item.iItem = 0;
     item.pszText    = buff;
-    item.cchTextMax = sizeof(buff)/sizeof(CHAR);
+    item.cchTextMax = ARRAY_SIZE(buff);
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
     res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
     expect(TRUE, res);
@@ -4662,7 +4662,7 @@ static void test_canceleditlabel(void)
     ok(!IsWindow(hwndedit), "Expected edit control to be destroyed\n");
     memset(&itema, 0, sizeof(itema));
     itema.pszText = buff;
-    itema.cchTextMax = sizeof(buff)/sizeof(CHAR);
+    itema.cchTextMax = ARRAY_SIZE(buff);
     ret = SendMessageA(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&itema);
     expect(5, ret);
     ok(strcmp(buff, test1) == 0, "Expected label text not to change\n");
@@ -5658,7 +5658,7 @@ static void test_dispinfo(void)
 
     g_disp_A_to_W = TRUE;
     item.pszText = (char*)buff;
-    item.cchTextMax = sizeof(buff)/sizeof(WCHAR);
+    item.cchTextMax = ARRAY_SIZE(buff);
     ret = SendMessageA(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
     ok(ret == sizeof(testA)-1, "got %d, expected 4\n", ret);
     g_disp_A_to_W = FALSE;
@@ -6177,7 +6177,7 @@ static void test_state_image(void)
     };
     int i;
 
-    for (i = 0; i < sizeof(styles)/sizeof(styles[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(styles); i++)
     {
         static char text[] = "Item";
         static char subtext[] = "Subitem";
diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c
index 85822a320c..7c78540333 100644
--- a/dlls/comctl32/tests/monthcal.c
+++ b/dlls/comctl32/tests/monthcal.c
@@ -1216,7 +1216,7 @@ if (0)
             } else {
                 title_index++;
 
-                if (sizeof(title_hits) / sizeof(title_hits[0]) <= title_index)
+                if (ARRAY_SIZE(title_hits) <= title_index)
                     break;
 
                 todo_wine_if(title_hits[title_index].todo)
@@ -1241,8 +1241,7 @@ if (0)
 
     todo_wine ok(month_count + year_count >= 1, "Not enough month and year items\n");
 
-    ok(r.right <= x && title_index + 1 == sizeof(title_hits) / sizeof(title_hits[0]),
-       "Wrong title layout\n");
+    ok(r.right <= x && title_index + 1 == ARRAY_SIZE(title_hits), "Wrong title layout\n");
 
     DestroyWindow(hwnd);
 }
@@ -2016,7 +2015,7 @@ static void test_sel_notify(void)
     };
     int i;
 
-    for(i = 0; i < sizeof styles / sizeof styles[0]; i++)
+    for(i = 0; i < ARRAY_SIZE(styles); i++)
     {
         hwnd = create_monthcal_control(styles[i].val);
         SetWindowLongPtrA(hwnd, GWLP_ID, SEL_NOTIFY_TEST_ID);
diff --git a/dlls/comctl32/tests/mru.c b/dlls/comctl32/tests/mru.c
index dfad6f859d..b3d3e7a265 100644
--- a/dlls/comctl32/tests/mru.c
+++ b/dlls/comctl32/tests/mru.c
@@ -118,7 +118,7 @@ static LSTATUS mru_RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
     dwMaxSubkeyLen++;
     dwMaxValueLen++;
     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
-    if (dwMaxLen > sizeof(szNameBuf)/sizeof(CHAR))
+    if (dwMaxLen > ARRAY_SIZE(szNameBuf))
     {
         /* Name too big: alloc a buffer for it */
         if (!(lpszName = heap_alloc(dwMaxLen * sizeof(CHAR))))
@@ -480,7 +480,7 @@ static void test_CreateMRUListLazyA(void)
         return;
     }
 
-    for (i = 0; i < sizeof(create_lazyA)/sizeof(create_lazya_t); i++)
+    for (i = 0; i < ARRAY_SIZE(create_lazyA); i++)
     {
         const create_lazya_t *ptr = &create_lazyA[i];
         HANDLE hMRU;
diff --git a/dlls/comctl32/tests/progress.c b/dlls/comctl32/tests/progress.c
index b911021be0..497cb47d3c 100644
--- a/dlls/comctl32/tests/progress.c
+++ b/dlls/comctl32/tests/progress.c
@@ -258,7 +258,7 @@ static void test_PBM_STEPIT(void)
     HWND progress;
     int i, j;
 
-    for (i = 0; i < sizeof(stepit_tests)/sizeof(stepit_tests[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(stepit_tests); i++)
     {
         struct stepit_test *test = &stepit_tests[i];
         LRESULT ret;
diff --git a/dlls/comctl32/tests/rebar.c b/dlls/comctl32/tests/rebar.c
index 7dae3a7dbe..3b1be77497 100644
--- a/dlls/comctl32/tests/rebar.c
+++ b/dlls/comctl32/tests/rebar.c
@@ -826,7 +826,7 @@ static DWORD resize_numtests = 0;
         RECT r; \
         int value; \
         const rbresize_test_result_t *res = &resize_results[resize_numtests++]; \
-        assert(resize_numtests <= sizeof(resize_results)/sizeof(resize_results[0])); \
+        assert(resize_numtests <= ARRAY_SIZE(resize_results)); \
         GetWindowRect(hRebar, &r); \
         MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); \
         if ((dwStyles[i] & (CCS_NOPARENTALIGN|CCS_NODIVIDER)) == CCS_NOPARENTALIGN) {\
@@ -853,7 +853,7 @@ static void test_resize(void)
         CCS_TOP | WS_BORDER, CCS_NOPARENTALIGN | CCS_NODIVIDER | WS_BORDER, CCS_NORESIZE | WS_BORDER,
         CCS_NOMOVEY | WS_BORDER};
 
-    const int styles_count = sizeof(dwStyles) / sizeof(dwStyles[0]);
+    const int styles_count = ARRAY_SIZE(dwStyles);
     int i;
 
     for (i = 0; i < styles_count; i++)
diff --git a/dlls/comctl32/tests/status.c b/dlls/comctl32/tests/status.c
index 2308974761..d78bd20262 100644
--- a/dlls/comctl32/tests/status.c
+++ b/dlls/comctl32/tests/status.c
@@ -127,7 +127,7 @@ static int CALLBACK check_height_font_enumproc(ENUMLOGFONTEXA *enumlf, NEWTEXTME
     if (type != TRUETYPE_FONTTYPE)
         facename = enumlf->elfLogFont.lfFaceName;
 
-    for (i = 0; i < sizeof(sizes)/sizeof(sizes[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(sizes); i++)
     {
         HFONT hFont;
         TEXTMETRICA tm;
diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c
index 432b89bd15..cca700cd18 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -152,8 +152,7 @@ static void init_test_message(UINT message, WPARAM wParam, LPARAM lParam, struct
 }
 
 #define run_test(info, expect_button, seq, context) \
-        run_test_(info, expect_button, seq, context, \
-                  sizeof(seq)/sizeof(seq[0]) - 1, __FILE__, __LINE__)
+        run_test_(info, expect_button, seq, context, ARRAY_SIZE(seq) - 1, __FILE__, __LINE__)
 
 static void run_test_(TASKDIALOGCONFIG *info, int expect_button, const struct message_info *test_messages,
     const char *context, int test_messages_len, const char *file, int line)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index 5fd6133e1f..41807258f4 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -387,7 +387,7 @@ static void basic_test(void)
         WS_CHILD | TBSTYLE_LIST,
         100,
         0, NULL, 0,
-        buttons, sizeof(buttons)/sizeof(buttons[0]),
+        buttons, ARRAY_SIZE(buttons),
         0, 0, 20, 16, sizeof(TBBUTTON));
     ok(hToolbar != NULL, "Toolbar creation\n");
     SendMessageA(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)"test\000");
@@ -1315,7 +1315,7 @@ static DWORD tbsize_alt_numtests = 0;
         compare(buttonCount, res->nButtons, "%d"); \
         for (i=0; i<min(buttonCount, res->nButtons); i++) { \
             ok(SendMessageA(hToolbar, TB_GETITEMRECT, i, (LPARAM)&rc) == 1, "TB_GETITEMRECT\n"); \
-            if (broken(tbsize_alt_numtests < sizeof(tbsize_alt_results)/sizeof(tbsize_alt_results[0]) && \
+            if (broken(tbsize_alt_numtests < ARRAY_SIZE(tbsize_alt_results) && \
                        EqualRect(&rc, &tbsize_alt_results[tbsize_alt_numtests].rcButton))) { \
                 win_skip("Alternate rect found\n"); \
                 tbsize_alt_numtests++; \
@@ -1939,13 +1939,13 @@ static void test_setrows(void)
         | CCS_NOMOVEY | CCS_TOP,
         0,
         0, NULL, 0,
-        buttons, sizeof(buttons)/sizeof(buttons[0]),
+        buttons, ARRAY_SIZE(buttons),
         20, 20, 0, 0, sizeof(TBBUTTON));
     ok(hToolbar != NULL, "Toolbar creation\n");
     ok(SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0) == 0, "TB_AUTOSIZE failed\n");
 
     /* test setting rows to each of 1-10 with bLarger true and false */
-    for (i=0; i<(sizeof(tbrows_results) / sizeof(tbrows_result_t)); i++) {
+    for (i=0; i<ARRAY_SIZE(tbrows_results); i++) {
         RECT rc;
         int rows;
 
@@ -2058,7 +2058,7 @@ static void test_get_set_style(void)
         WS_CHILD | TBSTYLE_LIST,
         100,
         0, NULL, 0,
-        buttons, sizeof(buttons)/sizeof(buttons[0]),
+        buttons, ARRAY_SIZE(buttons),
         0, 0, 20, 16, sizeof(TBBUTTON));
     ok(hToolbar != NULL, "Toolbar creation\n");
     SendMessageA(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)"test\000");
@@ -2276,7 +2276,7 @@ static void test_TB_GET_SET_EXTENDEDSTYLE(void)
         return;
     }
 
-    for (i = 0; i < sizeof(extended_style_test)/sizeof(extended_style_t); i++)
+    for (i = 0; i < ARRAY_SIZE(extended_style_test); i++)
     {
         ptr = &extended_style_test[i];
 
@@ -2397,7 +2397,7 @@ static void test_save(void)
     params.pszValueName = value;
 
     rebuild_toolbar_with_buttons( &wnd );
-    SendMessageW( wnd, TB_ADDBUTTONSW, sizeof(more_btns) / sizeof(more_btns[0]), (LPARAM)more_btns );
+    SendMessageW(wnd, TB_ADDBUTTONSW, ARRAY_SIZE(more_btns), (LPARAM)more_btns);
 
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
     res = SendMessageW( wnd, TB_SAVERESTOREW, TRUE, (LPARAM)&params );
@@ -2423,7 +2423,7 @@ static void test_save(void)
     ok( res, "restoring failed\n" );
     ok_sequence(sequences, PARENT_SEQ_INDEX, restore_parent_seq, "restore", FALSE);
     count = SendMessageW( wnd, TB_BUTTONCOUNT, 0, 0 );
-    ok( count == sizeof(expect_btns) / sizeof(expect_btns[0]), "got %d\n", count );
+    ok( count == ARRAY_SIZE(expect_btns), "got %d\n", count );
 
     for (i = 0; i < count; i++)
     {
diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c
index af95a569bb..0cb7afd688 100644
--- a/dlls/comctl32/tests/tooltips.c
+++ b/dlls/comctl32/tests/tooltips.c
@@ -183,7 +183,7 @@ static void test_customdraw(void) {
    GetCursorPos(&orig_pos);
 
    for (iterationNumber = 0;
-        iterationNumber < sizeof(expectedResults)/sizeof(expectedResults[0]);
+        iterationNumber < ARRAY_SIZE(expectedResults);
         iterationNumber++) {
 
        HWND parent, hwndTip;
@@ -821,7 +821,7 @@ static void test_longtextW(void)
     toolinfoW.hinst = GetModuleHandleW(NULL);
     toolinfoW.uFlags = 0;
     toolinfoW.uId = 0x1234ABCD;
-    MultiByteToWideChar(CP_ACP, 0, longtextA, -1, bufW, sizeof(bufW)/sizeof(bufW[0]));
+    MultiByteToWideChar(CP_ACP, 0, longtextA, -1, bufW, ARRAY_SIZE(bufW));
     lenW = lstrlenW(bufW);
     toolinfoW.lpszText = bufW;
     toolinfoW.lParam = 0xdeadbeef;
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 5cf397f3af..33edaaf4b4 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -527,7 +527,7 @@ static void test_callback(void)
     tvi.hItem = hRoot;
     tvi.mask = TVIF_TEXT;
     tvi.pszText = buf;
-    tvi.cchTextMax = sizeof(buf)/sizeof(buf[0]);
+    tvi.cchTextMax = ARRAY_SIZE(buf);
     ret = TreeView_GetItemA(hTree, &tvi);
     expect(TRUE, ret);
     ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Callback item text mismatch %s vs %s\n",
@@ -706,7 +706,7 @@ static void test_getitemtext(void)
     HWND hTree;
 
     CHAR szBuffer[80] = "Blah";
-    int nBufferSize = sizeof(szBuffer)/sizeof(CHAR);
+    int nBufferSize = ARRAY_SIZE(szBuffer);
 
     hTree = create_treeview_control(0);
     fill_tree(hTree);
@@ -1630,7 +1630,7 @@ static void test_itemedit(void)
     item.mask = TVIF_TEXT;
     item.hItem = hRoot;
     item.pszText = buffA;
-    item.cchTextMax = sizeof(buffA)/sizeof(CHAR);
+    item.cchTextMax = ARRAY_SIZE(buffA);
     r = SendMessageA(hTree, TVM_GETITEMA, 0, (LPARAM)&item);
     expect(TRUE, r);
     ok(!strcmp("x", buffA), "Expected item text to change\n");
@@ -1664,7 +1664,7 @@ static void test_itemedit(void)
     ok(IsWindow(edit), "Expected valid handle\n");
     g_beginedit_alter_text = FALSE;
 
-    GetWindowTextA(edit, buffA, sizeof(buffA)/sizeof(CHAR));
+    GetWindowTextA(edit, buffA, ARRAY_SIZE(buffA));
     ok(!strcmp(buffA, "<edittextaltered>"), "got string %s\n", buffA);
 
     DestroyWindow(hTree);
@@ -1991,7 +1991,7 @@ static void test_TVS_SINGLEEXPAND(void)
     SetWindowLongA(hTree, GWL_STYLE, GetWindowLongA(hTree, GWL_STYLE) | TVS_SINGLEEXPAND);
     /* to avoid painting related notifications */
     ShowWindow(hTree, SW_HIDE);
-    for (i = 0; i < sizeof(items)/sizeof(items[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(items); i++)
     {
         ins.hParent = items[i].parent ? *items[i].parent : TVI_ROOT;
         ins.hInsertAfter = TVI_FIRST;
@@ -2000,7 +2000,7 @@ static void test_TVS_SINGLEEXPAND(void)
         *items[i].handle = TreeView_InsertItemA(hTree, &ins);
     }
 
-    for (i = 0; i < sizeof(sequence_tests)/sizeof(sequence_tests[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(sequence_tests); i++)
     {
         flush_sequences(sequences, NUM_MSG_SEQUENCES);
         ret = SendMessageA(hTree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)(*sequence_tests[i].select));
@@ -2009,7 +2009,7 @@ static void test_TVS_SINGLEEXPAND(void)
         ok_sequence(sequences, PARENT_SEQ_INDEX, sequence_tests[i].sequence, context, FALSE);
     }
 
-    for (i = 0; i < sizeof(items)/sizeof(items[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(items); i++)
     {
         ret = SendMessageA(hTree, TVM_GETITEMSTATE, (WPARAM)(*items[i].handle), 0xFFFF);
         ok(ret == items[i].final_state, "singleexpand items[%d]: expected state 0x%x got 0x%x\n",
diff --git a/dlls/comctl32/tests/updown.c b/dlls/comctl32/tests/updown.c
index f549c41583..1f4e38f0eb 100644
--- a/dlls/comctl32/tests/updown.c
+++ b/dlls/comctl32/tests/updown.c
@@ -697,13 +697,13 @@ static void test_updown_base(void)
     r = SendMessageA(updown, UDM_SETPOS, 0, 10);
     expect(50, r);
 
-    GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
+    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
     ok(lstrcmpA(text, "10") == 0, "Expected '10', got '%s'\n", text);
 
     r = SendMessageA(updown, UDM_SETBASE, 16, 0);
     expect(10, r);
 
-    GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
+    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
     /* FIXME: currently hex output isn't properly formatted, but for this
        test only change from initial text matters */
     ok(lstrcmpA(text, "10") != 0, "Expected '0x000A', got '%s'\n", text);
@@ -837,20 +837,20 @@ static void test_UDS_SETBUDDYINT(void)
     style = GetWindowLongA(updown, GWL_STYLE);
     ok(style & UDS_SETBUDDYINT, "Expected UDS_SETBUDDY to be set\n");
     SendMessageA(updown, UDM_SETPOS, 0, 20);
-    GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
+    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
     ok(lstrlenA(text) == 0, "Expected empty string\n");
     DestroyWindow(updown);
 
     /* creating with UDS_SETBUDDYINT */
     updown = create_updown_control(UDS_SETBUDDYINT | UDS_ALIGNRIGHT, g_edit);
-    GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
+    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
     /* 50 is initial value here */
     ok(lstrcmpA(text, "50") == 0, "Expected '50', got '%s'\n", text);
     /* now remove style flag */
     style = GetWindowLongA(updown, GWL_STYLE);
     SetWindowLongA(updown, GWL_STYLE, style & ~UDS_SETBUDDYINT);
     SendMessageA(updown, UDM_SETPOS, 0, 20);
-    GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
+    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
     ok(lstrcmpA(text, "20") == 0, "Expected '20', got '%s'\n", text);
     /* set edit text directly, check position */
     strcpy(text, "10");
@@ -872,7 +872,7 @@ static void test_UDS_SETBUDDYINT(void)
     style = GetWindowLongA(updown, GWL_STYLE);
     SetWindowLongA(updown, GWL_STYLE, style | UDS_SETBUDDYINT);
     SendMessageA(updown, UDM_SETPOS, 0, 30);
-    GetWindowTextA(g_edit, text, sizeof(text)/sizeof(CHAR));
+    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
     ok(lstrcmpA(text, "30") == 0, "Expected '30', got '%s'\n", text);
     DestroyWindow(updown);
 }
-- 
2.14.4




More information about the wine-devel mailing list