Robert Wilhelm : scrrun/tests: Use more context for MultiByteToWideChar in ReadAll test.

Alexandre Julliard julliard at winehq.org
Mon Dec 6 16:08:00 CST 2021


Module: wine
Branch: master
Commit: a818801b369bd0e2e54556355179df7f940edb0b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a818801b369bd0e2e54556355179df7f940edb0b

Author: Robert Wilhelm <robert.wilhelm at gmx.net>
Date:   Thu Dec  2 22:32:39 2021 +0100

scrrun/tests: Use more context for MultiByteToWideChar in ReadAll test.

Second byte of BOM (0xfe) is LeadByte in Asian locales. Therefore chars after BOM matter.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=39244
Signed-off-by: Robert Wilhelm <robert.wilhelm at gmx.net>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/scrrun/tests/filesystem.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index 0fb332ff963..65bb83dfd7e 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -1684,9 +1684,11 @@ static void test_WriteLine(void)
 
 static void test_ReadAll(void)
 {
+    static const WCHAR firstlineW[] = L"first";
     static const WCHAR secondlineW[] = L"second";
     static const WCHAR aW[] = L"A";
     WCHAR pathW[MAX_PATH], dirW[MAX_PATH], buffW[500];
+    char buffA[MAX_PATH];
     ITextStream *stream;
     BSTR nameW;
     HRESULT hr;
@@ -1703,8 +1705,10 @@ static void test_ReadAll(void)
     hr = IFileSystem3_CreateTextFile(fs3, nameW, VARIANT_FALSE, VARIANT_TRUE, &stream);
     ok(hr == S_OK, "got 0x%08x\n", hr);
 
-    hr = ITextStream_WriteLine(stream, nameW);
+    str = SysAllocString(firstlineW);
+    hr = ITextStream_WriteLine(stream, str);
     ok(hr == S_OK, "got 0x%08x\n", hr);
+    SysFreeString(str);
 
     str = SysAllocString(secondlineW);
     hr = ITextStream_WriteLine(stream, str);
@@ -1732,7 +1736,9 @@ static void test_ReadAll(void)
     hr = ITextStream_ReadAll(stream, &str);
     ok(hr == S_FALSE || broken(hr == S_OK) /* win2k */, "got 0x%08x\n", hr);
     buffW[0] = 0;
-    MultiByteToWideChar(CP_ACP, 0, utf16bom, -1, buffW, ARRAY_SIZE(buffW));
+    lstrcpyA(buffA, utf16bom);
+    lstrcatA(buffA, "first");
+    MultiByteToWideChar(CP_ACP, 0, buffA, -1, buffW, ARRAY_SIZE(buffW));
     ok(str[0] == buffW[0] && str[1] == buffW[1], "got %s, %d\n", wine_dbgstr_w(str), SysStringLen(str));
     SysFreeString(str);
     ITextStream_Release(stream);
@@ -1741,7 +1747,7 @@ static void test_ReadAll(void)
     hr = IFileSystem3_OpenTextFile(fs3, nameW, ForReading, VARIANT_FALSE, TristateTrue, &stream);
     ok(hr == S_OK, "got 0x%08x\n", hr);
 
-    lstrcpyW(buffW, nameW);
+    lstrcpyW(buffW, firstlineW);
     lstrcatW(buffW, L"\r\n");
     lstrcatW(buffW, secondlineW);
     lstrcatW(buffW, L"\r\n");
@@ -1772,7 +1778,7 @@ static void test_ReadAll(void)
     hr = ITextStream_ReadLine(stream, &str);
     ok(hr == S_OK, "got 0x%08x\n", hr);
     ok(str != NULL, "got %p\n", str);
-    ok(!wcscmp(str, nameW), "got %s\n", wine_dbgstr_w(str));
+    ok(!wcscmp(str, firstlineW), "got %s\n", wine_dbgstr_w(str));
     SysFreeString(str);
 
     lstrcpyW(buffW, secondlineW);




More information about the wine-cvs mailing list