summaryrefslogtreecommitdiff
path: root/time
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-08-31 20:15:31 +0000
committerUlrich Drepper <drepper@redhat.com>2002-08-31 20:15:31 +0000
commit281058289a8c7ccf038eccec9a414eb5ef79c2f9 (patch)
treeaf6531313730398f3b1d71b5d52f9d5f181b69c8 /time
parenta0fc81e1710a9cb9b9ccfceaf2afcca2a310cb4d (diff)
downloadglibc-281058289a8c7ccf038eccec9a414eb5ef79c2f9.tar.gz
(main): Also test strftime with uselocale.
Diffstat (limited to 'time')
-rw-r--r--time/tst-ftime_l.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/time/tst-ftime_l.c b/time/tst-ftime_l.c
index 6ebc973feb..fc3d78d689 100644
--- a/time/tst-ftime_l.c
+++ b/time/tst-ftime_l.c
@@ -10,10 +10,12 @@ int
main (void)
{
locale_t l;
+ locale_t old;
struct tm tm;
char buf[1000];
wchar_t wbuf[1000];
int result = 0;
+ size_t n;
l = newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL);
if (l == NULL)
@@ -81,5 +83,44 @@ main (void)
setlocale (LC_ALL, "C");
}
+ old = uselocale (l);
+
+ n = strftime (buf, sizeof (buf), "%e %^B %Y", &tm);
+
+ /* Switch back. */
+ (void) uselocale (old);
+
+ if (n == 0)
+ {
+ puts ("strftime after first uselocale failed");
+ result = 1;
+ }
+ else if (strcmp (buf, " 1 M\xc4RZ 2002") != 0)
+ {
+ printf ("strftime in non-C locale: expected \"%s\", got \"%s\"\n",
+ " 1 M\xc4RZ 2002", buf);
+ result = 1;
+ }
+ else
+ {
+ setlocale (LC_ALL, "de_DE.ISO-8859-1");
+ printf ("got \"%s\"\n", buf);
+ setlocale (LC_ALL, "C");
+ }
+
+ if (strftime (buf, sizeof (buf), "%e %^B %Y", &tm) == 0)
+ {
+ puts ("strftime after second uselocale failed");
+ result = 1;
+ }
+ else if (strcmp (buf, " 1 MARCH 2002") != 0)
+ {
+ printf ("initial strftime: expected \"%s\", got \"%s\"\n",
+ " 1 MARCH 2002", buf);
+ result = 1;
+ }
+ else
+ printf ("got \"%s\"\n", buf);
+
return result;
}