1*0a6a1f1dSLionel Sambuc /* $NetBSD: t_strtoi.c,v 1.1 2015/05/01 14:17:56 christos Exp $ */
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc /*-
4*0a6a1f1dSLionel Sambuc * Copyright (c) 2015 The NetBSD Foundation, Inc.
5*0a6a1f1dSLionel Sambuc * All rights reserved.
6*0a6a1f1dSLionel Sambuc *
7*0a6a1f1dSLionel Sambuc * This code is derived from software contributed to The NetBSD Foundation
8*0a6a1f1dSLionel Sambuc * by Jukka Ruohonen.
9*0a6a1f1dSLionel Sambuc *
10*0a6a1f1dSLionel Sambuc * Redistribution and use in source and binary forms, with or without
11*0a6a1f1dSLionel Sambuc * modification, are permitted provided that the following conditions
12*0a6a1f1dSLionel Sambuc * are met:
13*0a6a1f1dSLionel Sambuc * 1. Redistributions of source code must retain the above copyright
14*0a6a1f1dSLionel Sambuc * notice, this list of conditions and the following disclaimer.
15*0a6a1f1dSLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
16*0a6a1f1dSLionel Sambuc * notice, this list of conditions and the following disclaimer in the
17*0a6a1f1dSLionel Sambuc * documentation and/or other materials provided with the distribution.
18*0a6a1f1dSLionel Sambuc *
19*0a6a1f1dSLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*0a6a1f1dSLionel Sambuc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*0a6a1f1dSLionel Sambuc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*0a6a1f1dSLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*0a6a1f1dSLionel Sambuc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*0a6a1f1dSLionel Sambuc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*0a6a1f1dSLionel Sambuc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*0a6a1f1dSLionel Sambuc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*0a6a1f1dSLionel Sambuc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*0a6a1f1dSLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*0a6a1f1dSLionel Sambuc * POSSIBILITY OF SUCH DAMAGE.
30*0a6a1f1dSLionel Sambuc */
31*0a6a1f1dSLionel Sambuc
32*0a6a1f1dSLionel Sambuc /*
33*0a6a1f1dSLionel Sambuc * Created by Kamil Rytarowski, vesed on ID:
34*0a6a1f1dSLionel Sambuc * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp
35*0a6a1f1dSLionel Sambuc */
36*0a6a1f1dSLionel Sambuc
37*0a6a1f1dSLionel Sambuc #include <sys/cdefs.h>
38*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: t_strtoi.c,v 1.1 2015/05/01 14:17:56 christos Exp $");
39*0a6a1f1dSLionel Sambuc
40*0a6a1f1dSLionel Sambuc #include <atf-c.h>
41*0a6a1f1dSLionel Sambuc #include <errno.h>
42*0a6a1f1dSLionel Sambuc #include <inttypes.h>
43*0a6a1f1dSLionel Sambuc #include <stdlib.h>
44*0a6a1f1dSLionel Sambuc #include <string.h>
45*0a6a1f1dSLionel Sambuc #include <limits.h>
46*0a6a1f1dSLionel Sambuc
47*0a6a1f1dSLionel Sambuc struct test {
48*0a6a1f1dSLionel Sambuc const char *str;
49*0a6a1f1dSLionel Sambuc intmax_t res;
50*0a6a1f1dSLionel Sambuc int base;
51*0a6a1f1dSLionel Sambuc const char *end;
52*0a6a1f1dSLionel Sambuc intmax_t lo;
53*0a6a1f1dSLionel Sambuc intmax_t hi;
54*0a6a1f1dSLionel Sambuc int rstatus;
55*0a6a1f1dSLionel Sambuc };
56*0a6a1f1dSLionel Sambuc
57*0a6a1f1dSLionel Sambuc static void check(struct test *, intmax_t, char *, int);
58*0a6a1f1dSLionel Sambuc
59*0a6a1f1dSLionel Sambuc static void
check(struct test * t,intmax_t rv,char * end,int rstatus)60*0a6a1f1dSLionel Sambuc check(struct test *t, intmax_t rv, char *end, int rstatus)
61*0a6a1f1dSLionel Sambuc {
62*0a6a1f1dSLionel Sambuc
63*0a6a1f1dSLionel Sambuc if (rv != t->res)
64*0a6a1f1dSLionel Sambuc atf_tc_fail_nonfatal("strtoi(%s, &end, %d, %jd, %jd, &rstatus)"
65*0a6a1f1dSLionel Sambuc " failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv);
66*0a6a1f1dSLionel Sambuc
67*0a6a1f1dSLionel Sambuc if (rstatus != t->rstatus)
68*0a6a1f1dSLionel Sambuc atf_tc_fail_nonfatal("strtoi(%s, &end, %d, %jd, %jd, &rstatus)"
69*0a6a1f1dSLionel Sambuc " failed (rstatus: %d ('%s'))",
70*0a6a1f1dSLionel Sambuc t->str, t->base, t->lo, t->hi, rstatus, strerror(rstatus));
71*0a6a1f1dSLionel Sambuc
72*0a6a1f1dSLionel Sambuc if ((t->end != NULL && strcmp(t->end, end) != 0) ||
73*0a6a1f1dSLionel Sambuc (t->end == NULL && *end != '\0'))
74*0a6a1f1dSLionel Sambuc atf_tc_fail_nonfatal("invalid end pointer ('%s') from "
75*0a6a1f1dSLionel Sambuc "strtoi(%s, &end, %d, %jd, %jd, &rstatus)",
76*0a6a1f1dSLionel Sambuc end, t->str, t->base, t->lo, t->hi);
77*0a6a1f1dSLionel Sambuc }
78*0a6a1f1dSLionel Sambuc
79*0a6a1f1dSLionel Sambuc ATF_TC(strtoi_base);
ATF_TC_HEAD(strtoi_base,tc)80*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(strtoi_base, tc)
81*0a6a1f1dSLionel Sambuc {
82*0a6a1f1dSLionel Sambuc atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases");
83*0a6a1f1dSLionel Sambuc }
84*0a6a1f1dSLionel Sambuc
ATF_TC_BODY(strtoi_base,tc)85*0a6a1f1dSLionel Sambuc ATF_TC_BODY(strtoi_base, tc)
86*0a6a1f1dSLionel Sambuc {
87*0a6a1f1dSLionel Sambuc struct test t[] = {
88*0a6a1f1dSLionel Sambuc { "123456789", 123456789, 0, NULL,
89*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
90*0a6a1f1dSLionel Sambuc { "111010110111100110100010101",123456789, 2, NULL,
91*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
92*0a6a1f1dSLionel Sambuc { "22121022020212200", 123456789, 3, NULL,
93*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
94*0a6a1f1dSLionel Sambuc { "13112330310111", 123456789, 4, NULL,
95*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
96*0a6a1f1dSLionel Sambuc { "223101104124", 123456789, 5, NULL,
97*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
98*0a6a1f1dSLionel Sambuc { "20130035113", 123456789, 6, NULL,
99*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
100*0a6a1f1dSLionel Sambuc { "3026236221", 123456789, 7, NULL,
101*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
102*0a6a1f1dSLionel Sambuc { "726746425", 123456789, 8, NULL,
103*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
104*0a6a1f1dSLionel Sambuc { "277266780", 123456789, 9, NULL,
105*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
106*0a6a1f1dSLionel Sambuc { "123456789", 123456789, 10, NULL,
107*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
108*0a6a1f1dSLionel Sambuc { "63762A05", 123456789, 11, NULL,
109*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
110*0a6a1f1dSLionel Sambuc { "35418A99", 123456789, 12, NULL,
111*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
112*0a6a1f1dSLionel Sambuc { "1C767471", 123456789, 13, NULL,
113*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
114*0a6a1f1dSLionel Sambuc { "12579781", 123456789, 14, NULL,
115*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
116*0a6a1f1dSLionel Sambuc { "AC89BC9", 123456789, 15, NULL,
117*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
118*0a6a1f1dSLionel Sambuc { "75BCD15", 123456789, 16, NULL,
119*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
120*0a6a1f1dSLionel Sambuc { "1234567", 342391, 8, NULL,
121*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
122*0a6a1f1dSLionel Sambuc { "01234567", 342391, 0, NULL,
123*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
124*0a6a1f1dSLionel Sambuc { "0123456789", 123456789, 10, NULL,
125*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
126*0a6a1f1dSLionel Sambuc { "0x75bcd15", 123456789, 0, NULL,
127*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
128*0a6a1f1dSLionel Sambuc };
129*0a6a1f1dSLionel Sambuc
130*0a6a1f1dSLionel Sambuc intmax_t rv;
131*0a6a1f1dSLionel Sambuc char *end;
132*0a6a1f1dSLionel Sambuc int e;
133*0a6a1f1dSLionel Sambuc size_t i;
134*0a6a1f1dSLionel Sambuc
135*0a6a1f1dSLionel Sambuc for (i = 0; i < __arraycount(t); i++) {
136*0a6a1f1dSLionel Sambuc
137*0a6a1f1dSLionel Sambuc errno = 0;
138*0a6a1f1dSLionel Sambuc rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e);
139*0a6a1f1dSLionel Sambuc
140*0a6a1f1dSLionel Sambuc if (errno != 0)
141*0a6a1f1dSLionel Sambuc atf_tc_fail("strtoi(3) changed errno to %d ('%s')",
142*0a6a1f1dSLionel Sambuc e, strerror(e));
143*0a6a1f1dSLionel Sambuc
144*0a6a1f1dSLionel Sambuc check(&t[i], rv, end, e);
145*0a6a1f1dSLionel Sambuc }
146*0a6a1f1dSLionel Sambuc }
147*0a6a1f1dSLionel Sambuc
148*0a6a1f1dSLionel Sambuc ATF_TC(strtoi_case);
ATF_TC_HEAD(strtoi_case,tc)149*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(strtoi_case, tc)
150*0a6a1f1dSLionel Sambuc {
151*0a6a1f1dSLionel Sambuc atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)");
152*0a6a1f1dSLionel Sambuc }
153*0a6a1f1dSLionel Sambuc
ATF_TC_BODY(strtoi_case,tc)154*0a6a1f1dSLionel Sambuc ATF_TC_BODY(strtoi_case, tc)
155*0a6a1f1dSLionel Sambuc {
156*0a6a1f1dSLionel Sambuc struct test t[] = {
157*0a6a1f1dSLionel Sambuc { "abcd", 0xabcd, 16, NULL,
158*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
159*0a6a1f1dSLionel Sambuc { " dcba", 0xdcba, 16, NULL,
160*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
161*0a6a1f1dSLionel Sambuc { "abcd dcba", 0xabcd, 16, " dcba",
162*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ENOTSUP },
163*0a6a1f1dSLionel Sambuc { "abc0x123", 0xabc0, 16, "x123",
164*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ENOTSUP },
165*0a6a1f1dSLionel Sambuc { "abcd\0x123", 0xabcd, 16, "\0x123",
166*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
167*0a6a1f1dSLionel Sambuc { "ABCD", 0xabcd, 16, NULL,
168*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
169*0a6a1f1dSLionel Sambuc { "aBcD", 0xabcd, 16, NULL,
170*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
171*0a6a1f1dSLionel Sambuc { "0xABCD", 0xabcd, 16, NULL,
172*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
173*0a6a1f1dSLionel Sambuc { "0xABCDX", 0xabcd, 16, "X",
174*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ENOTSUP},
175*0a6a1f1dSLionel Sambuc };
176*0a6a1f1dSLionel Sambuc
177*0a6a1f1dSLionel Sambuc intmax_t rv;
178*0a6a1f1dSLionel Sambuc char *end;
179*0a6a1f1dSLionel Sambuc int e;
180*0a6a1f1dSLionel Sambuc size_t i;
181*0a6a1f1dSLionel Sambuc
182*0a6a1f1dSLionel Sambuc for (i = 0; i < __arraycount(t); i++) {
183*0a6a1f1dSLionel Sambuc
184*0a6a1f1dSLionel Sambuc errno = 0;
185*0a6a1f1dSLionel Sambuc rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e);
186*0a6a1f1dSLionel Sambuc
187*0a6a1f1dSLionel Sambuc if (errno != 0)
188*0a6a1f1dSLionel Sambuc atf_tc_fail("strtoi(3) changed errno to %d ('%s')",
189*0a6a1f1dSLionel Sambuc e, strerror(e));
190*0a6a1f1dSLionel Sambuc
191*0a6a1f1dSLionel Sambuc check(&t[i], rv, end, e);
192*0a6a1f1dSLionel Sambuc }
193*0a6a1f1dSLionel Sambuc }
194*0a6a1f1dSLionel Sambuc
195*0a6a1f1dSLionel Sambuc ATF_TC(strtoi_range);
ATF_TC_HEAD(strtoi_range,tc)196*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(strtoi_range, tc)
197*0a6a1f1dSLionel Sambuc {
198*0a6a1f1dSLionel Sambuc atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)");
199*0a6a1f1dSLionel Sambuc }
200*0a6a1f1dSLionel Sambuc
ATF_TC_BODY(strtoi_range,tc)201*0a6a1f1dSLionel Sambuc ATF_TC_BODY(strtoi_range, tc)
202*0a6a1f1dSLionel Sambuc {
203*0a6a1f1dSLionel Sambuc struct test t[] = {
204*0a6a1f1dSLionel Sambuc #if INTMAX_MAX == 0x7fffffffffffffff
205*0a6a1f1dSLionel Sambuc { "1000000000000000000000", INTMAX_MAX, 8, NULL,
206*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ERANGE },
207*0a6a1f1dSLionel Sambuc { "9223372036854775808", INTMAX_MAX, 10, NULL,
208*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ERANGE },
209*0a6a1f1dSLionel Sambuc { "8000000000000000", INTMAX_MAX, 16, NULL,
210*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ERANGE },
211*0a6a1f1dSLionel Sambuc #else
212*0a6a1f1dSLionel Sambuc #error extend this test to your platform!
213*0a6a1f1dSLionel Sambuc #endif
214*0a6a1f1dSLionel Sambuc { "10", 1, 10, NULL,
215*0a6a1f1dSLionel Sambuc -1, 1, ERANGE },
216*0a6a1f1dSLionel Sambuc { "10", 11, 10, NULL,
217*0a6a1f1dSLionel Sambuc 11, 20, ERANGE },
218*0a6a1f1dSLionel Sambuc };
219*0a6a1f1dSLionel Sambuc
220*0a6a1f1dSLionel Sambuc intmax_t rv;
221*0a6a1f1dSLionel Sambuc char *end;
222*0a6a1f1dSLionel Sambuc int e;
223*0a6a1f1dSLionel Sambuc size_t i;
224*0a6a1f1dSLionel Sambuc
225*0a6a1f1dSLionel Sambuc for (i = 0; i < __arraycount(t); i++) {
226*0a6a1f1dSLionel Sambuc
227*0a6a1f1dSLionel Sambuc errno = 0;
228*0a6a1f1dSLionel Sambuc rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e);
229*0a6a1f1dSLionel Sambuc
230*0a6a1f1dSLionel Sambuc if (errno != 0)
231*0a6a1f1dSLionel Sambuc atf_tc_fail("strtoi(3) changed errno to %d ('%s')",
232*0a6a1f1dSLionel Sambuc e, strerror(e));
233*0a6a1f1dSLionel Sambuc
234*0a6a1f1dSLionel Sambuc check(&t[i], rv, end, e);
235*0a6a1f1dSLionel Sambuc }
236*0a6a1f1dSLionel Sambuc }
237*0a6a1f1dSLionel Sambuc
238*0a6a1f1dSLionel Sambuc ATF_TC(strtoi_signed);
ATF_TC_HEAD(strtoi_signed,tc)239*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(strtoi_signed, tc)
240*0a6a1f1dSLionel Sambuc {
241*0a6a1f1dSLionel Sambuc atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)");
242*0a6a1f1dSLionel Sambuc }
243*0a6a1f1dSLionel Sambuc
ATF_TC_BODY(strtoi_signed,tc)244*0a6a1f1dSLionel Sambuc ATF_TC_BODY(strtoi_signed, tc)
245*0a6a1f1dSLionel Sambuc {
246*0a6a1f1dSLionel Sambuc struct test t[] = {
247*0a6a1f1dSLionel Sambuc { "1", 1, 0, NULL,
248*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
249*0a6a1f1dSLionel Sambuc { " 2", 2, 0, NULL,
250*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
251*0a6a1f1dSLionel Sambuc { " 3", 3, 0, NULL,
252*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
253*0a6a1f1dSLionel Sambuc { " -3", -3, 0, NULL,
254*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
255*0a6a1f1dSLionel Sambuc { "--1", 0, 0, "--1",
256*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ECANCELED },
257*0a6a1f1dSLionel Sambuc { "+-2", 0, 0, "+-2",
258*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ECANCELED },
259*0a6a1f1dSLionel Sambuc { "++3", 0, 0, "++3",
260*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ECANCELED },
261*0a6a1f1dSLionel Sambuc { "+9", 9, 0, NULL,
262*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
263*0a6a1f1dSLionel Sambuc { "+123", 123, 0, NULL,
264*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, 0 },
265*0a6a1f1dSLionel Sambuc { "-1 3", -1, 0, " 3",
266*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ENOTSUP },
267*0a6a1f1dSLionel Sambuc { "-1.3", -1, 0, ".3",
268*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ENOTSUP },
269*0a6a1f1dSLionel Sambuc { "- 3", 0, 0, "- 3",
270*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ECANCELED },
271*0a6a1f1dSLionel Sambuc { "+33.", 33, 0, ".",
272*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ENOTSUP },
273*0a6a1f1dSLionel Sambuc { "30x0", 30, 0, "x0",
274*0a6a1f1dSLionel Sambuc INTMAX_MIN, INTMAX_MAX, ENOTSUP },
275*0a6a1f1dSLionel Sambuc };
276*0a6a1f1dSLionel Sambuc
277*0a6a1f1dSLionel Sambuc intmax_t rv;
278*0a6a1f1dSLionel Sambuc char *end;
279*0a6a1f1dSLionel Sambuc int e;
280*0a6a1f1dSLionel Sambuc size_t i;
281*0a6a1f1dSLionel Sambuc
282*0a6a1f1dSLionel Sambuc for (i = 0; i < __arraycount(t); i++) {
283*0a6a1f1dSLionel Sambuc
284*0a6a1f1dSLionel Sambuc errno = 0;
285*0a6a1f1dSLionel Sambuc rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e);
286*0a6a1f1dSLionel Sambuc
287*0a6a1f1dSLionel Sambuc if (errno != 0)
288*0a6a1f1dSLionel Sambuc atf_tc_fail("strtoi(3) changed errno to %d ('%s')",
289*0a6a1f1dSLionel Sambuc e, strerror(e));
290*0a6a1f1dSLionel Sambuc
291*0a6a1f1dSLionel Sambuc check(&t[i], rv, end, e);
292*0a6a1f1dSLionel Sambuc }
293*0a6a1f1dSLionel Sambuc }
294*0a6a1f1dSLionel Sambuc
ATF_TP_ADD_TCS(tp)295*0a6a1f1dSLionel Sambuc ATF_TP_ADD_TCS(tp)
296*0a6a1f1dSLionel Sambuc {
297*0a6a1f1dSLionel Sambuc
298*0a6a1f1dSLionel Sambuc ATF_TP_ADD_TC(tp, strtoi_base);
299*0a6a1f1dSLionel Sambuc ATF_TP_ADD_TC(tp, strtoi_case);
300*0a6a1f1dSLionel Sambuc ATF_TP_ADD_TC(tp, strtoi_range);
301*0a6a1f1dSLionel Sambuc ATF_TP_ADD_TC(tp, strtoi_signed);
302*0a6a1f1dSLionel Sambuc
303*0a6a1f1dSLionel Sambuc return atf_no_error();
304*0a6a1f1dSLionel Sambuc }
305