Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/time Account for J, fix %Z



details:   https://anonhg.NetBSD.org/src/rev/2fe3020b5439
branches:  trunk
changeset: 341331:2fe3020b5439
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Oct 31 02:13:41 2015 +0000

description:
Account for J, fix %Z

diffstat:

 tests/lib/libc/time/t_strptime.c |  28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

diffs (73 lines):

diff -r 6bb0d2e25688 -r 2fe3020b5439 tests/lib/libc/time/t_strptime.c
--- a/tests/lib/libc/time/t_strptime.c  Sat Oct 31 02:09:06 2015 +0000
+++ b/tests/lib/libc/time/t_strptime.c  Sat Oct 31 02:13:41 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strptime.c,v 1.10 2015/10/30 18:25:49 christos Exp $ */
+/* $NetBSD: t_strptime.c,v 1.11 2015/10/31 02:13:41 christos Exp $ */
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -32,10 +32,11 @@
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_strptime.c,v 1.10 2015/10/30 18:25:49 christos Exp $");
+__RCSID("$NetBSD: t_strptime.c,v 1.11 2015/10/31 02:13:41 christos Exp $");
 
 #include <time.h>
 #include <stdlib.h>
+#include <stdio.h>
 
 #include <atf-c.h>
 
@@ -148,7 +149,7 @@
        { "X",                          39600 },
        { "Y",                          43200 },
 
-       { "J",                          -1 },
+       { "J",                          -2 },
 
        { "America/Los_Angeles",        -28800 },
        { "America/New_York",           -18000 },
@@ -161,14 +162,31 @@
 ztest(const char *name, const char *fmt, long value)
 {
        struct tm tm;
+       char *rv;
 
        memset(&tm, 0, sizeof(tm));
-       if (strptime(name, fmt, &tm) == NULL) 
+       if ((rv = strptime(name, fmt, &tm)) == NULL) 
                tm.tm_gmtoff = -1;
+       else if (rv == name && fmt[1] == 'Z')
+               value = 0;
+
+       switch (value) {
+       case -2:
+               value = -timezone;
+               break;
+       case -1:
+               if (fmt[1] == 'Z')
+                       value = 0;
+               break;
+       default:
+               break;
+       }
+
        ATF_REQUIRE_MSG(tm.tm_gmtoff == value,
            "strptime(\"%s\", \"%s\", &tm): "
            "expected: tm.tm_gmtoff=%ld, got: tm.tm_gmtoff=%ld",
            name, fmt, value, tm.tm_gmtoff);
+       printf("%s %s %ld\n", name, fmt, tm.tm_gmtoff);
 }
 
 ATF_TC(common);
@@ -418,7 +436,7 @@
 
        /* This is all handled by tzalloc for %Z */
        for (size_t i = 0; i < __arraycount(zt); i++)
-               ztest(zt[i].name, "%z", zt[i].offs);
+               ztest(zt[i].name, "%Z", zt[i].offs);
 }
 
 ATF_TP_ADD_TCS(tp)



Home | Main Index | Thread Index | Old Index