[PATCH 1/5] ucrtbase: Improve strftime special test cases for %c %r formats.

Jeff Smith whydoubt at gmail.com
Mon Dec 2 11:52:00 CST 2019


Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
 dlls/ucrtbase/tests/misc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c
index 083be42f42..606e74b524 100644
--- a/dlls/ucrtbase/tests/misc.c
+++ b/dlls/ucrtbase/tests/misc.c
@@ -29,6 +29,7 @@
 #include <fcntl.h>
 #include <time.h>
 #include <direct.h>
+#include <locale.h>
 
 #include <windef.h>
 #include <winbase.h>
@@ -162,6 +163,7 @@ static int* (CDECL *p_errno)(void);
 static char* (CDECL *p_asctime)(const struct tm *);
 static size_t (__cdecl *p_strftime)(char *, size_t, const char *, const struct tm *);
 static size_t (__cdecl *p__Strftime)(char*, size_t, const char*, const struct tm*, void*);
+static char* (__cdecl *p_setlocale)(int, const char*);
 static struct tm*  (__cdecl *p__gmtime32)(const __time32_t*);
 static void (CDECL *p_exit)(int);
 static int (CDECL *p__crt_atexit)(void (CDECL*)(void));
@@ -538,6 +540,7 @@ static BOOL init(void)
     p_asctime = (void*)GetProcAddress(module, "asctime");
     p_strftime = (void*)GetProcAddress(module, "strftime");
     p__Strftime = (void*)GetProcAddress(module, "_Strftime");
+    p_setlocale = (void*)GetProcAddress(module, "setlocale");
     p__gmtime32 = (void*)GetProcAddress(module, "_gmtime32");
     p__crt_atexit = (void*)GetProcAddress(module, "_crt_atexit");
     p_exit = (void*)GetProcAddress(module, "exit");
@@ -1135,6 +1138,8 @@ static void test_strftime(void)
     struct tm tm_yweek = { 0, 0, 0, 1, 0, 70, 0, 0, 0 };
     char buf[256];
     int i, ret=0;
+    char expected[] = "01/01/1970 00:00:00";
+    const char *locale;
 
     for (i=0; i<ARRAY_SIZE(tests); i++)
     {
@@ -1185,6 +1190,16 @@ static void test_strftime(void)
                     i, j, buf, tests_yweek[i].ret[j]);
         }
     }
+
+    locale = p_setlocale(LC_ALL, NULL);
+    p_setlocale(LC_ALL, "fr-FR");
+    ret = p_strftime(buf, sizeof(buf), "%c", &epoch);
+    ok(ret == strlen(expected), "ret = %d\n", ret);
+    ok(!strcmp(buf, expected), "buf = \"%s\", expected \"%s\"\n", buf, expected);
+    ret = p_strftime(buf, sizeof(buf), "%x %r", &epoch);
+    todo_wine ok(ret == strlen(expected), "ret = %d\n", ret);
+    todo_wine ok(!strcmp(buf, expected), "buf = \"%s\", expected \"%s\"\n", buf, expected);
+    p_setlocale(LC_ALL, locale);
 }
 
 static LONG* get_failures_counter(HANDLE *map)
-- 
2.23.0




More information about the wine-devel mailing list