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 Add tests for %z
details: https://anonhg.NetBSD.org/src/rev/3dc5ae371e24
branches: trunk
changeset: 341281:3dc5ae371e24
user: christos <christos%NetBSD.org@localhost>
date: Thu Oct 29 17:48:20 2015 +0000
description:
Add tests for %z
diffstat:
tests/lib/libc/time/t_strptime.c | 96 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 94 insertions(+), 2 deletions(-)
diffs (124 lines):
diff -r eff97d8a5611 -r 3dc5ae371e24 tests/lib/libc/time/t_strptime.c
--- a/tests/lib/libc/time/t_strptime.c Thu Oct 29 16:19:44 2015 +0000
+++ b/tests/lib/libc/time/t_strptime.c Thu Oct 29 17:48:20 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strptime.c,v 1.6 2015/07/04 13:36:25 christos Exp $ */
+/* $NetBSD: t_strptime.c,v 1.7 2015/10/29 17:48:20 christos Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_strptime.c,v 1.6 2015/07/04 13:36:25 christos Exp $");
+__RCSID("$NetBSD: t_strptime.c,v 1.7 2015/10/29 17:48:20 christos Exp $");
#include <time.h>
@@ -291,6 +291,97 @@
h_pass("1980", "%EY", 4, -1, -1, -1, -1, -1, 80, -1, -1);
}
+ATF_TC(zone);
+
+ATF_TC_HEAD(zone, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Checks strptime(3) timezone conversion [z]");
+}
+
+static struct {
+ const char *name;
+ long offs;
+} zt[] = {
+ { "Z", 0 },
+ { "UT", 0 },
+ { "UTC", 0 },
+ { "GMT", 0 },
+ { "EST", -18000 },
+ { "EDT", -14400 },
+ { "CST", -21600 },
+ { "CDT", -18000 },
+ { "MST", -25200 },
+ { "MDT", -21600 },
+ { "PST", -28800 },
+ { "PDT", -25200 },
+
+ { "VST", -1 },
+ { "VDT", -1 },
+
+ { "+03", 10800 },
+ { "-03", -10800 },
+ { "+0403", 14580 },
+ { "-0403", -14580 },
+ { "+04:03", 14580 },
+ { "-04:03", -14580 },
+
+ { "1", -1 },
+ { "03", -1 },
+ { "0304", -1 },
+ { "+1", -1 },
+ { "-203", -1 },
+ { "+12345", -1 },
+ { "+12:345", -1 },
+ { "+123:45", -1 },
+
+ { "A", -3600 },
+ { "B", -7200 },
+ { "C", -10800 },
+ { "D", -14400 },
+ { "E", -18000 },
+ { "F", -21600 },
+ { "G", -25200 },
+ { "H", -28800 },
+ { "I", -32400 },
+ { "L", -39600 },
+ { "M", -43200 },
+ { "N", 3600 },
+ { "O", 7200 },
+ { "P", 10800 },
+ { "Q", 14400 },
+ { "R", 18000 },
+ { "T", 25200 },
+ { "U", 28800 },
+ { "V", 32400 },
+ { "W", 36000 },
+ { "X", 39600 },
+ { "Y", 43200 },
+
+ { "J", -1 },
+
+ { "America/Los_Angeles", -28800 },
+ { "America/New_York", -18000 },
+ { "EST4EDT", -14400 },
+
+ { "Bogus", -1 },
+};
+
+ATF_TC_BODY(zone, tc)
+{
+ struct tm tm;
+
+ for (size_t i = 0; i < __arraycount(zt); i++) {
+ if (strptime(zt[i].name, "%z", &tm) == NULL)
+ tm.tm_gmtoff = -1;
+ ATF_REQUIRE_MSG(tm.tm_gmtoff == zt[i].offs,
+ "strptime(\"%s\", \"%%z\", &tm): "
+ "expected: tm.tm_gmtoff=%ld, got: tm.tm_gmtoff=%ld",
+ zt[i].name, zt[i].offs, tm.tm_gmtoff);
+ }
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -300,6 +391,7 @@
ATF_TP_ADD_TC(tp, month);
ATF_TP_ADD_TC(tp, seconds);
ATF_TP_ADD_TC(tp, year);
+ ATF_TP_ADD_TC(tp, zone);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index