Module Name: src
Committed By: apb
Date: Sat Jan 19 15:21:43 UTC 2013
Modified Files:
src/tests/lib/libutil: t_parsedate.c
Log Message:
Test parsedate("@-2",...) (should return -2 and not set errno);
and parsedate("@junk",...) (should return -1 and set errno).
We were already testing "@-1".
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libutil/t_parsedate.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libutil/t_parsedate.c
diff -u src/tests/lib/libutil/t_parsedate.c:1.6 src/tests/lib/libutil/t_parsedate.c:1.7
--- src/tests/lib/libutil/t_parsedate.c:1.6 Sat Jan 19 14:03:08 2013
+++ src/tests/lib/libutil/t_parsedate.c Sat Jan 19 15:21:43 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: t_parsedate.c,v 1.6 2013/01/19 14:03:08 apb Exp $ */
+/* $NetBSD: t_parsedate.c,v 1.7 2013/01/19 15:21:43 apb Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_parsedate.c,v 1.6 2013/01/19 14:03:08 apb Exp $");
+__RCSID("$NetBSD: t_parsedate.c,v 1.7 2013/01/19 15:21:43 apb Exp $");
#include <atf-c.h>
#include <errno.h>
@@ -121,9 +121,14 @@ ATF_TC_BODY(atsecs, tc)
tzoff = -3600;
ATF_CHECK(parsedate("@0", NULL, &tzoff) == (time_t)0);
- /* -1 is not an error */
+ /* -1 or other negative numbers are not errors */
errno = 0;
ATF_CHECK(parsedate("@-1", NULL, &tzoff) == (time_t)-1 && errno == 0);
+ ATF_CHECK(parsedate("@-2", NULL, &tzoff) == (time_t)-2 && errno == 0);
+
+ /* junk is an error */
+ errno = 0;
+ ATF_CHECK(parsedate("@junk", NULL, NULL) == (time_t)-1 && errno != 0);
}
ATF_TP_ADD_TCS(tp)