diff options
| author | joerg <joerg@NetBSD.org> | 2011-11-21 23:50:44 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2011-11-21 23:50:44 +0000 |
| commit | cf5b206fe31d956c20cd5d331a7352f202f2d265 (patch) | |
| tree | 75fe92e8649cd372f3fd746580e2bac9d6c8bb61 /tests/lib | |
| parent | b5df9b6700fd304520105359d6fc03632f56931d (diff) | |
Add test cases for strcspn, strpbrk, strspn, wcscspn, wcspbrk and
wcsspn.
Diffstat (limited to 'tests/lib')
| -rw-r--r-- | tests/lib/libc/locale/Makefile | 5 | ||||
| -rw-r--r-- | tests/lib/libc/locale/t_wcscspn.c | 58 | ||||
| -rw-r--r-- | tests/lib/libc/locale/t_wcspbrk.c | 62 | ||||
| -rw-r--r-- | tests/lib/libc/locale/t_wcsspn.c | 60 | ||||
| -rw-r--r-- | tests/lib/libc/string/Makefile | 5 | ||||
| -rw-r--r-- | tests/lib/libc/string/t_strcspn.c | 58 | ||||
| -rw-r--r-- | tests/lib/libc/string/t_strpbrk.c | 62 | ||||
| -rw-r--r-- | tests/lib/libc/string/t_strspn.c | 60 |
8 files changed, 368 insertions, 2 deletions
diff --git a/tests/lib/libc/locale/Makefile b/tests/lib/libc/locale/Makefile index 296b7ecf205..45671f76f92 100644 --- a/tests/lib/libc/locale/Makefile +++ b/tests/lib/libc/locale/Makefile @@ -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 @@ TESTSDIR= ${TESTSBASE}/lib/libc/locale 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 --git a/tests/lib/libc/locale/t_wcscspn.c b/tests/lib/libc/locale/t_wcscspn.c new file mode 100644 index 00000000000..10756b5cc4e --- /dev/null +++ b/tests/lib/libc/locale/t_wcscspn.c @@ -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 --git a/tests/lib/libc/locale/t_wcspbrk.c b/tests/lib/libc/locale/t_wcspbrk.c new file mode 100644 index 00000000000..57c1ac54be3 --- /dev/null +++ b/tests/lib/libc/locale/t_wcspbrk.c @@ -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 --git a/tests/lib/libc/locale/t_wcsspn.c b/tests/lib/libc/locale/t_wcsspn.c new file mode 100644 index 00000000000..2083650b331 --- /dev/null +++ b/tests/lib/libc/locale/t_wcsspn.c @@ -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 --git a/tests/lib/libc/string/Makefile b/tests/lib/libc/string/Makefile index ba4b2700543..9bd1959488d 100644 --- a/tests/lib/libc/string/Makefile +++ b/tests/lib/libc/string/Makefile @@ -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_strcat 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 --git a/tests/lib/libc/string/t_strcspn.c b/tests/lib/libc/string/t_strcspn.c new file mode 100644 index 00000000000..d38cdb43939 --- /dev/null +++ b/tests/lib/libc/string/t_strcspn.c @@ -0,0 +1,58 @@ +/* $NetBSD: t_strcspn.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_strcspn.c,v 1.1 2011/11/21 23:50:45 joerg Exp $"); + +#include <atf-c.h> +#include <string.h> + +ATF_TC(strcspn); +ATF_TC_HEAD(strcspn, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test strcspn(3)"); +} + +ATF_TC_BODY(strcspn, tc) +{ + ATF_CHECK_EQ(strcspn("abcdefghijklmnop", ""), 16); + ATF_CHECK_EQ(strcspn("abcdefghijklmnop", "a"), 0); + ATF_CHECK_EQ(strcspn("abcdefghijklmnop", "b"), 1); + ATF_CHECK_EQ(strcspn("abcdefghijklmnop", "cd"), 2); + ATF_CHECK_EQ(strcspn("abcdefghijklmnop", "qrstuvwxyz"), 16); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, strcspn); + return atf_no_error(); +} diff --git a/tests/lib/libc/string/t_strpbrk.c b/tests/lib/libc/string/t_strpbrk.c new file mode 100644 index 00000000000..d0f2d9b5d0b --- /dev/null +++ b/tests/lib/libc/string/t_strpbrk.c @@ -0,0 +1,62 @@ +/* $NetBSD: t_strpbrk.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_strpbrk.c,v 1.1 2011/11/21 23:50:45 joerg Exp $"); + +#include <atf-c.h> +#include <string.h> + +ATF_TC(strpbrk); +ATF_TC_HEAD(strpbrk, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test strpbrk(3)"); +} + +ATF_TC_BODY(strpbrk, tc) +{ + static const char s[] = "abcdefghijklmnop"; + + ATF_CHECK_EQ(strpbrk(s, ""), NULL); + ATF_CHECK_EQ(strpbrk(s, "qrst"), NULL); + ATF_CHECK_EQ(strpbrk(s, "a"), s); + ATF_CHECK_EQ(strpbrk(s, "b"), s + 1); + ATF_CHECK_EQ(strpbrk(s, "ab"), s); + ATF_CHECK_EQ(strpbrk(s, "cdef"), s + 2); + ATF_CHECK_EQ(strpbrk(s, "fedc"), s + 2); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, strpbrk); + return atf_no_error(); +} diff --git a/tests/lib/libc/string/t_strspn.c b/tests/lib/libc/string/t_strspn.c new file mode 100644 index 00000000000..6782181b079 --- /dev/null +++ b/tests/lib/libc/string/t_strspn.c @@ -0,0 +1,60 @@ +/* $NetBSD: t_strspn.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_strspn.c,v 1.1 2011/11/21 23:50:45 joerg Exp $"); + +#include <atf-c.h> +#include <string.h> + +ATF_TC(strspn); +ATF_TC_HEAD(strspn, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test strspn(3)"); +} + +ATF_TC_BODY(strspn, tc) +{ + ATF_CHECK_EQ(strspn("abcdefghijklmnop", ""), 0); + ATF_CHECK_EQ(strspn("abcdefghijklmnop", "a"), 1); + ATF_CHECK_EQ(strspn("abcdefghijklmnop", "b"), 0); + ATF_CHECK_EQ(strspn("abcdefghijklmnop", "ab"), 2); + ATF_CHECK_EQ(strspn("abcdefghijklmnop", "abc"), 3); + ATF_CHECK_EQ(strspn("abcdefghijklmnop", "abce"), 3); + ATF_CHECK_EQ(strspn("abcdefghijklmnop", "abcdefghijklmnop"), 16); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, strspn); + return atf_no_error(); +} |
