Module Name:    src
Committed By:   njoly
Date:           Mon Dec 20 16:23:01 UTC 2010

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/lib/libutil: Makefile
Added Files:
        src/tests/lib/libutil: t_parsedate.c

Log Message:
Add testcase from PR/44255, that exercize parsedate(3) with sample
strings taken from the manpage.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libutil/Makefile
cvs rdiff -u -r0 -r1.1 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/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.182 src/distrib/sets/lists/tests/mi:1.183
--- src/distrib/sets/lists/tests/mi:1.182	Mon Dec 20 15:10:06 2010
+++ src/distrib/sets/lists/tests/mi	Mon Dec 20 16:23:01 2010
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.182 2010/12/20 15:10:06 njoly Exp $
+# $NetBSD: mi,v 1.183 2010/12/20 16:23:01 njoly Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -377,6 +377,7 @@
 ./usr/libdata/debug/usr/tests/lib/libskey				tests-lib-debug
 ./usr/libdata/debug/usr/tests/lib/libskey/t_algorithms.debug		tests-lib-debug		debug,atf,skey
 ./usr/libdata/debug/usr/tests/lib/libutil				tests-lib-debug
+./usr/libdata/debug/usr/tests/lib/libutil/t_parsedate.debug		tests-lib-debug		debug,atf
 ./usr/libdata/debug/usr/tests/lib/libutil/t_snprintb.debug		tests-lib-debug		debug,atf
 ./usr/libdata/debug/usr/tests/lib/libutil/t_sockaddr_snprintf.debug	tests-lib-debug		debug,atf
 ./usr/libdata/debug/usr/tests/libexec					tests-lib-debug
@@ -1613,6 +1614,7 @@
 ./usr/tests/lib/libskey/t_algorithms		tests-lib-tests		atf,skey
 ./usr/tests/lib/libutil				tests-lib-tests		atf
 ./usr/tests/lib/libutil/Atffile			tests-lib-tests		atf
+./usr/tests/lib/libutil/t_parsedate		tests-lib-tests		atf
 ./usr/tests/lib/libutil/t_snprintb		tests-lib-tests		atf
 ./usr/tests/lib/libutil/t_sockaddr_snprintf	tests-lib-tests		atf
 ./usr/tests/libexec				tests-lib-tests

Index: src/tests/lib/libutil/Makefile
diff -u src/tests/lib/libutil/Makefile:1.1 src/tests/lib/libutil/Makefile:1.2
--- src/tests/lib/libutil/Makefile:1.1	Fri Jul 16 13:56:32 2010
+++ src/tests/lib/libutil/Makefile	Mon Dec 20 16:23:01 2010
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2010/07/16 13:56:32 jmmv Exp $
+# $NetBSD: Makefile,v 1.2 2010/12/20 16:23:01 njoly Exp $
 
 NOMAN=		# defined
 
@@ -9,7 +9,8 @@
 DPADD+=		${LIBUTIL}
 LDADD+=		-lutil
 
-TESTS_C=	t_snprintb
+TESTS_C=	t_parsedate
+TESTS_C+=	t_snprintb
 TESTS_C+=	t_sockaddr_snprintf
 
 .if (${USE_INET6} != "no")

Added files:

Index: src/tests/lib/libutil/t_parsedate.c
diff -u /dev/null src/tests/lib/libutil/t_parsedate.c:1.1
--- /dev/null	Mon Dec 20 16:23:01 2010
+++ src/tests/lib/libutil/t_parsedate.c	Mon Dec 20 16:23:01 2010
@@ -0,0 +1,100 @@
+/* $NetBSD: t_parsedate.c,v 1.1 2010/12/20 16:23:01 njoly Exp $ */
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_parsedate.c,v 1.1 2010/12/20 16:23:01 njoly Exp $");
+
+#include <atf-c.h>
+#include <util.h>
+
+ATF_TC(dates);
+
+ATF_TC_HEAD(dates, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test unambiguous dates");
+}
+
+ATF_TC_BODY(dates, tc)
+{
+
+	atf_tc_expect_fail("PR lib/44255");
+	ATF_CHECK(parsedate("69-09-10", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("2006-11-17", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("10/1/2000", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("20 Jun 1994", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("23jun2001", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("1-sep-06", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("1/11", NULL, NULL) != -1);
+}
+
+ATF_TC(times);
+
+ATF_TC_HEAD(times, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test times");
+}
+
+ATF_TC_BODY(times, tc)
+{
+
+	atf_tc_expect_fail("PR lib/44255");
+	ATF_CHECK(parsedate("10:01", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("10:12pm", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("12:11:01.000012", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("12:21-0500", NULL, NULL) != -1);
+}
+
+ATF_TC(relative);
+
+ATF_TC_HEAD(relative, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test relative items");            
+}
+
+ATF_TC_BODY(relative, tc)
+{
+
+	atf_tc_expect_fail("PR lib/44255");
+	ATF_CHECK(parsedate("-1 month", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("last friday", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("one week ago", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("this thursday", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("next sunday", NULL, NULL) != -1);
+	ATF_CHECK(parsedate("+2 years", NULL, NULL) != -1);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, dates);
+	ATF_TP_ADD_TC(tp, times);
+	ATF_TP_ADD_TC(tp, relative);
+
+	return atf_no_error();
+}

Reply via email to