Paul Vriens : riched32/tests: Cater for differences between platforms.
Alexandre Julliard
julliard at winehq.org
Fri Jun 12 10:41:10 CDT 2009
Module: wine
Branch: master
Commit: 45629dc050f46988c23ded35ad18bbd8c63e4e65
URL: http://source.winehq.org/git/wine.git/?a=commit;h=45629dc050f46988c23ded35ad18bbd8c63e4e65
Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date: Fri Jun 12 15:05:15 2009 +0200
riched32/tests: Cater for differences between platforms.
---
dlls/riched32/tests/editor.c | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index c29d6d7..0d853a6 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -348,11 +348,12 @@ static const struct getline_s {
int line;
size_t buffer_len;
const char *text;
+ const char *broken_text;
} gl[] = {
- {0, 10, "foo bar\r\n"},
- {1, 10, "\r"},
- {2, 10, "\r\r\n"},
- {3, 10, "bar\n"},
+ {0, 10, "foo bar\r\n", "foo bar\r\n"},
+ {1, 10, "\r", "\r\r\r\n"},
+ {2, 10, "\r\r\n", "bar\n"},
+ {3, 10, "bar\n", "\r\n"},
{4, 10, "\r\n"},
/* Buffer smaller than line length */
@@ -367,19 +368,40 @@ static void test_EM_GETLINE(void)
HWND hwndRichEdit = new_richedit(NULL);
static const int nBuf = 1024;
char dest[1024], origdest[1024];
+ LRESULT linecount;
const char text[] = "foo bar\r\n"
"\r"
"\r\r\n"
"bar\n";
+ BOOL broken_os = FALSE;
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
+ linecount = SendMessage(hwndRichEdit, EM_GETLINECOUNT, 0, 0);
+ if (linecount == 4)
+ {
+ broken_os = TRUE;
+ win_skip("Win9x, WinME and NT4 handle '\\r only' differently\n");
+ }
memset(origdest, 0xBB, nBuf);
for (i = 0; i < sizeof(gl)/sizeof(struct getline_s); i++)
{
- int nCopied;
- int expected_nCopied = min(gl[i].buffer_len, strlen(gl[i].text));
- int expected_bytes_written = min(gl[i].buffer_len, strlen(gl[i].text) + 1);
+ int nCopied, expected_nCopied, expected_bytes_written;
+ char gl_text[1024];
+
+ if (gl[i].line >= linecount)
+ continue; /* Win9x, WinME and NT4 */
+
+ if (broken_os && gl[i].broken_text)
+ /* Win9x, WinME and NT4 */
+ strcpy(gl_text, gl[i].broken_text);
+ else
+ strcpy(gl_text, gl[i].text);
+
+ expected_nCopied = min(gl[i].buffer_len, strlen(gl_text));
+ /* Cater for the fact that Win9x, WinME and NT4 don't append the '\0' */
+ expected_bytes_written = min(gl[i].buffer_len, strlen(gl_text) + (broken_os ? 0 : 1));
+
memset(dest, 0xBB, nBuf);
*(WORD *) dest = gl[i].buffer_len;
@@ -393,11 +415,11 @@ static void test_EM_GETLINE(void)
ok(!dest[0] && !dest[1] && !strncmp(dest+2, origdest+2, nBuf-2),
"buffer_len=0\n");
else if (gl[i].buffer_len == 1)
- ok(dest[0] == gl[i].text[0] && !dest[1] &&
+ ok(dest[0] == gl_text[0] && !dest[1] &&
!strncmp(dest+2, origdest+2, nBuf-2), "buffer_len=1\n");
else
{
- ok(!strncmp(dest, gl[i].text, expected_bytes_written),
+ ok(!strncmp(dest, gl_text, expected_bytes_written),
"%d: expected_bytes_written=%d\n", i, expected_bytes_written);
ok(!strncmp(dest + expected_bytes_written, origdest
+ expected_bytes_written, nBuf - expected_bytes_written),
More information about the wine-cvs
mailing list