1 /* $NetBSD: t_inttypes.c,v 1.3 2013/10/19 17:44:37 christos Exp $ */
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
35 ATF_TC_WITHOUT_HEAD(int_fmtio
);
36 ATF_TC_BODY(int_fmtio
, tc
)
45 int_least16_t il16
= 0;
46 int_least32_t il32
= 0;
47 int_least64_t il64
= 0;
49 int_fast16_t if16
= 0;
50 int_fast32_t if32
= 0;
51 int_fast64_t if64
= 0;
58 uint_least8_t uil8
= 0;
59 uint_least16_t uil16
= 0;
60 uint_least32_t uil32
= 0;
61 uint_least64_t uil64
= 0;
62 uint_fast8_t uif8
= 0;
63 uint_fast16_t uif16
= 0;
64 uint_fast32_t uif32
= 0;
65 uint_fast64_t uif64
= 0;
69 #define PRINT(fmt, var) \
70 snprintf(buf, sizeof(buf), "%" fmt, var)
71 #define SCAN(fmt, var) \
72 sscanf(buf, "%" fmt, &var)
78 PRINT(PRIdLEAST8
, il8
);
79 PRINT(PRIdLEAST16
, il16
);
80 PRINT(PRIdLEAST32
, il32
);
81 PRINT(PRIdLEAST64
, il64
);
82 PRINT(PRIdFAST8
, if8
);
83 PRINT(PRIdFAST16
, if16
);
84 PRINT(PRIdFAST32
, if32
);
85 PRINT(PRIdFAST64
, if64
);
93 PRINT(PRIiLEAST8
, il8
);
94 PRINT(PRIiLEAST16
, il16
);
95 PRINT(PRIiLEAST32
, il32
);
96 PRINT(PRIiLEAST64
, il64
);
97 PRINT(PRIiFAST8
, if8
);
98 PRINT(PRIiFAST16
, if16
);
99 PRINT(PRIiFAST32
, if32
);
100 PRINT(PRIiFAST64
, if64
);
108 PRINT(PRIoLEAST8
, uil8
);
109 PRINT(PRIoLEAST16
, uil16
);
110 PRINT(PRIoLEAST32
, uil32
);
111 PRINT(PRIoLEAST64
, uil64
);
112 PRINT(PRIoFAST8
, uif8
);
113 PRINT(PRIoFAST16
, uif16
);
114 PRINT(PRIoFAST32
, uif32
);
115 PRINT(PRIoFAST64
, uif64
);
123 PRINT(PRIuLEAST8
, uil8
);
124 PRINT(PRIuLEAST16
, uil16
);
125 PRINT(PRIuLEAST32
, uil32
);
126 PRINT(PRIuLEAST64
, uil64
);
127 PRINT(PRIuFAST8
, uif8
);
128 PRINT(PRIuFAST16
, uif16
);
129 PRINT(PRIuFAST32
, uif32
);
130 PRINT(PRIuFAST64
, uif64
);
138 PRINT(PRIxLEAST8
, uil8
);
139 PRINT(PRIxLEAST16
, uil16
);
140 PRINT(PRIxLEAST32
, uil32
);
141 PRINT(PRIxLEAST64
, uil64
);
142 PRINT(PRIxFAST8
, uif8
);
143 PRINT(PRIxFAST16
, uif16
);
144 PRINT(PRIxFAST32
, uif32
);
145 PRINT(PRIxFAST64
, uif64
);
153 PRINT(PRIXLEAST8
, uil8
);
154 PRINT(PRIXLEAST16
, uil16
);
155 PRINT(PRIXLEAST32
, uil32
);
156 PRINT(PRIXLEAST64
, uil64
);
157 PRINT(PRIXFAST8
, uif8
);
158 PRINT(PRIXFAST16
, uif16
);
159 PRINT(PRIXFAST32
, uif32
);
160 PRINT(PRIXFAST64
, uif64
);
169 SCAN(SCNdLEAST8
, il8
);
170 SCAN(SCNdLEAST16
, il16
);
171 SCAN(SCNdLEAST32
, il32
);
172 SCAN(SCNdLEAST64
, il64
);
173 SCAN(SCNdFAST8
, if8
);
174 SCAN(SCNdFAST16
, if16
);
175 SCAN(SCNdFAST32
, if32
);
176 SCAN(SCNdFAST64
, if64
);
184 SCAN(SCNiLEAST8
, il8
);
185 SCAN(SCNiLEAST16
, il16
);
186 SCAN(SCNiLEAST32
, il32
);
187 SCAN(SCNiLEAST64
, il64
);
188 SCAN(SCNiFAST8
, if8
);
189 SCAN(SCNiFAST16
, if16
);
190 SCAN(SCNiFAST32
, if32
);
191 SCAN(SCNiFAST64
, if64
);
199 SCAN(SCNoLEAST8
, uil8
);
200 SCAN(SCNoLEAST16
, uil16
);
201 SCAN(SCNoLEAST32
, uil32
);
202 SCAN(SCNoLEAST64
, uil64
);
203 SCAN(SCNoFAST8
, uif8
);
204 SCAN(SCNoFAST16
, uif16
);
205 SCAN(SCNoFAST32
, uif32
);
206 SCAN(SCNoFAST64
, uif64
);
214 SCAN(SCNuLEAST8
, uil8
);
215 SCAN(SCNuLEAST16
, uil16
);
216 SCAN(SCNuLEAST32
, uil32
);
217 SCAN(SCNuLEAST64
, uil64
);
218 SCAN(SCNuFAST8
, uif8
);
219 SCAN(SCNuFAST16
, uif16
);
220 SCAN(SCNuFAST32
, uif32
);
221 SCAN(SCNuFAST64
, uif64
);
229 SCAN(SCNxLEAST8
, uil8
);
230 SCAN(SCNxLEAST16
, uil16
);
231 SCAN(SCNxLEAST32
, uil32
);
232 SCAN(SCNxLEAST64
, uil64
);
233 SCAN(SCNxFAST8
, uif8
);
234 SCAN(SCNxFAST16
, uif16
);
235 SCAN(SCNxFAST32
, uif32
);
236 SCAN(SCNxFAST64
, uif64
);
247 ATF_TP_ADD_TC(tp
, int_fmtio
);
249 return atf_no_error();