aboutsummaryrefslogtreecommitdiff
path: root/time/tst-strftime.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-05-11 22:41:23 +0000
committerUlrich Drepper <drepper@redhat.com>2003-05-11 22:41:23 +0000
commitef3a0fcdad439948e501e951e8b1055e4971d008 (patch)
treeba5a7154a421b8e7188ac9013fdfd5a787509491 /time/tst-strftime.c
parent8403786bbfd1d25b513285f3e5d46fe798b8fc30 (diff)
downloadglibc-ef3a0fcdad439948e501e951e8b1055e4971d008.zip
glibc-ef3a0fcdad439948e501e951e8b1055e4971d008.tar.gz
glibc-ef3a0fcdad439948e501e951e8b1055e4971d008.tar.bz2
(do_test): Add tests for - flag.
Diffstat (limited to 'time/tst-strftime.c')
-rw-r--r--time/tst-strftime.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/time/tst-strftime.c b/time/tst-strftime.c
index 1feb741..374fba4 100644
--- a/time/tst-strftime.c
+++ b/time/tst-strftime.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <time.h>
@@ -67,6 +68,42 @@ do_test (void)
free (buf);
}
+ struct tm ttm =
+ {
+ /* Initialize the fields which are needed in the tests. */
+ .tm_mday = 1,
+ .tm_hour = 2
+ };
+ const struct
+ {
+ const char *fmt;
+ const char *exp;
+ size_t n;
+ } ftests[] =
+ {
+ { "%-e", "1", 1 },
+ { "%-k", "2", 1 },
+ { "%-l", "2", 1 },
+ };
+#define nftests (sizeof (ftests) / sizeof (ftests[0]))
+ for (cnt = 0; cnt < nftests; ++cnt)
+ {
+ char buf[100];
+ size_t r = strftime (buf, sizeof (buf), ftests[cnt].fmt, &ttm);
+ if (r != ftests[cnt].n)
+ {
+ printf ("strftime(\"%s\") returned %zu not %zu\n",
+ ftests[cnt].fmt, r, ftests[cnt].n);
+ result = 1;
+ }
+ if (strcmp (buf, ftests[cnt].exp) != 0)
+ {
+ printf ("strftime(\"%s\") produced \"%s\" not \"%s\"\n",
+ ftests[cnt].fmt, buf, ftests[cnt].exp);
+ result = 1;
+ }
+ }
+
return result;
}