xref: /minix3/tests/lib/libc/time/t_strptime.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /* $NetBSD: t_strptime.c,v 1.6 2015/07/04 13:36:25 christos Exp $ */
211be35a1SLionel Sambuc 
311be35a1SLionel Sambuc /*-
411be35a1SLionel Sambuc  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
511be35a1SLionel Sambuc  * All rights reserved.
611be35a1SLionel Sambuc  *
711be35a1SLionel Sambuc  * This code is derived from software contributed to The NetBSD Foundation
811be35a1SLionel Sambuc  * by David Laight.
911be35a1SLionel Sambuc  *
1011be35a1SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
1111be35a1SLionel Sambuc  * modification, are permitted provided that the following conditions
1211be35a1SLionel Sambuc  * are met:
1311be35a1SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
1411be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
1511be35a1SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
1611be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
1711be35a1SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
1811be35a1SLionel Sambuc  *
1911be35a1SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2011be35a1SLionel Sambuc  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2111be35a1SLionel Sambuc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2211be35a1SLionel Sambuc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2311be35a1SLionel Sambuc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2411be35a1SLionel Sambuc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2511be35a1SLionel Sambuc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2611be35a1SLionel Sambuc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2711be35a1SLionel Sambuc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2811be35a1SLionel Sambuc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2911be35a1SLionel Sambuc  * POSSIBILITY OF SUCH DAMAGE.
3011be35a1SLionel Sambuc  */
3111be35a1SLionel Sambuc 
3211be35a1SLionel Sambuc #include <sys/cdefs.h>
3311be35a1SLionel Sambuc __COPYRIGHT("@(#) Copyright (c) 2008\
3411be35a1SLionel Sambuc  The NetBSD Foundation, inc. All rights reserved.");
35*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: t_strptime.c,v 1.6 2015/07/04 13:36:25 christos Exp $");
3611be35a1SLionel Sambuc 
3711be35a1SLionel Sambuc #include <time.h>
3811be35a1SLionel Sambuc 
3911be35a1SLionel Sambuc #include <atf-c.h>
4011be35a1SLionel Sambuc 
4111be35a1SLionel Sambuc static void
h_pass(const char * buf,const char * fmt,int len,int tm_sec,int tm_min,int tm_hour,int tm_mday,int tm_mon,int tm_year,int tm_wday,int tm_yday)4211be35a1SLionel Sambuc h_pass(const char *buf, const char *fmt, int len,
4311be35a1SLionel Sambuc     int tm_sec, int tm_min, int tm_hour, int tm_mday,
4411be35a1SLionel Sambuc     int tm_mon, int tm_year, int tm_wday, int tm_yday)
4511be35a1SLionel Sambuc {
4611be35a1SLionel Sambuc 	struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
4711be35a1SLionel Sambuc 	const char *ret, *exp;
4811be35a1SLionel Sambuc 
4911be35a1SLionel Sambuc 	exp = buf + len;
5011be35a1SLionel Sambuc 	ret = strptime(buf, fmt, &tm);
5111be35a1SLionel Sambuc 
5211be35a1SLionel Sambuc 	ATF_REQUIRE_MSG(ret == exp,
5311be35a1SLionel Sambuc 	    "strptime(\"%s\", \"%s\", tm): incorrect return code: "
5411be35a1SLionel Sambuc 	    "expected: %p, got: %p", buf, fmt, exp, ret);
5511be35a1SLionel Sambuc 
5611be35a1SLionel Sambuc #define H_REQUIRE_FIELD(field)						\
5711be35a1SLionel Sambuc 		ATF_REQUIRE_MSG(tm.field == field,			\
5811be35a1SLionel Sambuc 		    "strptime(\"%s\", \"%s\", tm): incorrect %s: "	\
5911be35a1SLionel Sambuc 		    "expected: %d, but got: %d", buf, fmt,		\
6011be35a1SLionel Sambuc 		    ___STRING(field), field, tm.field)
6111be35a1SLionel Sambuc 
6211be35a1SLionel Sambuc 	H_REQUIRE_FIELD(tm_sec);
6311be35a1SLionel Sambuc 	H_REQUIRE_FIELD(tm_min);
6411be35a1SLionel Sambuc 	H_REQUIRE_FIELD(tm_hour);
6511be35a1SLionel Sambuc 	H_REQUIRE_FIELD(tm_mday);
6611be35a1SLionel Sambuc 	H_REQUIRE_FIELD(tm_mon);
6711be35a1SLionel Sambuc 	H_REQUIRE_FIELD(tm_year);
6811be35a1SLionel Sambuc 	H_REQUIRE_FIELD(tm_wday);
6911be35a1SLionel Sambuc 	H_REQUIRE_FIELD(tm_yday);
7011be35a1SLionel Sambuc 
7111be35a1SLionel Sambuc #undef H_REQUIRE_FIELD
7211be35a1SLionel Sambuc }
7311be35a1SLionel Sambuc 
7411be35a1SLionel Sambuc static void
h_fail(const char * buf,const char * fmt)7511be35a1SLionel Sambuc h_fail(const char *buf, const char *fmt)
7611be35a1SLionel Sambuc {
7711be35a1SLionel Sambuc 	struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
7811be35a1SLionel Sambuc 
7911be35a1SLionel Sambuc 	ATF_REQUIRE_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", "
8011be35a1SLionel Sambuc 	    "\"%s\", &tm) should fail, but it didn't", buf, fmt);
8111be35a1SLionel Sambuc }
8211be35a1SLionel Sambuc 
8311be35a1SLionel Sambuc ATF_TC(common);
8411be35a1SLionel Sambuc 
ATF_TC_HEAD(common,tc)8511be35a1SLionel Sambuc ATF_TC_HEAD(common, tc)
8611be35a1SLionel Sambuc {
8711be35a1SLionel Sambuc 
8811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Checks strptime(3): various checks");
8911be35a1SLionel Sambuc }
9011be35a1SLionel Sambuc 
ATF_TC_BODY(common,tc)9111be35a1SLionel Sambuc ATF_TC_BODY(common, tc)
9211be35a1SLionel Sambuc {
9311be35a1SLionel Sambuc 
9411be35a1SLionel Sambuc 	h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y",
95*0a6a1f1dSLionel Sambuc 		24, 46, 27, 23, 20, 0, 98, 2, 19);
9611be35a1SLionel Sambuc 	h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y",
97*0a6a1f1dSLionel Sambuc 		24, 46, 27, 23, 20, 0, 98, 2, 19);
9811be35a1SLionel Sambuc 	h_pass("Tue Jan 20 23:27:46 1998", "%c",
99*0a6a1f1dSLionel Sambuc 		24, 46, 27, 23, 20, 0, 98, 2, 19);
10011be35a1SLionel Sambuc 	h_pass("Fri Mar  4 20:05:34 2005", "%a %b %e %H:%M:%S %Y",
101*0a6a1f1dSLionel Sambuc 		24, 34, 5, 20, 4, 2, 105, 5, 62);
10211be35a1SLionel Sambuc 	h_pass("5\t3  4 8pm:05:34 2005", "%w%n%m%t%d%n%k%p:%M:%S %Y",
103*0a6a1f1dSLionel Sambuc 		21, 34, 5, 20, 4, 2, 105, 5, 62);
10411be35a1SLionel Sambuc 	h_pass("Fri Mar  4 20:05:34 2005", "%c",
105*0a6a1f1dSLionel Sambuc 		24, 34, 5, 20, 4, 2, 105, 5, 62);
10611be35a1SLionel Sambuc }
10711be35a1SLionel Sambuc 
10811be35a1SLionel Sambuc ATF_TC(day);
10911be35a1SLionel Sambuc 
ATF_TC_HEAD(day,tc)11011be35a1SLionel Sambuc ATF_TC_HEAD(day, tc)
11111be35a1SLionel Sambuc {
11211be35a1SLionel Sambuc 
113*0a6a1f1dSLionel Sambuc 	atf_tc_set_md_var(tc, "descr",
114*0a6a1f1dSLionel Sambuc 			  "Checks strptime(3) day name conversions [aA]");
11511be35a1SLionel Sambuc }
11611be35a1SLionel Sambuc 
ATF_TC_BODY(day,tc)11711be35a1SLionel Sambuc ATF_TC_BODY(day, tc)
11811be35a1SLionel Sambuc {
11911be35a1SLionel Sambuc 
12011be35a1SLionel Sambuc 	h_pass("Sun", "%a", 3, -1, -1, -1, -1, -1, -1, 0, -1);
12111be35a1SLionel Sambuc 	h_pass("Sunday", "%a", 6, -1, -1, -1, -1, -1, -1, 0, -1);
12211be35a1SLionel Sambuc 	h_pass("Mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
12311be35a1SLionel Sambuc 	h_pass("Monday", "%a", 6, -1, -1, -1, -1, -1, -1, 1, -1);
12411be35a1SLionel Sambuc 	h_pass("Tue", "%a", 3, -1, -1, -1, -1, -1, -1, 2, -1);
12511be35a1SLionel Sambuc 	h_pass("Tuesday", "%a", 7, -1, -1, -1, -1, -1, -1, 2, -1);
12611be35a1SLionel Sambuc 	h_pass("Wed", "%a", 3, -1, -1, -1, -1, -1, -1, 3, -1);
12711be35a1SLionel Sambuc 	h_pass("Wednesday", "%a", 9, -1, -1, -1, -1, -1, -1, 3, -1);
12811be35a1SLionel Sambuc 	h_pass("Thu", "%a", 3, -1, -1, -1, -1, -1, -1, 4, -1);
12911be35a1SLionel Sambuc 	h_pass("Thursday", "%a", 8, -1, -1, -1, -1, -1, -1, 4, -1);
13011be35a1SLionel Sambuc 	h_pass("Fri", "%a", 3, -1, -1, -1, -1, -1, -1, 5, -1);
13111be35a1SLionel Sambuc 	h_pass("Friday", "%a", 6, -1, -1, -1, -1, -1, -1, 5, -1);
13211be35a1SLionel Sambuc 	h_pass("Sat", "%a", 3, -1, -1, -1, -1, -1, -1, 6, -1);
13311be35a1SLionel Sambuc 	h_pass("Saturday", "%a", 8, -1, -1, -1, -1, -1, -1, 6, -1);
13411be35a1SLionel Sambuc 	h_pass("Saturn", "%a", 3, -1, -1, -1, -1, -1, -1, 6, -1);
13511be35a1SLionel Sambuc 	h_fail("Moon", "%a");
13611be35a1SLionel Sambuc 	h_pass("Sun", "%A", 3, -1, -1, -1, -1, -1, -1, 0, -1);
13711be35a1SLionel Sambuc 	h_pass("Sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
13811be35a1SLionel Sambuc 	h_pass("Mon", "%A", 3, -1, -1, -1, -1, -1, -1, 1, -1);
13911be35a1SLionel Sambuc 	h_pass("Monday", "%A", 6, -1, -1, -1, -1, -1, -1, 1, -1);
14011be35a1SLionel Sambuc 	h_pass("Tue", "%A", 3, -1, -1, -1, -1, -1, -1, 2, -1);
14111be35a1SLionel Sambuc 	h_pass("Tuesday", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
14211be35a1SLionel Sambuc 	h_pass("Wed", "%A", 3, -1, -1, -1, -1, -1, -1, 3, -1);
14311be35a1SLionel Sambuc 	h_pass("Wednesday", "%A", 9, -1, -1, -1, -1, -1, -1, 3, -1);
14411be35a1SLionel Sambuc 	h_pass("Thu", "%A", 3, -1, -1, -1, -1, -1, -1, 4, -1);
14511be35a1SLionel Sambuc 	h_pass("Thursday", "%A", 8, -1, -1, -1, -1, -1, -1, 4, -1);
14611be35a1SLionel Sambuc 	h_pass("Fri", "%A", 3, -1, -1, -1, -1, -1, -1, 5, -1);
14711be35a1SLionel Sambuc 	h_pass("Friday", "%A", 6, -1, -1, -1, -1, -1, -1, 5, -1);
14811be35a1SLionel Sambuc 	h_pass("Sat", "%A", 3, -1, -1, -1, -1, -1, -1, 6, -1);
14911be35a1SLionel Sambuc 	h_pass("Saturday", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
15011be35a1SLionel Sambuc 	h_pass("Saturn", "%A", 3, -1, -1, -1, -1, -1, -1, 6, -1);
15111be35a1SLionel Sambuc 	h_fail("Moon", "%A");
15211be35a1SLionel Sambuc 
15311be35a1SLionel Sambuc 	h_pass("mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
15411be35a1SLionel Sambuc 	h_pass("tueSDay", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
15511be35a1SLionel Sambuc 	h_pass("sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
15611be35a1SLionel Sambuc 	h_fail("sunday", "%EA");
15711be35a1SLionel Sambuc 	h_pass("SaturDay", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
15811be35a1SLionel Sambuc 	h_fail("SaturDay", "%OA");
15911be35a1SLionel Sambuc }
16011be35a1SLionel Sambuc 
161*0a6a1f1dSLionel Sambuc ATF_TC(hour);
162*0a6a1f1dSLionel Sambuc 
ATF_TC_HEAD(hour,tc)163*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(hour, tc)
164*0a6a1f1dSLionel Sambuc {
165*0a6a1f1dSLionel Sambuc 
166*0a6a1f1dSLionel Sambuc 	atf_tc_set_md_var(tc, "descr",
167*0a6a1f1dSLionel Sambuc 			  "Checks strptime(3) hour conversions [IH]");
168*0a6a1f1dSLionel Sambuc }
169*0a6a1f1dSLionel Sambuc 
ATF_TC_BODY(hour,tc)170*0a6a1f1dSLionel Sambuc ATF_TC_BODY(hour, tc)
171*0a6a1f1dSLionel Sambuc {
172*0a6a1f1dSLionel Sambuc 
173*0a6a1f1dSLionel Sambuc 	h_fail("00", "%I");
174*0a6a1f1dSLionel Sambuc 	h_fail("13", "%I");
175*0a6a1f1dSLionel Sambuc 
176*0a6a1f1dSLionel Sambuc 	h_pass("00", "%H", 2, -1, -1, 0, -1, -1, -1, -1, -1);
177*0a6a1f1dSLionel Sambuc 	h_pass("12", "%H", 2, -1, -1, 12, -1, -1, -1, -1, -1);
178*0a6a1f1dSLionel Sambuc 	h_pass("23", "%H", 2, -1, -1, 23, -1, -1, -1, -1, -1);
179*0a6a1f1dSLionel Sambuc 	h_fail("24", "%H");
180*0a6a1f1dSLionel Sambuc }
181*0a6a1f1dSLionel Sambuc 
182*0a6a1f1dSLionel Sambuc 
18311be35a1SLionel Sambuc ATF_TC(month);
18411be35a1SLionel Sambuc 
ATF_TC_HEAD(month,tc)18511be35a1SLionel Sambuc ATF_TC_HEAD(month, tc)
18611be35a1SLionel Sambuc {
18711be35a1SLionel Sambuc 
188*0a6a1f1dSLionel Sambuc 	atf_tc_set_md_var(tc, "descr",
189*0a6a1f1dSLionel Sambuc 			  "Checks strptime(3) month name conversions [bB]");
19011be35a1SLionel Sambuc }
19111be35a1SLionel Sambuc 
ATF_TC_BODY(month,tc)19211be35a1SLionel Sambuc ATF_TC_BODY(month, tc)
19311be35a1SLionel Sambuc {
19411be35a1SLionel Sambuc 
19511be35a1SLionel Sambuc 	h_pass("Jan", "%b", 3, -1, -1, -1, -1, 0, -1, -1, -1);
19611be35a1SLionel Sambuc 	h_pass("January", "%b", 7, -1, -1, -1, -1, 0, -1, -1, -1);
19711be35a1SLionel Sambuc 	h_pass("Feb", "%b", 3, -1, -1, -1, -1, 1, -1, -1, -1);
19811be35a1SLionel Sambuc 	h_pass("February", "%b", 8, -1, -1, -1, -1, 1, -1, -1, -1);
19911be35a1SLionel Sambuc 	h_pass("Mar", "%b", 3, -1, -1, -1, -1, 2, -1, -1, -1);
20011be35a1SLionel Sambuc 	h_pass("March", "%b", 5, -1, -1, -1, -1, 2, -1, -1, -1);
20111be35a1SLionel Sambuc 	h_pass("Apr", "%b", 3, -1, -1, -1, -1, 3, -1, -1, -1);
20211be35a1SLionel Sambuc 	h_pass("April", "%b", 5, -1, -1, -1, -1, 3, -1, -1, -1);
20311be35a1SLionel Sambuc 	h_pass("May", "%b", 3, -1, -1, -1, -1, 4, -1, -1, -1);
20411be35a1SLionel Sambuc 	h_pass("Jun", "%b", 3, -1, -1, -1, -1, 5, -1, -1, -1);
20511be35a1SLionel Sambuc 	h_pass("June", "%b", 4, -1, -1, -1, -1, 5, -1, -1, -1);
20611be35a1SLionel Sambuc 	h_pass("Jul", "%b", 3, -1, -1, -1, -1, 6, -1, -1, -1);
20711be35a1SLionel Sambuc 	h_pass("July", "%b", 4, -1, -1, -1, -1, 6, -1, -1, -1);
20811be35a1SLionel Sambuc 	h_pass("Aug", "%b", 3, -1, -1, -1, -1, 7, -1, -1, -1);
20911be35a1SLionel Sambuc 	h_pass("August", "%b", 6, -1, -1, -1, -1, 7, -1, -1, -1);
21011be35a1SLionel Sambuc 	h_pass("Sep", "%b", 3, -1, -1, -1, -1, 8, -1, -1, -1);
21111be35a1SLionel Sambuc 	h_pass("September", "%b", 9, -1, -1, -1, -1, 8, -1, -1, -1);
21211be35a1SLionel Sambuc 	h_pass("Oct", "%b", 3, -1, -1, -1, -1, 9, -1, -1, -1);
21311be35a1SLionel Sambuc 	h_pass("October", "%b", 7, -1, -1, -1, -1, 9, -1, -1, -1);
21411be35a1SLionel Sambuc 	h_pass("Nov", "%b", 3, -1, -1, -1, -1, 10, -1, -1, -1);
21511be35a1SLionel Sambuc 	h_pass("November", "%b", 8, -1, -1, -1, -1, 10, -1, -1, -1);
21611be35a1SLionel Sambuc 	h_pass("Dec", "%b", 3, -1, -1, -1, -1, 11, -1, -1, -1);
21711be35a1SLionel Sambuc 	h_pass("December", "%b", 8, -1, -1, -1, -1, 11, -1, -1, -1);
21811be35a1SLionel Sambuc 	h_pass("Mayor", "%b", 3, -1, -1, -1, -1, 4, -1, -1, -1);
21911be35a1SLionel Sambuc 	h_pass("Mars", "%b", 3, -1, -1, -1, -1, 2, -1, -1, -1);
22011be35a1SLionel Sambuc 	h_fail("Rover", "%b");
22111be35a1SLionel Sambuc 	h_pass("Jan", "%B", 3, -1, -1, -1, -1, 0, -1, -1, -1);
22211be35a1SLionel Sambuc 	h_pass("January", "%B", 7, -1, -1, -1, -1, 0, -1, -1, -1);
22311be35a1SLionel Sambuc 	h_pass("Feb", "%B", 3, -1, -1, -1, -1, 1, -1, -1, -1);
22411be35a1SLionel Sambuc 	h_pass("February", "%B", 8, -1, -1, -1, -1, 1, -1, -1, -1);
22511be35a1SLionel Sambuc 	h_pass("Mar", "%B", 3, -1, -1, -1, -1, 2, -1, -1, -1);
22611be35a1SLionel Sambuc 	h_pass("March", "%B", 5, -1, -1, -1, -1, 2, -1, -1, -1);
22711be35a1SLionel Sambuc 	h_pass("Apr", "%B", 3, -1, -1, -1, -1, 3, -1, -1, -1);
22811be35a1SLionel Sambuc 	h_pass("April", "%B", 5, -1, -1, -1, -1, 3, -1, -1, -1);
22911be35a1SLionel Sambuc 	h_pass("May", "%B", 3, -1, -1, -1, -1, 4, -1, -1, -1);
23011be35a1SLionel Sambuc 	h_pass("Jun", "%B", 3, -1, -1, -1, -1, 5, -1, -1, -1);
23111be35a1SLionel Sambuc 	h_pass("June", "%B", 4, -1, -1, -1, -1, 5, -1, -1, -1);
23211be35a1SLionel Sambuc 	h_pass("Jul", "%B", 3, -1, -1, -1, -1, 6, -1, -1, -1);
23311be35a1SLionel Sambuc 	h_pass("July", "%B", 4, -1, -1, -1, -1, 6, -1, -1, -1);
23411be35a1SLionel Sambuc 	h_pass("Aug", "%B", 3, -1, -1, -1, -1, 7, -1, -1, -1);
23511be35a1SLionel Sambuc 	h_pass("August", "%B", 6, -1, -1, -1, -1, 7, -1, -1, -1);
23611be35a1SLionel Sambuc 	h_pass("Sep", "%B", 3, -1, -1, -1, -1, 8, -1, -1, -1);
23711be35a1SLionel Sambuc 	h_pass("September", "%B", 9, -1, -1, -1, -1, 8, -1, -1, -1);
23811be35a1SLionel Sambuc 	h_pass("Oct", "%B", 3, -1, -1, -1, -1, 9, -1, -1, -1);
23911be35a1SLionel Sambuc 	h_pass("October", "%B", 7, -1, -1, -1, -1, 9, -1, -1, -1);
24011be35a1SLionel Sambuc 	h_pass("Nov", "%B", 3, -1, -1, -1, -1, 10, -1, -1, -1);
24111be35a1SLionel Sambuc 	h_pass("November", "%B", 8, -1, -1, -1, -1, 10, -1, -1, -1);
24211be35a1SLionel Sambuc 	h_pass("Dec", "%B", 3, -1, -1, -1, -1, 11, -1, -1, -1);
24311be35a1SLionel Sambuc 	h_pass("December", "%B", 8, -1, -1, -1, -1, 11, -1, -1, -1);
24411be35a1SLionel Sambuc 	h_pass("Mayor", "%B", 3, -1, -1, -1, -1, 4, -1, -1, -1);
24511be35a1SLionel Sambuc 	h_pass("Mars", "%B", 3, -1, -1, -1, -1, 2, -1, -1, -1);
24611be35a1SLionel Sambuc 	h_fail("Rover", "%B");
24711be35a1SLionel Sambuc 
24811be35a1SLionel Sambuc 	h_pass("september", "%b", 9, -1, -1, -1, -1, 8, -1, -1, -1);
24911be35a1SLionel Sambuc 	h_pass("septembe", "%B", 3, -1, -1, -1, -1, 8, -1, -1, -1);
25011be35a1SLionel Sambuc }
25111be35a1SLionel Sambuc 
252*0a6a1f1dSLionel Sambuc ATF_TC(seconds);
253*0a6a1f1dSLionel Sambuc 
ATF_TC_HEAD(seconds,tc)254*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(seconds, tc)
255*0a6a1f1dSLionel Sambuc {
256*0a6a1f1dSLionel Sambuc 
257*0a6a1f1dSLionel Sambuc 	atf_tc_set_md_var(tc, "descr",
258*0a6a1f1dSLionel Sambuc 			  "Checks strptime(3) seconds conversions [S]");
259*0a6a1f1dSLionel Sambuc }
260*0a6a1f1dSLionel Sambuc 
ATF_TC_BODY(seconds,tc)261*0a6a1f1dSLionel Sambuc ATF_TC_BODY(seconds, tc)
262*0a6a1f1dSLionel Sambuc {
263*0a6a1f1dSLionel Sambuc 
264*0a6a1f1dSLionel Sambuc 	h_pass("0", "%S", 1, 0, -1, -1, -1, -1, -1, -1, -1);
265*0a6a1f1dSLionel Sambuc 	h_pass("59", "%S", 2, 59, -1, -1, -1, -1, -1, -1, -1);
266*0a6a1f1dSLionel Sambuc 	h_pass("60", "%S", 2, 60, -1, -1, -1, -1, -1, -1, -1);
267*0a6a1f1dSLionel Sambuc 	h_pass("61", "%S", 2, 61, -1, -1, -1, -1, -1, -1, -1);
268*0a6a1f1dSLionel Sambuc 	h_fail("62", "%S");
269*0a6a1f1dSLionel Sambuc }
270*0a6a1f1dSLionel Sambuc 
271*0a6a1f1dSLionel Sambuc ATF_TC(year);
272*0a6a1f1dSLionel Sambuc 
ATF_TC_HEAD(year,tc)273*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(year, tc)
274*0a6a1f1dSLionel Sambuc {
275*0a6a1f1dSLionel Sambuc 
276*0a6a1f1dSLionel Sambuc 	atf_tc_set_md_var(tc, "descr",
277*0a6a1f1dSLionel Sambuc 			  "Checks strptime(3) century/year conversions [CyY]");
278*0a6a1f1dSLionel Sambuc }
279*0a6a1f1dSLionel Sambuc 
ATF_TC_BODY(year,tc)280*0a6a1f1dSLionel Sambuc ATF_TC_BODY(year, tc)
281*0a6a1f1dSLionel Sambuc {
282*0a6a1f1dSLionel Sambuc 
283*0a6a1f1dSLionel Sambuc 	h_pass("x20y", "x%Cy", 4, -1, -1, -1, -1, -1, 100, -1, -1);
284*0a6a1f1dSLionel Sambuc 	h_pass("x84y", "x%yy", 4, -1, -1, -1, -1, -1, 84, -1, -1);
285*0a6a1f1dSLionel Sambuc 	h_pass("x2084y", "x%C%yy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
286*0a6a1f1dSLionel Sambuc 	h_pass("x8420y", "x%y%Cy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
287*0a6a1f1dSLionel Sambuc 	h_pass("%20845", "%%%C%y5", 6, -1, -1, -1, -1, -1, 184, -1, -1);
288*0a6a1f1dSLionel Sambuc 	h_fail("%", "%E%");
289*0a6a1f1dSLionel Sambuc 
290*0a6a1f1dSLionel Sambuc 	h_pass("1980", "%Y", 4, -1, -1, -1, -1, -1, 80, -1, -1);
291*0a6a1f1dSLionel Sambuc 	h_pass("1980", "%EY", 4, -1, -1, -1, -1, -1, 80, -1, -1);
292*0a6a1f1dSLionel Sambuc }
293*0a6a1f1dSLionel Sambuc 
ATF_TP_ADD_TCS(tp)29411be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
29511be35a1SLionel Sambuc {
29611be35a1SLionel Sambuc 
29711be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, common);
29811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, day);
299*0a6a1f1dSLionel Sambuc 	ATF_TP_ADD_TC(tp, hour);
30011be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, month);
301*0a6a1f1dSLionel Sambuc 	ATF_TP_ADD_TC(tp, seconds);
302*0a6a1f1dSLionel Sambuc 	ATF_TP_ADD_TC(tp, year);
30311be35a1SLionel Sambuc 
30411be35a1SLionel Sambuc 	return atf_no_error();
30511be35a1SLionel Sambuc }
306