Robert Wilhelm : scrrun/tests: Check file contents using ReadFile in CreateTextFile test.
Alexandre Julliard
julliard at winehq.org
Mon Dec 6 16:08:00 CST 2021
Module: wine
Branch: master
Commit: ed8048b9e70bde0b89bc4fef2cac825c5b70bdff
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ed8048b9e70bde0b89bc4fef2cac825c5b70bdff
Author: Robert Wilhelm <robert.wilhelm at gmx.net>
Date: Thu Dec 2 22:32:24 2021 +0100
scrrun/tests: Check file contents using ReadFile in CreateTextFile test.
This is less fragile then former MultiByteToWideChar method because
second byte of BOM (0xfe) is LeadByte in Asian locales.
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 | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index 91729bb047f..0fb332ff963 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -1468,6 +1468,7 @@ static void test_CreateTextFile(void)
HANDLE file;
HRESULT hr;
BOOL ret;
+ DWORD r;
get_temp_filepath(testfileW, pathW, dirW);
@@ -1517,18 +1518,15 @@ static void test_CreateTextFile(void)
ok(hr == S_OK, "got 0x%08x\n", hr);
ITextStream_Release(stream);
- /* File was created in Unicode mode, it contains 0xfffe BOM. Opening it in non-Unicode mode
- treats BOM like a valuable data with appropriate CP_ACP -> WCHAR conversion. */
- buffW[0] = 0;
- MultiByteToWideChar(CP_ACP, 0, utf16bom, -1, buffW, ARRAY_SIZE(buffW));
+ /* check contents */
+ file = CreateFileW(pathW, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ ok(file != INVALID_HANDLE_VALUE, "got %p\n", file);
+ r = 0;
+ ret = ReadFile(file, buffW, sizeof(buffW), &r, NULL);
+ ok(ret && r == 2, "read %d, got %d, %d\n", r, ret, GetLastError());
- hr = IFileSystem3_OpenTextFile(fs3, nameW, ForReading, VARIANT_FALSE, TristateFalse, &stream);
- ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = ITextStream_ReadAll(stream, &str);
- ok(hr == S_FALSE || broken(hr == S_OK) /* win2k */, "got 0x%08x\n", hr);
- ok(!lstrcmpW(str, buffW), "got %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(buffW));
- SysFreeString(str);
- ITextStream_Release(stream);
+ ok( buffW[0] == 0xfeff, "got %04x\n", buffW[0] );
+ CloseHandle(file);
DeleteFileW(nameW);
RemoveDirectoryW(dirW);
More information about the wine-cvs
mailing list