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

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

parent ebfe62fc
...@@ -340,14 +340,12 @@ static void test_EM_FINDTEXT(BOOL unicode) ...@@ -340,14 +340,12 @@ static void test_EM_FINDTEXT(BOOL unicode)
hwndRichEdit = new_richedit(NULL); hwndRichEdit = new_richedit(NULL);
/* Empty rich edit control */ /* Empty rich edit control */
run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests, run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests, ARRAY_SIZE(find_tests), unicode);
sizeof(find_tests)/sizeof(struct find_s), unicode);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)haystack); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)haystack);
/* Haystack text */ /* Haystack text */
run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2, run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2, ARRAY_SIZE(find_tests2), unicode);
sizeof(find_tests2)/sizeof(struct find_s), unicode);
/* Setting a format on an arbitrary range should have no effect in search /* Setting a format on an arbitrary range should have no effect in search
results. This tests correct offset reporting across runs. */ results. This tests correct offset reporting across runs. */
...@@ -359,8 +357,7 @@ static void test_EM_FINDTEXT(BOOL unicode) ...@@ -359,8 +357,7 @@ static void test_EM_FINDTEXT(BOOL unicode)
SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
/* Haystack text, again */ /* Haystack text, again */
run_tests_EM_FINDTEXT(hwndRichEdit, "2-bis", find_tests2, run_tests_EM_FINDTEXT(hwndRichEdit, "2-bis", find_tests2, ARRAY_SIZE(find_tests2), unicode);
sizeof(find_tests2)/sizeof(struct find_s), unicode);
/* Yet another range */ /* Yet another range */
cf2.dwMask = CFM_BOLD | cf2.dwMask; cf2.dwMask = CFM_BOLD | cf2.dwMask;
...@@ -369,8 +366,7 @@ static void test_EM_FINDTEXT(BOOL unicode) ...@@ -369,8 +366,7 @@ static void test_EM_FINDTEXT(BOOL unicode)
SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
/* Haystack text, again */ /* Haystack text, again */
run_tests_EM_FINDTEXT(hwndRichEdit, "2-bisbis", find_tests2, run_tests_EM_FINDTEXT(hwndRichEdit, "2-bisbis", find_tests2, ARRAY_SIZE(find_tests2), unicode);
sizeof(find_tests2)/sizeof(struct find_s), unicode);
DestroyWindow(hwndRichEdit); DestroyWindow(hwndRichEdit);
} }
...@@ -404,7 +400,7 @@ static void test_EM_GETLINE(void) ...@@ -404,7 +400,7 @@ static void test_EM_GETLINE(void)
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text);
memset(origdest, 0xBB, nBuf); memset(origdest, 0xBB, nBuf);
for (i = 0; i < sizeof(gl)/sizeof(struct getline_s); i++) for (i = 0; i < ARRAY_SIZE(gl); i++)
{ {
int nCopied; int nCopied;
int expected_nCopied = min(gl[i].buffer_len, strlen(gl[i].text)); int expected_nCopied = min(gl[i].buffer_len, strlen(gl[i].text));
...@@ -509,7 +505,7 @@ static void test_EM_LINELENGTH(void) ...@@ -509,7 +505,7 @@ static void test_EM_LINELENGTH(void)
{15, 4}, /* Line 3: |wine */ {15, 4}, /* Line 3: |wine */
}; };
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
for (i = 0; i < sizeof(offset_test1)/sizeof(offset_test1[0]); i++) { for (i = 0; i < ARRAY_SIZE(offset_test1); i++) {
result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test1[i][0], 0); result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test1[i][0], 0);
ok(result == offset_test1[i][1], "Length of line at offset %d is %ld, expected %d\n", ok(result == offset_test1[i][1], "Length of line at offset %d is %ld, expected %d\n",
offset_test1[i][0], result, offset_test1[i][1]); offset_test1[i][0], result, offset_test1[i][1]);
...@@ -2049,7 +2045,7 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2049,7 +2045,7 @@ static void test_EM_AUTOURLDETECT(void)
urlRet=SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, (WPARAM)"h", (LPARAM)"h"); urlRet=SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, (WPARAM)"h", (LPARAM)"h");
ok(urlRet==E_INVALIDARG, "Bad wParam2: urlRet is: %d\n", urlRet); ok(urlRet==E_INVALIDARG, "Bad wParam2: urlRet is: %d\n", urlRet);
/* for each url, check the text to see if CFE_LINK effect is present */ /* for each url, check the text to see if CFE_LINK effect is present */
for (i = 0; i < sizeof(urls)/sizeof(struct urls_s); i++) { for (i = 0; i < ARRAY_SIZE(urls); i++) {
SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, FALSE, 0); SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, FALSE, 0);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)urls[i].text); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)urls[i].text);
...@@ -2063,10 +2059,10 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2063,10 +2059,10 @@ static void test_EM_AUTOURLDETECT(void)
DestroyWindow(hwndRichEdit); DestroyWindow(hwndRichEdit);
/* Test detection of URLs within normal text - WM_SETTEXT case. */ /* Test detection of URLs within normal text - WM_SETTEXT case. */
for (i = 0; i < sizeof(urls)/sizeof(struct urls_s); i++) { for (i = 0; i < ARRAY_SIZE(urls); i++) {
hwndRichEdit = new_richedit(parent); hwndRichEdit = new_richedit(parent);
for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos; char * at_pos;
int at_offset; int at_offset;
int end_offset; int end_offset;
...@@ -2117,7 +2113,7 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2117,7 +2113,7 @@ static void test_EM_AUTOURLDETECT(void)
} }
} }
for (j = 0; j < sizeof(templates_non_delim) / sizeof(const char *); j++) { for (j = 0; j < ARRAY_SIZE(templates_non_delim); j++) {
char * at_pos; char * at_pos;
int at_offset; int at_offset;
int end_offset; int end_offset;
...@@ -2158,7 +2154,7 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2158,7 +2154,7 @@ static void test_EM_AUTOURLDETECT(void)
} }
} }
for (j = 0; j < sizeof(templates_xten_delim) / sizeof(const char *); j++) { for (j = 0; j < ARRAY_SIZE(templates_xten_delim); j++) {
char * at_pos; char * at_pos;
int at_offset; int at_offset;
int end_offset; int end_offset;
...@@ -2213,7 +2209,7 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2213,7 +2209,7 @@ static void test_EM_AUTOURLDETECT(void)
} }
} }
for (j = 0; j < sizeof(templates_neutral_delim) / sizeof(const char *); j++) { for (j = 0; j < ARRAY_SIZE(templates_neutral_delim); j++) {
char * at_pos, * end_pos; char * at_pos, * end_pos;
int at_offset; int at_offset;
int end_offset; int end_offset;
...@@ -2421,7 +2417,7 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2421,7 +2417,7 @@ static void test_EM_AUTOURLDETECT(void)
*/ */
/* Set entire text in one go, like WM_SETTEXT */ /* Set entire text in one go, like WM_SETTEXT */
for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos; char * at_pos;
int at_offset; int at_offset;
int end_offset; int end_offset;
...@@ -2476,7 +2472,7 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2476,7 +2472,7 @@ static void test_EM_AUTOURLDETECT(void)
} }
/* Set selection with X to the URL */ /* Set selection with X to the URL */
for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos; char * at_pos;
int at_offset; int at_offset;
int end_offset; int end_offset;
...@@ -2530,7 +2526,7 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2530,7 +2526,7 @@ static void test_EM_AUTOURLDETECT(void)
} }
/* Set selection with X to the first character of the URL, then the rest */ /* Set selection with X to the first character of the URL, then the rest */
for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos; char * at_pos;
int at_offset; int at_offset;
int end_offset; int end_offset;
...@@ -2598,7 +2594,7 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2598,7 +2594,7 @@ static void test_EM_AUTOURLDETECT(void)
hwndRichEdit = new_richedit(parent); hwndRichEdit = new_richedit(parent);
/* Set selection with X to the URL */ /* Set selection with X to the URL */
for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos; char * at_pos;
int at_offset; int at_offset;
int end_offset; int end_offset;
...@@ -2649,7 +2645,7 @@ static void test_EM_AUTOURLDETECT(void) ...@@ -2649,7 +2645,7 @@ static void test_EM_AUTOURLDETECT(void)
} }
/* Set selection with X to the first character of the URL, then the rest */ /* Set selection with X to the first character of the URL, then the rest */
for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos; char * at_pos;
int at_offset; int at_offset;
int end_offset; int end_offset;
...@@ -4933,7 +4929,7 @@ static void test_EM_EXSETSEL(void) ...@@ -4933,7 +4929,7 @@ static void test_EM_EXSETSEL(void)
{ {
HWND hwndRichEdit = new_richedit(NULL); HWND hwndRichEdit = new_richedit(NULL);
int i; int i;
const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s); const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */ /* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection"); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
...@@ -4988,7 +4984,7 @@ static void test_EM_SETSEL(void) ...@@ -4988,7 +4984,7 @@ static void test_EM_SETSEL(void)
char buffA[32] = {0}; char buffA[32] = {0};
HWND hwndRichEdit = new_richedit(NULL); HWND hwndRichEdit = new_richedit(NULL);
int i; int i;
const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s); const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */ /* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection"); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
...@@ -5623,7 +5619,7 @@ static void test_EM_FORMATRANGE(void) ...@@ -5623,7 +5619,7 @@ static void test_EM_FORMATRANGE(void)
SendMessageA(hwndRichEdit, EM_FORMATRANGE, FALSE, 0); SendMessageA(hwndRichEdit, EM_FORMATRANGE, FALSE, 0);
for (i = 0; i < sizeof(fmtstrings)/sizeof(fmtstrings[0]); i++) for (i = 0; i < ARRAY_SIZE(fmtstrings); i++)
{ {
GETTEXTLENGTHEX gtl; GETTEXTLENGTHEX gtl;
SIZE stringsize; SIZE stringsize;
...@@ -5831,7 +5827,7 @@ static void test_EM_STREAMIN(void) ...@@ -5831,7 +5827,7 @@ static void test_EM_STREAMIN(void)
}; };
const WCHAR streamText5[] = { 'T', 'e', 's', 't', 'S', 'o', 'm', 'e', 'T', 'e', 'x', 't' }; const WCHAR streamText5[] = { 'T', 'e', 's', 't', 'S', 'o', 'm', 'e', 'T', 'e', 'x', 't' };
int length5 = sizeof(streamText5) / sizeof(WCHAR); int length5 = ARRAY_SIZE(streamText5);
struct StringWithLength cookieForStream5 = { struct StringWithLength cookieForStream5 = {
sizeof(streamText5), sizeof(streamText5),
(char *)streamText5, (char *)streamText5,
...@@ -6868,7 +6864,7 @@ static void test_EN_LINK(void) ...@@ -6868,7 +6864,7 @@ static void test_EN_LINK(void)
GetCursorPos(&orig_cursor_pos); GetCursorPos(&orig_cursor_pos);
SetCursorPos(0, 0); SetCursorPos(0, 0);
for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++) for (i = 0; i < ARRAY_SIZE(link_notify_tests); i++)
{ {
link_notify_test("cursor position simulated", i, hwnd, parent, link_notify_test("cursor position simulated", i, hwnd, parent,
link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam, link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam,
...@@ -6878,7 +6874,7 @@ static void test_EN_LINK(void) ...@@ -6878,7 +6874,7 @@ static void test_EN_LINK(void)
ClientToScreen(hwnd, &cursor_screen_pos); ClientToScreen(hwnd, &cursor_screen_pos);
SetCursorPos(cursor_screen_pos.x, cursor_screen_pos.y); SetCursorPos(cursor_screen_pos.x, cursor_screen_pos.y);
for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++) for (i = 0; i < ARRAY_SIZE(link_notify_tests); i++)
{ {
link_notify_test("cursor position set", i, hwnd, parent, link_notify_test("cursor position set", i, hwnd, parent,
link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam, link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam,
...@@ -8178,7 +8174,7 @@ static void test_EM_FINDWORDBREAK_W(void) ...@@ -8178,7 +8174,7 @@ static void test_EM_FINDWORDBREAK_W(void)
int i; int i;
HWND hwndRichEdit = new_richeditW(NULL); HWND hwndRichEdit = new_richeditW(NULL);
ok(IsWindowUnicode(hwndRichEdit), "window should be unicode\n"); ok(IsWindowUnicode(hwndRichEdit), "window should be unicode\n");
for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++) for (i = 0; i < ARRAY_SIZE(delimiter_tests); i++)
{ {
WCHAR wbuf[2]; WCHAR wbuf[2];
int result; int result;
...@@ -8212,7 +8208,7 @@ static void test_EM_FINDWORDBREAK_A(void) ...@@ -8212,7 +8208,7 @@ static void test_EM_FINDWORDBREAK_A(void)
HWND hwndRichEdit = new_richedit(NULL); HWND hwndRichEdit = new_richedit(NULL);
ok(!IsWindowUnicode(hwndRichEdit), "window should not be unicode\n"); ok(!IsWindowUnicode(hwndRichEdit), "window should not be unicode\n");
for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++) for (i = 0; i < ARRAY_SIZE(delimiter_tests); i++)
{ {
int result; int result;
char buf[2]; char buf[2];
...@@ -8256,7 +8252,7 @@ static void test_enter(void) ...@@ -8256,7 +8252,7 @@ static void test_enter(void)
HWND hwndRichEdit = new_richedit(NULL); HWND hwndRichEdit = new_richedit(NULL);
UINT i,j; UINT i,j;
for (i = 0; i < sizeof(testenteritems)/sizeof(testenteritems[0]); i++) { for (i = 0; i < ARRAY_SIZE(testenteritems); i++) {
char buf[1024] = {0}; char buf[1024] = {0};
LRESULT result; LRESULT result;
...@@ -8538,7 +8534,7 @@ static void test_alignment_style(void) ...@@ -8538,7 +8534,7 @@ static void test_alignment_style(void)
EDITSTREAM es; EDITSTREAM es;
int i; int i;
for (i = 0; i < sizeof(align_style) / sizeof(align_style[0]); i++) for (i = 0; i < ARRAY_SIZE(align_style); i++)
{ {
DWORD dwStyle, new_align; DWORD dwStyle, new_align;
...@@ -8646,8 +8642,8 @@ static void test_rtf(void) ...@@ -8646,8 +8642,8 @@ static void test_rtf(void)
result = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es ); result = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es );
ok( result == 11, "got %ld\n", result ); ok( result == 11, "got %ld\n", result );
result = SendMessageW( edit, WM_GETTEXT, sizeof(buf)/sizeof(buf[0]), (LPARAM)buf ); result = SendMessageW( edit, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf );
ok( result == sizeof(expect_specials)/sizeof(expect_specials[0]), "got %ld\n", result ); ok( result == ARRAY_SIZE(expect_specials), "got %ld\n", result );
ok( !memcmp( buf, expect_specials, sizeof(expect_specials) ), "got %s\n", wine_dbgstr_w(buf) ); ok( !memcmp( buf, expect_specials, sizeof(expect_specials) ), "got %s\n", wine_dbgstr_w(buf) );
/* Show that \rtlpar propagates to the second paragraph and is /* Show that \rtlpar propagates to the second paragraph and is
......
...@@ -247,8 +247,8 @@ static void test_ITextDocument_Open(void) ...@@ -247,8 +247,8 @@ static void test_ITextDocument_Open(void)
tomReadOnly|tomShareDenyWrite, tomReadOnly|tomShareDenyRead tomReadOnly|tomShareDenyWrite, tomReadOnly|tomShareDenyRead
}; };
int tomNumSingle = sizeof(tomConstantsSingle)/sizeof(tomConstantsSingle[0]); int tomNumSingle = ARRAY_SIZE(tomConstantsSingle);
int tomNumMulti = sizeof(tomConstantsMulti)/sizeof(tomConstantsMulti[0]); int tomNumMulti = ARRAY_SIZE(tomConstantsMulti);
int i; int i;
V_VT(&testfile) = VT_BSTR; V_VT(&testfile) = VT_BSTR;
......
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