Add test cases for strcspn, strpbrk, strspn, wcscspn, wcspbrk and
wcsspn.
This commit is contained in:
parent
19166a6288
commit
9cf8fb38ac
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue