Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add testcase from PR/44255, that exercize parsedate(3) with ...
details: https://anonhg.NetBSD.org/src/rev/a3e6aeb7cf1d
branches: trunk
changeset: 759921:a3e6aeb7cf1d
user: njoly <njoly%NetBSD.org@localhost>
date: Mon Dec 20 16:23:01 2010 +0000
description:
Add testcase from PR/44255, that exercize parsedate(3) with sample
strings taken from the manpage.
diffstat:
distrib/sets/lists/tests/mi | 4 +-
tests/lib/libutil/Makefile | 5 +-
tests/lib/libutil/t_parsedate.c | 100 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 3 deletions(-)
diffs (148 lines):
diff -r 4dd58d9ee5ec -r a3e6aeb7cf1d distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Mon Dec 20 16:13:44 2010 +0000
+++ b/distrib/sets/lists/tests/mi Mon Dec 20 16:23:01 2010 +0000
@@ -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
diff -r 4dd58d9ee5ec -r a3e6aeb7cf1d tests/lib/libutil/Makefile
--- a/tests/lib/libutil/Makefile Mon Dec 20 16:13:44 2010 +0000
+++ b/tests/lib/libutil/Makefile Mon Dec 20 16:23:01 2010 +0000
@@ -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")
diff -r 4dd58d9ee5ec -r a3e6aeb7cf1d tests/lib/libutil/t_parsedate.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libutil/t_parsedate.c Mon Dec 20 16:23:01 2010 +0000
@@ -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();
+}
Home |
Main Index |
Thread Index |
Old Index