summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2014-12-01 20:47:00 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2014-12-01 20:47:00 +0100
commitc37bec8802893e7cb3e8bfda8a6f7c61de5f231d (patch)
tree1e7a838ef97617b95ec353eb4b1203d56accc74b /test
parent19a696d410c8f2839ad4617ad8446fc3781ae684 (diff)
parentb36422960466777495933ed1eb50befd1c34e9a9 (diff)
Merge remote-tracking branch 'origin/upstream'
Diffstat (limited to 'test')
-rw-r--r--test/time/Makefile.in7
-rw-r--r--test/time/tst_wcsftime.c70
2 files changed, 54 insertions, 23 deletions
diff --git a/test/time/Makefile.in b/test/time/Makefile.in
index a2613784b..83bc07dbb 100644
--- a/test/time/Makefile.in
+++ b/test/time/Makefile.in
@@ -9,8 +9,13 @@ TESTS_DISABLED += tst-timerfd
endif
ifneq ($(UCLIBC_HAS_XLOCALE),y)
-TESTS_DISABLED += tst-ftime_l tst_wcsftime
+TESTS_DISABLED += tst-ftime_l
+endif
+
+ifneq ($(UCLIBC_HAS_WCHAR)$(UCLIBC_HAS_LOCALE),yy)
+TESTS_DISABLED += tst_wcsftime
endif
CFLAGS_tst-strptime2 := -std=c99
DODIFF_futimens1 := 1
+DODIFF_tst_wcsftime := 1
diff --git a/test/time/tst_wcsftime.c b/test/time/tst_wcsftime.c
index 6e35f1e6f..5631d952a 100644
--- a/test/time/tst_wcsftime.c
+++ b/test/time/tst_wcsftime.c
@@ -1,39 +1,65 @@
#include <stdio.h>
#include <time.h>
#include <features.h>
-#ifdef __UCLIBC_HAS_WCHAR__
#include <wchar.h>
+#include <locale.h>
+
+#define NUM_OF_DATES 7
+#define NUM_OF_LOCALES 3
+#define BUF_SIZE 256
int
-main (int argc, char *argv[])
+main (void)
{
- wchar_t buf[200];
- time_t t;
+ wchar_t buf[BUF_SIZE];
struct tm *tp;
- int result = 0;
+ time_t time_list[NUM_OF_DATES] = {
+ 500, 68200000, 694223999,
+ 694224000, 704900000, 705000000,
+ 705900000
+ };
+ char *locale_list[NUM_OF_LOCALES] = {
+ "C",
+ "fr_FR.ISO-8859-1",
+ "ja_JP.UTF-8"
+ };
+ int result = 0, ddd, lll;
size_t n;
- time (&t);
- tp = gmtime (&t);
+ for (lll = 0; lll < NUM_OF_LOCALES; lll++) {
+ printf ("\nUsing locale: %s\n", locale_list[lll]);
+ char* set = setlocale(LC_ALL, locale_list[lll]);
+ if (set == NULL) {
+ printf ("FAILED!\n\n");
+ continue;
+ } else
+ printf ("\n");
+ for (ddd = 0; ddd < NUM_OF_DATES; ddd++) {
+ tp = localtime(&time_list[ddd]);
+ printf ("%ld corresponds to ", time_list[ddd]);
- n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
- L"%H:%M:%S %Y-%m-%d\n", tp);
- if (n != 21)
- result = 1;
+ n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
+ L"%H:%M:%S %Y-%m-%d%n", tp);
+ if (n != 21) {
+ result = 1;
+ printf ("FAILED!\n");
+ }
- wprintf (L"It is now %ls", buf);
+ printf ("%ls", buf);
- wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%A\n", tp);
+ wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
+ L"%tor, as %%D %%T: %D %T%n", tp);
+ printf ("%ls", buf);
- wprintf (L"The weekday is %ls", buf);
+ wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%A (%a)%n", tp);
+ printf ("The weekday was %ls", buf);
+ wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%B (%b) %Y%n", tp);
+ /* glibc bug? forgets aigu from french february février
+ * See s/printf (/wprintf (L/g */
+ //wprintf (L"Month was %ls", buf);
+ printf ("Month was %ls", buf);
+ }
+ }
return result;
}
-
-#else
-int main(void)
-{
- puts("Test requires WCHAR support; skipping");
- return 0;
-}
-#endif