[PATCH 3/3] scrrun: use more context for MultiByteToWideChar in Read test.

Robert Wilhelm robert.wilhelm at gmx.net
Thu Dec 2 15:32:46 CST 2021


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>
---
 dlls/scrrun/tests/filesystem.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index 8dc08d7487e..376cad2d4ed 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -1820,8 +1820,10 @@ static void test_ReadAll(void)

 static void test_Read(void)
 {
+    static const WCHAR firstlineW[] = L"first";
     static const WCHAR secondlineW[] = L"second";
     WCHAR pathW[MAX_PATH], dirW[MAX_PATH], buffW[500];
+    char buffA[MAX_PATH];
     ITextStream *stream;
     BSTR nameW;
     HRESULT hr;
@@ -1838,8 +1840,10 @@ static void test_Read(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);
@@ -1884,9 +1888,10 @@ static void test_Read(void)
     ok(hr == S_OK, "got 0x%08x\n", hr);

     buffW[0] = 0;
-    MultiByteToWideChar(CP_ACP, 0, utf16bom, -1, buffW, ARRAY_SIZE(buffW));
-
-    ok(!lstrcmpW(str, buffW), "got %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(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, expected %s, %d\n", wine_dbgstr_w(str), wine_dbgstr_w(buffW), SysStringLen(str));
     ok(SysStringLen(str) == 2, "got %d\n", SysStringLen(str));
     SysFreeString(str);
     ITextStream_Release(stream);
@@ -1895,7 +1900,7 @@ static void test_Read(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");
@@ -1941,7 +1946,7 @@ static void test_Read(void)
     hr = IFileSystem3_OpenTextFile(fs3, nameW, ForReading, VARIANT_FALSE, TristateUseDefault, &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");
--
2.31.1






More information about the wine-devel mailing list