Francois Gouget : kernel32/tests: Test GetTimeFormatA()'s Unicode to ANSI conversion.

Alexandre Julliard julliard at winehq.org
Thu Aug 26 15:22:32 CDT 2021


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

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Aug 26 18:26:26 2021 +0200

kernel32/tests: Test GetTimeFormatA()'s Unicode to ANSI conversion.

The ANSI string may be longer than the Unicode one and the return
value should reflect that.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/locale.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index b83cdc6b956..45bf56d8ad7 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -631,6 +631,34 @@ static void test_GetTimeFormatA(void)
   curtime.wMonth = 60;
   ret = GetTimeFormatA(lcid, 0, &curtime, "h:m:s", buffer, ARRAY_SIZE(buffer));
   expect_str(ret, buffer, "12:56:13");
+
+  /* The ANSI string may be longer than the Unicode one.
+   * In particular, in the Japanese code page, "\x93\xfa" = L"\x65e5".
+   */
+
+  lcid = MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN), SORT_DEFAULT);
+
+  ret = GetTimeFormatA(lcid, 0, &curtime, "h\x93\xfa", buffer, 5);
+  if (broken(1)) /* FIXME Remove once Wine is less broken */
+  expect_str(ret, buffer, "12\x93\xfa"); /* only 3+1 WCHARs */
+  todo_wine ok(ret == strlen("12\x93\xfa") + 1, "Expected ret %d, got %d\n", strlen("12\x93\xfa") + 1, ret);
+  ok(strcmp(buffer, "12\x93\xfa") == 0, "Expected '12\x93\xfa', got '%s'\n", buffer);
+
+  ret = GetTimeFormatA(lcid, 0, &curtime, "h\x93\xfa", buffer, 4);
+  todo_wine expect_err(ret, NULL, ERROR_INSUFFICIENT_BUFFER);
+  SetLastError(0xdeadbeef);
+
+  ret = GetTimeFormatA(lcid, 0, &curtime, "h\x93\xfa", NULL, 0);
+  if (broken(1)) /* FIXME Remove once Wine is less broken */
+  expect_str(ret, NULL, "12\x93\xfa");
+  todo_wine ok(ret == strlen("12\x93\xfa") + 1, "Expected ret %d, got %d\n", strlen("12\x93\xfa") + 1, ret);
+
+  strcpy(buffer, "pristine"); /* clear previous identical result */
+  ret = GetTimeFormatA(lcid, 0, &curtime, "h\x93\xfa", buffer, 0);
+  if (broken(1)) /* FIXME Remove once Wine is less broken */
+  expect_str(ret, NULL, "12\x93\xfa");
+  todo_wine ok(ret == strlen("12\x93\xfa") + 1, "Expected ret %d, got %d\n", strlen("12\x93\xfa") + 1, ret);
+  ok(strcmp(buffer, "pristine") == 0, "Expected a pristine buffer, got '%s'\n", buffer);
 }
 
 static void test_GetTimeFormatEx(void)




More information about the wine-cvs mailing list