[PATCH] msvcrt/tests: Add a test for reading ascii files (without bom) opened with _wsopen_dispatch as unicode

Martin Storsjo martin at martin.st
Tue Jan 26 16:05:01 CST 2021


The added test points out a regression since
b0ab1b76029eaface724a28483fe8b0ea36029dc, which is noticed when
running MSVC 2010 in wine.

Signed-off-by: Martin Storsjo <martin at martin.st>
---
 dlls/msvcrt/tests/file.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index ecf99e38b0e..9ad91b578f5 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -1039,6 +1039,37 @@ static void test_fgetwc_unicode(void)
     ch = fgetwc(tempfh);
     ok(ch == WEOF, "got %04hx, expected WEOF (unicode)\n", ch);
     fclose(tempfh);
+
+    // Test missing bom
+    tempfh = fopen(tempfile, "wb");
+    ok(tempfh != NULL, "can't open tempfile\n");
+    fwrite("1234", 1, 4, tempfh);
+    fclose(tempfh);
+
+    tempfh = fopen(tempfile, "rt, ccs=UTF-8");
+    ok(tempfh != NULL, "can't open tempfile\n");
+    for (i = 0; i < 4; i++)
+    {
+        ch = fgetwc(tempfh);
+        ok(ch == '1' + i,
+           "got %04hx, expected %04x\n", ch, '1' + i);
+    }
+    ch = fgetwc(tempfh);
+    ok(ch == WEOF, "got %04hx, expected WEOF (utf8)\n", ch);
+    fclose(tempfh);
+
+    tempfh = fopen(tempfile, "rt, ccs=utf-16le");
+    ok(tempfh != NULL, "can't open tempfile\n");
+    for (i = 0; i < 4; i++)
+    {
+        ch = fgetwc(tempfh);
+        todo_wine ok(ch == '1' + i,
+           "got %04hx, expected %04x\n", ch, '1' + i);
+    }
+    ch = fgetwc(tempfh);
+    ok(ch == WEOF, "got %04hx, expected WEOF (utf8)\n", ch);
+    fclose(tempfh);
+
     unlink(temppath);
 }
 
-- 
2.25.1




More information about the wine-devel mailing list