| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: t_printf.c,v 1.15 2024/05/09 12:24:24 riastradh Exp $ */ | | 1 | /* $NetBSD: t_printf.c,v 1.16 2024/05/09 22:38:29 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -185,52 +185,52 @@ ATF_TC_BODY(sprintf_zeropad, tc) | | | @@ -185,52 +185,52 @@ ATF_TC_BODY(sprintf_zeropad, tc) |
185 | ATF_TC(snprintf_double_a); | | 185 | ATF_TC(snprintf_double_a); |
186 | ATF_TC_HEAD(snprintf_double_a, tc) | | 186 | ATF_TC_HEAD(snprintf_double_a, tc) |
187 | { | | 187 | { |
188 | atf_tc_set_md_var(tc, "descr", "Test printf a format"); | | 188 | atf_tc_set_md_var(tc, "descr", "Test printf a format"); |
189 | } | | 189 | } |
190 | | | 190 | |
191 | ATF_TC_BODY(snprintf_double_a, tc) | | 191 | ATF_TC_BODY(snprintf_double_a, tc) |
192 | { | | 192 | { |
193 | char buf[1000]; | | 193 | char buf[1000]; |
194 | | | 194 | |
195 | snprintf(buf, sizeof buf, "%.3a", (double)10.6); | | 195 | snprintf(buf, sizeof buf, "%.3a", (double)10.6); |
196 | ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 || | | 196 | ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 || |
197 | strcmp(buf, "0x2.a66p+2") == 0 || | | 197 | strcmp(buf, "0x2.a66p+2") == 0 || |
198 | strcmp(buf, "0x5.4ccp+1") == 0 || | | 198 | strcmp(buf, "0x5.4cdp+1") == 0 || |
199 | strcmp(buf, "0xa.99ap+0") == 0), | | 199 | strcmp(buf, "0xa.99ap+0") == 0), |
200 | "buf=%s", buf); | | 200 | "buf=%s", buf); |
201 | | | 201 | |
202 | snprintf(buf, sizeof buf, "%a", (double)0.125); | | 202 | snprintf(buf, sizeof buf, "%a", (double)0.125); |
203 | ATF_CHECK_MSG((strcmp(buf, "0x1p-3") == 0 || | | 203 | ATF_CHECK_MSG((strcmp(buf, "0x1p-3") == 0 || |
204 | strcmp(buf, "0x2p-4") == 0 || | | 204 | strcmp(buf, "0x2p-4") == 0 || |
205 | strcmp(buf, "0x4p-5") == 0 || | | 205 | strcmp(buf, "0x4p-5") == 0 || |
206 | strcmp(buf, "0x8p-6") == 0), | | 206 | strcmp(buf, "0x8p-6") == 0), |
207 | "buf=%s", buf); | | 207 | "buf=%s", buf); |
208 | } | | 208 | } |
209 | | | 209 | |
210 | ATF_TC(snprintf_long_double_a); | | 210 | ATF_TC(snprintf_long_double_a); |
211 | ATF_TC_HEAD(snprintf_long_double_a, tc) | | 211 | ATF_TC_HEAD(snprintf_long_double_a, tc) |
212 | { | | 212 | { |
213 | atf_tc_set_md_var(tc, "descr", "Test printf La format"); | | 213 | atf_tc_set_md_var(tc, "descr", "Test printf La format"); |
214 | } | | 214 | } |
215 | | | 215 | |
216 | ATF_TC_BODY(snprintf_long_double_a, tc) | | 216 | ATF_TC_BODY(snprintf_long_double_a, tc) |
217 | { | | 217 | { |
218 | char buf[1000]; | | 218 | char buf[1000]; |
219 | | | 219 | |
220 | snprintf(buf, sizeof buf, "%.3La", 10.6L); | | 220 | snprintf(buf, sizeof buf, "%.3La", 10.6L); |
221 | ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 || | | 221 | ATF_CHECK_MSG((strcmp(buf, "0x1.533p+3") == 0 || |
222 | strcmp(buf, "0x2.a66p+2") == 0 || | | 222 | strcmp(buf, "0x2.a66p+2") == 0 || |
223 | strcmp(buf, "0x5.4ccp+1") == 0 || | | 223 | strcmp(buf, "0x5.4cdp+1") == 0 || |
224 | strcmp(buf, "0xa.99ap+0") == 0), | | 224 | strcmp(buf, "0xa.99ap+0") == 0), |
225 | "buf=%s", buf); | | 225 | "buf=%s", buf); |
226 | | | 226 | |
227 | snprintf(buf, sizeof buf, "%La", 0.125L); | | 227 | snprintf(buf, sizeof buf, "%La", 0.125L); |
228 | ATF_CHECK_MSG((strcmp(buf, "0x1p-3") == 0 || | | 228 | ATF_CHECK_MSG((strcmp(buf, "0x1p-3") == 0 || |
229 | strcmp(buf, "0x2p-4") == 0 || | | 229 | strcmp(buf, "0x2p-4") == 0 || |
230 | strcmp(buf, "0x4p-5") == 0 || | | 230 | strcmp(buf, "0x4p-5") == 0 || |
231 | strcmp(buf, "0x8p-6") == 0), | | 231 | strcmp(buf, "0x8p-6") == 0), |
232 | "buf=%s", buf); | | 232 | "buf=%s", buf); |
233 | | | 233 | |
234 | #if LDBL_MAX_EXP >= 16384 && LDBL_MANT_DIG >= 64 | | 234 | #if LDBL_MAX_EXP >= 16384 && LDBL_MANT_DIG >= 64 |
235 | snprintf(buf, sizeof buf, "%La", -0xc.ecececececececep+3788L); | | 235 | snprintf(buf, sizeof buf, "%La", -0xc.ecececececececep+3788L); |
236 | ATF_CHECK_MSG((strcmp(buf, "-0x1.9d9d9d9d9d9d9d9cp+3791") == 0 || | | 236 | ATF_CHECK_MSG((strcmp(buf, "-0x1.9d9d9d9d9d9d9d9cp+3791") == 0 || |