summaryrefslogtreecommitdiff
path: root/gnulib-tests/test-strftime.c
diff options
context:
space:
mode:
Diffstat (limited to 'gnulib-tests/test-strftime.c')
-rw-r--r--gnulib-tests/test-strftime.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/gnulib-tests/test-strftime.c b/gnulib-tests/test-strftime.c
index 39494e6..102e168 100644
--- a/gnulib-tests/test-strftime.c
+++ b/gnulib-tests/test-strftime.c
@@ -1,5 +1,5 @@
/* Test that posixtime works as required.
- Copyright (C) 2011-2016 Free Software Foundation, Inc.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -96,6 +96,8 @@ static struct tzalloc_test TZ[] =
{ 0, "JST-9" },
#define NZ 5
{ 0, "NZST-12NZDT,M9.5.0,M4.1.0/3" },
+#define Unknown 6
+ { 0, "<-00>0" },
{ 0 }
};
@@ -121,18 +123,21 @@ static struct localtime_rz_test LT[] =
{ TZ+CentEur, 0, "1970-01-01 01:00:00 +0100 (CET)", 0 },
{ TZ+Japan , 0, "1970-01-01 09:00:00 +0900 (JST)", 0 },
{ TZ+NZ , 0, "1970-01-01 13:00:00 +1300 (NZDT)", 1 },
+ { TZ+Unknown, 0, "1970-01-01 00:00:00 -0000 (-00)", 0 },
{ TZ+Pacific, 500000001, "1985-11-04 16:53:21 -0800 (PST)", 0 },
{ TZ+Arizona, 500000001, "1985-11-04 17:53:21 -0700 (MST)", 0 },
{ TZ+UTC , 500000001, "1985-11-05 00:53:21 +0000 (UTC)", 0 },
{ TZ+CentEur, 500000001, "1985-11-05 01:53:21 +0100 (CET)", 1 },
{ TZ+Japan , 500000001, "1985-11-05 09:53:21 +0900 (JST)", 0 },
{ TZ+NZ , 500000001, "1985-11-05 13:53:21 +1300 (NZDT)", 0 },
+ { TZ+Unknown, 500000001, "1985-11-05 00:53:21 -0000 (-00)", 0 },
{ TZ+Pacific, 1000000002, "2001-09-08 18:46:42 -0700 (PDT)", 0 },
{ TZ+Arizona, 1000000002, "2001-09-08 18:46:42 -0700 (MST)", 0 },
{ TZ+UTC , 1000000002, "2001-09-09 01:46:42 +0000 (UTC)", 0 },
{ TZ+CentEur, 1000000002, "2001-09-09 03:46:42 +0200 (CEST)", 0 },
{ TZ+Japan , 1000000002, "2001-09-09 10:46:42 +0900 (JST)", 0 },
{ TZ+NZ , 1000000002, "2001-09-09 13:46:42 +1200 (NZST)", 0 },
+ { TZ+Unknown, 1000000002, "2001-09-09 01:46:42 -0000 (-00)", 0 },
{ 0 }
};
@@ -200,12 +205,48 @@ tzalloc_test (void)
return fail;
}
+
+static int
+quarter_test (void)
+{
+ int result = 0;
+ size_t mon;
+
+ /* Check %q. */
+ for (mon = 1; mon <= 12; mon++)
+ {
+ char out[2];
+ char exp[2] = {0,};
+ struct tm qtm = { .tm_mon = mon - 1 };
+ char fmt[3] = {'%','q','\0'};
+
+ size_t r = nstrftime (out, sizeof (out), fmt, &qtm, 0, 0);
+ if (r == 0)
+ {
+ puts ("nstrftime(\"%q\") failed");
+ result = 1;
+ break;
+ }
+
+ exp[0] = mon < 4 ? '1' : mon < 7 ? '2' : mon < 10 ? '3' : '4';
+ if (strcmp (out, exp) != 0)
+ {
+ printf ("nstrftime %%q: expected \"%s\", got \"%s\"\n", exp, out);
+ result = 1;
+ break;
+ }
+ }
+
+ return result;
+}
+
int
main (void)
{
int fail = 0;
fail |= posixtm_test ();
fail |= tzalloc_test ();
+ fail |= quarter_test ();
return fail;
}