[PATCH 2/3] riched20: Refactor tests testing VK_RETURN
Fabian Maurer
dark.shadow4 at web.de
Sun Dec 9 16:51:56 CST 2018
This is basically a no-op to make the tests and the following
additions simpler
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
dlls/riched20/tests/editor.c | 51 ++++++++++++++----------------------
dlls/riched32/tests/editor.c | 51 ++++++++++++++----------------------
2 files changed, 40 insertions(+), 62 deletions(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 035869e134..5c2df7f86c 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -8259,6 +8259,14 @@ static void test_EM_FINDWORDBREAK_A(void)
DestroyWindow(hwndRichEdit);
}
+static void format_test_result(char *target, const char *src)
+{
+ int i;
+ for (i = 0; i < strlen(src); i++)
+ sprintf(target + 2*i, "%02x", src[i] & 0xFF);
+ target[2*i] = 0;
+}
+
/*
* This test attempts to show the effect of enter on a richedit
* control v1.0 inserts CRLF whereas for higher versions it only
@@ -8285,13 +8293,12 @@ static void test_enter(void)
char expectedbuf[1024];
char resultbuf[1024];
HWND hwndRichEdit = new_richedit(NULL);
- UINT i,j;
+ UINT i;
+ char buf[1024] = {0};
+ GETTEXTEX getText = {sizeof(buf)};
+ LRESULT result;
for (i = 0; i < ARRAY_SIZE(testenteritems); i++) {
-
- char buf[1024] = {0};
- LRESULT result;
- GETTEXTEX getText;
const char *expected;
/* Set the text to the initial text */
@@ -8307,12 +8314,8 @@ static void test_enter(void)
result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buf);
expected = testenteritems[i].expectedwmtext;
- resultbuf[0]=0x00;
- for (j = 0; j < (UINT)result; j++)
- sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF);
- expectedbuf[0] = '\0';
- for (j = 0; j < strlen(expected); j++)
- sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, expected);
result = strcmp(expected, buf);
ok (result == 0,
@@ -8320,21 +8323,14 @@ static void test_enter(void)
i, resultbuf, expectedbuf);
/* 2. Retrieve with EM_GETTEXTEX, GT_DEFAULT */
- getText.cb = sizeof(buf);
getText.flags = GT_DEFAULT;
- getText.codepage = CP_ACP;
- getText.lpDefaultChar = NULL;
- getText.lpUsedDefChar = NULL;
+ getText.codepage = CP_ACP;
buf[0] = 0x00;
result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);
expected = testenteritems[i].expectedemtext;
- resultbuf[0]=0x00;
- for (j = 0; j < (UINT)result; j++)
- sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF);
- expectedbuf[0] = '\0';
- for (j = 0; j < strlen(expected); j++)
- sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, expected);
result = strcmp(expected, buf);
ok (result == 0,
@@ -8342,21 +8338,14 @@ static void test_enter(void)
i, resultbuf, expectedbuf);
/* 3. Retrieve with EM_GETTEXTEX, GT_USECRLF */
- getText.cb = sizeof(buf);
getText.flags = GT_USECRLF;
- getText.codepage = CP_ACP;
- getText.lpDefaultChar = NULL;
- getText.lpUsedDefChar = NULL;
+ getText.codepage = CP_ACP;
buf[0] = 0x00;
result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);
expected = testenteritems[i].expectedemtextcrlf;
- resultbuf[0]=0x00;
- for (j = 0; j < (UINT)result; j++)
- sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF);
- expectedbuf[0] = '\0';
- for (j = 0; j < strlen(expected); j++)
- sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, expected);
result = strcmp(expected, buf);
ok (result == 0,
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index 7751d2b402..64ad0f3029 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -1149,6 +1149,14 @@ static void simulate_typing_characters(HWND hwnd, const char* szChars)
}
}
+static void format_test_result(char *target, const char *src)
+{
+ int i;
+ for (i = 0; i < strlen(src); i++)
+ sprintf(target + 2*i, "%02x", src[i] & 0xFF);
+ target[2*i] = 0;
+}
+
/*
* This test attempts to show the effect of enter on a richedit
* control v1.0 inserts CRLF whereas for higher versions it only
@@ -1173,13 +1181,12 @@ static void test_enter(void)
char expectedbuf[1024];
char resultbuf[1024];
HWND hwndRichEdit = new_richedit(NULL);
- UINT i,j;
+ UINT i;
+ char buf[1024] = {0};
+ GETTEXTEX getText = {sizeof(buf)};
+ LRESULT result;
for (i = 0; i < ARRAY_SIZE(testenteritems); i++) {
-
- char buf[1024] = {0};
- LRESULT result;
- GETTEXTEX getText;
const char *expected;
/* Set the text to the initial text */
@@ -1195,12 +1202,8 @@ static void test_enter(void)
result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buf);
expected = testenteritems[i].expectedtext;
- resultbuf[0]=0x00;
- for (j = 0; j < (UINT)result; j++)
- sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF);
- expectedbuf[0] = '\0';
- for (j = 0; j < strlen(expected); j++)
- sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, expected);
result = strcmp(expected, buf);
ok (result == 0,
@@ -1208,21 +1211,14 @@ static void test_enter(void)
i, resultbuf, expectedbuf);
/* 2. Retrieve with EM_GETTEXTEX, GT_DEFAULT */
- getText.cb = sizeof(buf);
getText.flags = GT_DEFAULT;
- getText.codepage = CP_ACP;
- getText.lpDefaultChar = NULL;
- getText.lpUsedDefChar = NULL;
+ getText.codepage = CP_ACP;
buf[0] = 0x00;
result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);
expected = testenteritems[i].expectedtext;
- resultbuf[0]=0x00;
- for (j = 0; j < (UINT)result; j++)
- sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF);
- expectedbuf[0] = '\0';
- for (j = 0; j < strlen(expected); j++)
- sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, expected);
result = strcmp(expected, buf);
ok (result == 0 || broken(buf[0]==0x00 /* WinNT4 */),
@@ -1230,21 +1226,14 @@ static void test_enter(void)
i, resultbuf, expectedbuf);
/* 3. Retrieve with EM_GETTEXTEX, GT_USECRLF */
- getText.cb = sizeof(buf);
getText.flags = GT_USECRLF;
- getText.codepage = CP_ACP;
- getText.lpDefaultChar = NULL;
- getText.lpUsedDefChar = NULL;
+ getText.codepage = CP_ACP;
buf[0] = 0x00;
result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);
expected = testenteritems[i].expectedtext;
- resultbuf[0]=0x00;
- for (j = 0; j < (UINT)result; j++)
- sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF);
- expectedbuf[0] = '\0';
- for (j = 0; j < strlen(expected); j++)
- sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF);
+ format_test_result(resultbuf, buf);
+ format_test_result(expectedbuf, expected);
result = strcmp(expected, buf);
ok (result == 0 || broken(buf[0]==0x00 /* WinNT4 */),
--
2.19.2
More information about the wine-devel
mailing list