Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libutil PR lib/52101



details:   https://anonhg.NetBSD.org/src/rev/841ec7eb09b1
branches:  trunk
changeset: 822474:841ec7eb09b1
user:      kre <kre%NetBSD.org@localhost>
date:      Tue Mar 21 20:06:27 2017 +0000

description:
PR lib/52101

Add 6 extra tests for the 12am/12pm bug - all currently expected to fail.
(That is, 6 subtests of the "times" test will fail, all new ones)>

While here, when parsedate() fails (returns -1) avoid converting that
failure value (-1) to a struct tm (1969-12-31T23:59:59 UTC) and then
comparing the values with those expected by the test, and complaining
about all of those (where ANY was not permitted) that don't match...

diffstat:

 tests/lib/libutil/t_parsedate.c |  27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diffs (55 lines):

diff -r 0546d4f8fe97 -r 841ec7eb09b1 tests/lib/libutil/t_parsedate.c
--- a/tests/lib/libutil/t_parsedate.c   Tue Mar 21 19:26:40 2017 +0000
+++ b/tests/lib/libutil/t_parsedate.c   Tue Mar 21 20:06:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_parsedate.c,v 1.25 2016/06/22 15:01:38 kre Exp $ */
+/* $NetBSD: t_parsedate.c,v 1.26 2017/03/21 20:06:27 kre Exp $ */
 /*-
  * Copyright (c) 2010, 2015 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_parsedate.c,v 1.25 2016/06/22 15:01:38 kre Exp $");
+__RCSID("$NetBSD: t_parsedate.c,v 1.26 2017/03/21 20:06:27 kre Exp $");
 
 #include <atf-c.h>
 #include <errno.h>
@@ -84,6 +84,9 @@
 
        ATF_CHECK_MSG((t = parsedate(datestr, reftime, zoff)) != -1,
            "parsedate(%s) returned -1\n", argstr);
+       if (t == -1)
+               return;
+
        ATF_CHECK(time_to_tm(&t, &tm) != NULL);
        if (year != ANY)
                ATF_CHECK_MSG(tm.tm_year + 1900 == year,
@@ -180,6 +183,26 @@
                ANY, ANY, ANY, 0, 0, 0);
        parsecheck("noon", NULL, NULL, localtime_r,
                ANY, ANY, ANY, 12, 0, 0);
+
+       atf_tc_expect_fail("PR lib/52101");
+
+       parsecheck("12:30 am", NULL, NULL, localtime_r,
+               ANY, ANY, ANY, 0, 30, 0);
+       parsecheck("12:30 pm", NULL, NULL, localtime_r,
+               ANY, ANY, ANY, 12, 20, 0);
+
+       /*
+        * Technically, these are invalid, noon and midnight
+        * are neither am, nor pm, but this is what people expect...
+        */
+       parsecheck("12:00:00 am", NULL, NULL, localtime_r,
+               ANY, ANY, ANY, 0, 0, 0);
+       parsecheck("12:00:00 pm", NULL, NULL, localtime_r,
+               ANY, ANY, ANY, 12, 0, 0);
+       parsecheck("12am", NULL, NULL, localtime_r,
+               ANY, ANY, ANY, 0, 0, 0);
+       parsecheck("12pm", NULL, NULL, localtime_r,
+               ANY, ANY, ANY, 12, 0, 0);
 }
 
 ATF_TC(dsttimes);



Home | Main Index | Thread Index | Old Index