Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libutil Test parsedate("@-2", ...) (should return -...



details:   https://anonhg.NetBSD.org/src/rev/acbf8129561c
branches:  trunk
changeset: 784140:acbf8129561c
user:      apb <apb%NetBSD.org@localhost>
date:      Sat Jan 19 15:21:43 2013 +0000

description:
Test parsedate("@-2",...) (should return -2 and not set errno);
and parsedate("@junk",...) (should return -1 and set errno).
We were already testing "@-1".

diffstat:

 tests/lib/libutil/t_parsedate.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 0639c3e2d1d0 -r acbf8129561c tests/lib/libutil/t_parsedate.c
--- a/tests/lib/libutil/t_parsedate.c   Sat Jan 19 15:10:05 2013 +0000
+++ b/tests/lib/libutil/t_parsedate.c   Sat Jan 19 15:21:43 2013 +0000
@@ -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 @@
        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)



Home | Main Index | Thread Index | Old Index