Source-Changes-HG archive

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

[src/trunk]: src Add test cases for strcspn, strpbrk, strspn, wcscspn, wcspbr...



details:   https://anonhg.NetBSD.org/src/rev/d911d6db4551
branches:  trunk
changeset: 771469:d911d6db4551
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Nov 21 23:50:44 2011 +0000

description:
Add test cases for strcspn, strpbrk, strspn, wcscspn, wcspbrk and
wcsspn.

diffstat:

 distrib/sets/lists/tests/mi       |  14 ++++++++-
 tests/lib/libc/locale/Makefile    |   5 ++-
 tests/lib/libc/locale/t_wcscspn.c |  58 ++++++++++++++++++++++++++++++++++++
 tests/lib/libc/locale/t_wcspbrk.c |  62 +++++++++++++++++++++++++++++++++++++++
 tests/lib/libc/locale/t_wcsspn.c  |  60 +++++++++++++++++++++++++++++++++++++
 tests/lib/libc/string/Makefile    |   5 ++-
 tests/lib/libc/string/t_strcspn.c |  58 ++++++++++++++++++++++++++++++++++++
 tests/lib/libc/string/t_strpbrk.c |  62 +++++++++++++++++++++++++++++++++++++++
 tests/lib/libc/string/t_strspn.c  |  60 +++++++++++++++++++++++++++++++++++++
 9 files changed, 381 insertions(+), 3 deletions(-)

diffs (truncated from 485 to 300 lines):

diff -r 0f0fee224cc4 -r d911d6db4551 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Mon Nov 21 23:48:52 2011 +0000
+++ b/distrib/sets/lists/tests/mi       Mon Nov 21 23:50:44 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.424 2011/11/17 01:22:30 christos Exp $
+# $NetBSD: mi,v 1.425 2011/11/21 23:50:44 joerg Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -407,6 +407,9 @@
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_mbrtowc.debug          tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_mbstowcs.debug         tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_mbtowc.debug           tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/locale/t_wcscspn.debug          tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/locale/t_wcspbrk.debug          tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/locale/t_wcsspn.debug           tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_wcstod.debug           tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_wctomb.debug           tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/inet                            tests-lib-debug
@@ -483,11 +486,14 @@
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_strchr.debug           tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_strcmp.debug           tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_strcpy.debug           tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/string/t_strcspn.debug          tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_strerror.debug         tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_stresep.debug          tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_string.debug           tests-obsolete          obsolete
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_strlen.debug           tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/string/t_strpbrk.debug          tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_strrchr.debug          tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/string/t_strspn.debug           tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/string/t_swab.debug             tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/sys                             tests-lib-debug
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_access.debug              tests-lib-debug         debug,atf
@@ -1997,6 +2003,9 @@
 ./usr/tests/lib/libc/locale/t_mbrtowc          tests-lib-tests         atf
 ./usr/tests/lib/libc/locale/t_mbstowcs         tests-lib-tests         atf
 ./usr/tests/lib/libc/locale/t_mbtowc           tests-lib-tests         atf
+./usr/tests/lib/libc/locale/t_wcscspn          tests-lib-tests         atf
+./usr/tests/lib/libc/locale/t_wcspbrk          tests-lib-tests         atf
+./usr/tests/lib/libc/locale/t_wcsspn           tests-lib-tests         atf
 ./usr/tests/lib/libc/locale/t_wcstod           tests-lib-tests         atf
 ./usr/tests/lib/libc/locale/t_wctomb           tests-lib-tests         atf
 ./usr/tests/lib/libc/inet                      tests-lib-tests
@@ -2134,11 +2143,14 @@
 ./usr/tests/lib/libc/string/t_strchr           tests-lib-tests         atf
 ./usr/tests/lib/libc/string/t_strcmp           tests-lib-tests         atf
 ./usr/tests/lib/libc/string/t_strcpy           tests-lib-tests         atf
+./usr/tests/lib/libc/string/t_strcspn          tests-lib-tests         atf
 ./usr/tests/lib/libc/string/t_strerror         tests-lib-tests         atf
 ./usr/tests/lib/libc/string/t_stresep          tests-lib-tests         atf
 ./usr/tests/lib/libc/string/t_string           tests-obsolete          obsolete
 ./usr/tests/lib/libc/string/t_strlen           tests-lib-tests         atf
+./usr/tests/lib/libc/string/t_strpbrk          tests-lib-tests         atf
 ./usr/tests/lib/libc/string/t_strrchr          tests-lib-tests         atf
+./usr/tests/lib/libc/string/t_strspn           tests-lib-tests         atf
 ./usr/tests/lib/libc/string/t_swab             tests-lib-tests         atf
 ./usr/tests/lib/libc/sys                       tests-lib-tests
 ./usr/tests/lib/libc/sys/Atffile               tests-lib-tests         atf
diff -r 0f0fee224cc4 -r d911d6db4551 tests/lib/libc/locale/Makefile
--- a/tests/lib/libc/locale/Makefile    Mon Nov 21 23:48:52 2011 +0000
+++ b/tests/lib/libc/locale/Makefile    Mon Nov 21 23:50:44 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2011/07/15 07:35:21 jruoho Exp $
+# $NetBSD: Makefile,v 1.4 2011/11/21 23:50:45 joerg Exp $
 
 .include <bsd.own.mk>
 
@@ -7,6 +7,9 @@
 TESTS_C+=      t_mbrtowc
 TESTS_C+=      t_mbstowcs
 TESTS_C+=      t_mbtowc
+TESTS_C+=      t_wcscspn
+TESTS_C+=      t_wcspbrk
+TESTS_C+=      t_wcsspn
 TESTS_C+=      t_wcstod
 TESTS_C+=      t_wctomb
 
diff -r 0f0fee224cc4 -r d911d6db4551 tests/lib/libc/locale/t_wcscspn.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/locale/t_wcscspn.c Mon Nov 21 23:50:44 2011 +0000
@@ -0,0 +1,58 @@
+/*     $NetBSD: t_wcscspn.c,v 1.1 2011/11/21 23:50:45 joerg Exp $      */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Joerg Sonnenberger.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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_wcscspn.c,v 1.1 2011/11/21 23:50:45 joerg Exp $");
+
+#include <atf-c.h>
+#include <wchar.h>
+
+ATF_TC(wcscspn);
+ATF_TC_HEAD(wcscspn, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test wcscspn(3)");
+}
+
+ATF_TC_BODY(wcscspn, tc)
+{
+       ATF_CHECK_EQ(wcscspn(L"abcdefghijklmnop", L""), 16);
+       ATF_CHECK_EQ(wcscspn(L"abcdefghijklmnop", L"a"), 0);
+       ATF_CHECK_EQ(wcscspn(L"abcdefghijklmnop", L"b"), 1);
+       ATF_CHECK_EQ(wcscspn(L"abcdefghijklmnop", L"cd"), 2);
+       ATF_CHECK_EQ(wcscspn(L"abcdefghijklmnop", L"qrstuvwxyz"), 16);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+       ATF_TP_ADD_TC(tp, wcscspn);
+       return atf_no_error();
+}
diff -r 0f0fee224cc4 -r d911d6db4551 tests/lib/libc/locale/t_wcspbrk.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/locale/t_wcspbrk.c Mon Nov 21 23:50:44 2011 +0000
@@ -0,0 +1,62 @@
+/*     $NetBSD: t_wcspbrk.c,v 1.1 2011/11/21 23:50:45 joerg Exp $      */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Joerg Sonnenberger.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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_wcspbrk.c,v 1.1 2011/11/21 23:50:45 joerg Exp $");
+
+#include <atf-c.h>
+#include <wchar.h>
+
+ATF_TC(wcspbrk);
+ATF_TC_HEAD(wcspbrk, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test wcspbrk(3)");
+}
+
+ATF_TC_BODY(wcspbrk, tc)
+{
+       static const wchar_t s[] = L"abcdefghijklmnop";
+
+       ATF_CHECK_EQ(wcspbrk(s, L""), NULL);
+       ATF_CHECK_EQ(wcspbrk(s, L"qrst"), NULL);
+       ATF_CHECK_EQ(wcspbrk(s, L"a"), s);
+       ATF_CHECK_EQ(wcspbrk(s, L"b"), s + 1);
+       ATF_CHECK_EQ(wcspbrk(s, L"ab"), s);
+       ATF_CHECK_EQ(wcspbrk(s, L"cdef"), s + 2);
+       ATF_CHECK_EQ(wcspbrk(s, L"fedc"), s + 2);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+       ATF_TP_ADD_TC(tp, wcspbrk);
+       return atf_no_error();
+}
diff -r 0f0fee224cc4 -r d911d6db4551 tests/lib/libc/locale/t_wcsspn.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/locale/t_wcsspn.c  Mon Nov 21 23:50:44 2011 +0000
@@ -0,0 +1,60 @@
+/*     $NetBSD: t_wcsspn.c,v 1.1 2011/11/21 23:50:45 joerg Exp $       */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Joerg Sonnenberger.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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_wcsspn.c,v 1.1 2011/11/21 23:50:45 joerg Exp $");
+
+#include <atf-c.h>
+#include <wchar.h>
+
+ATF_TC(wcsspn);
+ATF_TC_HEAD(wcsspn, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test wcsspn(3)");
+}
+
+ATF_TC_BODY(wcsspn, tc)
+{
+       ATF_CHECK_EQ(wcsspn(L"abcdefghijklmnop", L""), 0);
+       ATF_CHECK_EQ(wcsspn(L"abcdefghijklmnop", L"a"), 1);
+       ATF_CHECK_EQ(wcsspn(L"abcdefghijklmnop", L"b"), 0);
+       ATF_CHECK_EQ(wcsspn(L"abcdefghijklmnop", L"ab"), 2);
+       ATF_CHECK_EQ(wcsspn(L"abcdefghijklmnop", L"abc"), 3);
+       ATF_CHECK_EQ(wcsspn(L"abcdefghijklmnop", L"abce"), 3);
+       ATF_CHECK_EQ(wcsspn(L"abcdefghijklmnop", L"abcdefghijklmnop"), 16);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+       ATF_TP_ADD_TC(tp, wcsspn);
+       return atf_no_error();
+}
diff -r 0f0fee224cc4 -r d911d6db4551 tests/lib/libc/string/Makefile
--- a/tests/lib/libc/string/Makefile    Mon Nov 21 23:48:52 2011 +0000
+++ b/tests/lib/libc/string/Makefile    Mon Nov 21 23:50:44 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2011/07/07 08:59:33 jruoho Exp $
+# $NetBSD: Makefile,v 1.8 2011/11/21 23:50:45 joerg Exp $
 
 .include <bsd.own.mk>
 
@@ -13,10 +13,13 @@
 TESTS_C+=      t_strchr
 TESTS_C+=      t_strcmp
 TESTS_C+=      t_strcpy
+TESTS_C+=      t_strcspn
 TESTS_C+=      t_strerror
 TESTS_C+=      t_stresep
 TESTS_C+=      t_strlen
+TESTS_C+=      t_strpbrk
 TESTS_C+=      t_strrchr
+TESTS_C+=      t_strspn
 TESTS_C+=      t_swab
 
 WARNS=         4
diff -r 0f0fee224cc4 -r d911d6db4551 tests/lib/libc/string/t_strcspn.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/string/t_strcspn.c Mon Nov 21 23:50:44 2011 +0000
@@ -0,0 +1,58 @@
+/*     $NetBSD: t_strcspn.c,v 1.1 2011/11/21 23:50:45 joerg Exp $      */
+
+/*-



Home | Main Index | Thread Index | Old Index