xref: /netbsd-src/tests/lib/libc/string/t_strcspn.c (revision 9cf8fb38acdc6689220209523a2daa0f6bf3b658)
1*9cf8fb38Sjoerg /*	$NetBSD: t_strcspn.c,v 1.1 2011/11/21 23:50:45 joerg Exp $	*/
2*9cf8fb38Sjoerg 
3*9cf8fb38Sjoerg /*-
4*9cf8fb38Sjoerg  * Copyright (c) 2011 The NetBSD Foundation, Inc.
5*9cf8fb38Sjoerg  * All rights reserved.
6*9cf8fb38Sjoerg  *
7*9cf8fb38Sjoerg  * This code is derived from software contributed to The NetBSD Foundation
8*9cf8fb38Sjoerg  * by Joerg Sonnenberger.
9*9cf8fb38Sjoerg  *
10*9cf8fb38Sjoerg  * Redistribution and use in source and binary forms, with or without
11*9cf8fb38Sjoerg  * modification, are permitted provided that the following conditions
12*9cf8fb38Sjoerg  * are met:
13*9cf8fb38Sjoerg  * 1. Redistributions of source code must retain the above copyright
14*9cf8fb38Sjoerg  *    notice, this list of conditions and the following disclaimer.
15*9cf8fb38Sjoerg  * 2. Redistributions in binary form must reproduce the above copyright
16*9cf8fb38Sjoerg  *    notice, this list of conditions and the following disclaimer in the
17*9cf8fb38Sjoerg  *    documentation and/or other materials provided with the distribution.
18*9cf8fb38Sjoerg  *
19*9cf8fb38Sjoerg  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*9cf8fb38Sjoerg  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*9cf8fb38Sjoerg  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*9cf8fb38Sjoerg  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*9cf8fb38Sjoerg  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*9cf8fb38Sjoerg  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*9cf8fb38Sjoerg  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*9cf8fb38Sjoerg  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*9cf8fb38Sjoerg  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*9cf8fb38Sjoerg  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*9cf8fb38Sjoerg  * POSSIBILITY OF SUCH DAMAGE.
30*9cf8fb38Sjoerg  */
31*9cf8fb38Sjoerg 
32*9cf8fb38Sjoerg #include <sys/cdefs.h>
33*9cf8fb38Sjoerg __RCSID("$NetBSD: t_strcspn.c,v 1.1 2011/11/21 23:50:45 joerg Exp $");
34*9cf8fb38Sjoerg 
35*9cf8fb38Sjoerg #include <atf-c.h>
36*9cf8fb38Sjoerg #include <string.h>
37*9cf8fb38Sjoerg 
38*9cf8fb38Sjoerg ATF_TC(strcspn);
ATF_TC_HEAD(strcspn,tc)39*9cf8fb38Sjoerg ATF_TC_HEAD(strcspn, tc)
40*9cf8fb38Sjoerg {
41*9cf8fb38Sjoerg 	atf_tc_set_md_var(tc, "descr", "Test strcspn(3)");
42*9cf8fb38Sjoerg }
43*9cf8fb38Sjoerg 
ATF_TC_BODY(strcspn,tc)44*9cf8fb38Sjoerg ATF_TC_BODY(strcspn, tc)
45*9cf8fb38Sjoerg {
46*9cf8fb38Sjoerg 	ATF_CHECK_EQ(strcspn("abcdefghijklmnop", ""), 16);
47*9cf8fb38Sjoerg 	ATF_CHECK_EQ(strcspn("abcdefghijklmnop", "a"), 0);
48*9cf8fb38Sjoerg 	ATF_CHECK_EQ(strcspn("abcdefghijklmnop", "b"), 1);
49*9cf8fb38Sjoerg 	ATF_CHECK_EQ(strcspn("abcdefghijklmnop", "cd"), 2);
50*9cf8fb38Sjoerg 	ATF_CHECK_EQ(strcspn("abcdefghijklmnop", "qrstuvwxyz"), 16);
51*9cf8fb38Sjoerg }
52*9cf8fb38Sjoerg 
ATF_TP_ADD_TCS(tp)53*9cf8fb38Sjoerg ATF_TP_ADD_TCS(tp)
54*9cf8fb38Sjoerg {
55*9cf8fb38Sjoerg 
56*9cf8fb38Sjoerg 	ATF_TP_ADD_TC(tp, strcspn);
57*9cf8fb38Sjoerg 	return atf_no_error();
58*9cf8fb38Sjoerg }
59