1 /* 2 * This file was generated from printf-tests.txt included 3 * as a part of the printf test suite developed by 4 * Bart Massey: 5 * 6 * https://github.com/BartMassey/printf-tests 7 * 8 * printf-tests.txt carries the following Copyright, which 9 * probably extends to this file as well given the transformations 10 * are fairly mechanical: 11 * 12 # Various printf tests compiled from various sources 13 # Copyright © 2013 Bart Massey 14 # This program is licensed under the GPL version 2 or later. 15 # Please see the file COPYING.GPL2 in this distribution for 16 # license terms. 17 18 */ 19 20 #ifndef __PICOLIBC__ 21 # define _WANT_IO_C99_FORMATS 22 # define _WANT_IO_LONG_LONG 23 # define _WANT_IO_POS_ARGS 24 #elif defined(TINY_STDIO) 25 # ifdef _HAS_IO_PERCENT_B 26 # define BINARY_FORMAT 27 # endif 28 # ifdef _HAS_IO_DOUBLE 29 # if __SIZEOF_DOUBLE__ == 4 30 # define LOW_FLOAT 31 # endif 32 # elif defined(_HAS_IO_FLOAT) 33 # define LOW_FLOAT 34 # define FLOAT float 35 # else 36 # define NO_FLOAT 37 # endif 38 # ifndef _HAS_IO_LONG_DOUBLE 39 # define NO_LONGDOUBLE 40 # endif 41 # ifndef _HAS_IO_LONG_LONG 42 # define NO_LONGLONG 43 # endif 44 # ifndef _HAS_IO_POS_ARGS 45 # define NO_POS_ARGS 46 # endif 47 # ifndef _HAS_IO_WCHAR 48 # define NO_WCHAR 49 # endif 50 # ifndef _HAS_IO_MBCHAR 51 # define NO_MBCHAR 52 # endif 53 # ifdef PICOLIBC_MINIMAL_PRINTF_SCANF 54 # define NO_WIDTH_PREC 55 # define NO_CASE_HEX 56 # endif 57 #else 58 # ifndef _MB_CAPABLE 59 # define NO_WCHAR 60 # define NO_MBCHAR 61 # endif 62 # if __SIZEOF_DOUBLE__ == 4 63 # define LOW_FLOAT 64 # endif 65 # ifdef NO_FLOATING_POINT 66 # define NO_FLOAT 67 # endif 68 # ifndef _WANT_IO_LONG_LONG 69 # define NO_LONGLONG 70 # endif 71 # ifndef _WANT_IO_POS_ARGS 72 # define NO_POS_ARGS 73 # endif 74 # define NORMALIZED_A 75 #endif 76 77 #ifndef FLOAT 78 #define FLOAT double 79 #endif 80 81 #if __SIZEOF_INT__ < 4 82 #define I(a,b) (b) 83 #else 84 #define I(a,b) (a) 85 #endif 86 87 //{ 88 /* XXX This code generated automatically by gen-testcases.hs 89 from ../../printf-tests.txt . You probably do not want to 90 manually edit this file. */ 91 #ifndef NO_FLOAT 92 result |= test(__LINE__, "0", "%.7g", printf_float(0.0)); 93 result |= test(__LINE__, "0.33", "%.*f", 2, printf_float(0.33333333)); 94 #endif 95 #ifndef NO_WIDTH_PREC 96 result |= test(__LINE__, "foo", "%.3s", "foobar"); 97 result |= test(__LINE__, " 00004", "%10.5d", 4); 98 result |= test(__LINE__, " 42", "% d", 42); 99 #endif 100 result |= test(__LINE__, "-42", "% d", -42); 101 #ifndef NO_WIDTH_PREC 102 result |= test(__LINE__, " 42", "% 5d", 42); 103 result |= test(__LINE__, " -42", "% 5d", -42); 104 result |= test(__LINE__, " 42", "% 15d", 42); 105 result |= test(__LINE__, " -42", "% 15d", -42); 106 result |= test(__LINE__, "+42", "%+d", 42); 107 result |= test(__LINE__, "-42", "%+d", -42); 108 result |= test(__LINE__, " +42", "%+5d", 42); 109 result |= test(__LINE__, " -42", "%+5d", -42); 110 result |= test(__LINE__, " +42", "%+15d", 42); 111 result |= test(__LINE__, " -42", "%+15d", -42); 112 #endif 113 result |= test(__LINE__, "42", "%0d", 42); 114 result |= test(__LINE__, "-42", "%0d", -42); 115 #ifndef NO_WIDTH_PREC 116 result |= test(__LINE__, "00042", "%05d", 42); 117 result |= test(__LINE__, "-0042", "%05d", -42); 118 result |= test(__LINE__, "000000000000042", "%015d", 42); 119 result |= test(__LINE__, "-00000000000042", "%015d", -42); 120 #endif 121 result |= test(__LINE__, "42", "%-d", 42); 122 result |= test(__LINE__, "-42", "%-d", -42); 123 #ifndef NO_WIDTH_PREC 124 result |= test(__LINE__, "42 ", "%-5d", 42); 125 result |= test(__LINE__, "-42 ", "%-5d", -42); 126 result |= test(__LINE__, "42 ", "%-15d", 42); 127 result |= test(__LINE__, "-42 ", "%-15d", -42); 128 #endif 129 result |= test(__LINE__, "42", "%-0d", 42); 130 result |= test(__LINE__, "-42", "%-0d", -42); 131 #ifndef NO_WIDTH_PREC 132 result |= test(__LINE__, "42 ", "%-05d", 42); 133 result |= test(__LINE__, "-42 ", "%-05d", -42); 134 result |= test(__LINE__, "42 ", "%-015d", 42); 135 result |= test(__LINE__, "-42 ", "%-015d", -42); 136 #endif 137 result |= test(__LINE__, "42", "%0-d", 42); 138 result |= test(__LINE__, "-42", "%0-d", -42); 139 #ifndef NO_WIDTH_PREC 140 result |= test(__LINE__, "42 ", "%0-5d", 42); 141 result |= test(__LINE__, "-42 ", "%0-5d", -42); 142 result |= test(__LINE__, "42 ", "%0-15d", 42); 143 result |= test(__LINE__, "-42 ", "%0-15d", -42); 144 #endif 145 #ifndef NO_FLOAT 146 result |= test(__LINE__, "42.90", "%.2f", printf_float(42.8952)); 147 result |= test(__LINE__, "42.90", "%.2F", printf_float(42.8952)); 148 #ifdef LOW_FLOAT 149 result |= test(__LINE__, "42.89520", "%.5f", printf_float(42.8952)); 150 #else 151 result |= test(__LINE__, "42.8952000000", "%.10f", printf_float(42.8952)); 152 #endif 153 result |= test(__LINE__, "42.90", "%1.2f", printf_float(42.8952)); 154 result |= test(__LINE__, " 42.90", "%6.2f", printf_float(42.8952)); 155 result |= test(__LINE__, "+42.90", "%+6.2f", printf_float(42.8952)); 156 #ifdef LOW_FLOAT 157 result |= test(__LINE__, "42.89520", "%5.5f", printf_float(42.8952)); 158 #else 159 result |= test(__LINE__, "42.8952000000", "%5.10f", printf_float(42.8952)); 160 #endif 161 #endif /* NO_FLOAT */ 162 /* 51: anti-test */ 163 /* 52: anti-test */ 164 /* 53: excluded for C */ 165 #if !defined(NO_POS_ARGS) 166 result |= test(__LINE__, "Hot Pocket", "%1$s %2$s", "Hot", "Pocket"); 167 result |= test(__LINE__, "Pocket Hot", "%2$s %1$s", "Hot", "Pocket"); 168 result |= test(__LINE__, "0002 1 hi", "%2$04d %1$*3$d %4$s", 1, 2, 3, "hi"); 169 result |= test(__LINE__, " ab", "%1$*2$.*3$s", "abc", 5, 2); 170 #ifndef NO_FLOAT 171 result |= test(__LINE__, "12.0 Hot Pockets", "%1$.1f %2$s %3$ss", printf_float(12.0), "Hot", "Pocket"); 172 result |= test(__LINE__, "12.0 Hot Pockets", "%1$.*4$f %2$s %3$ss", printf_float(12.0), "Hot", "Pocket", 1); 173 result |= test(__LINE__, " 12.0 Hot Pockets", "%1$*5$.*4$f %2$s %3$ss", printf_float(12.0), "Hot", "Pocket", 1, 5); 174 result |= test(__LINE__, " 12.0 Hot Pockets 5", "%1$5.*4$f %2$s %3$ss %5$d", printf_float(12.0), "Hot", "Pocket", 1, 5); 175 #if !defined(TINY_STDIO) || defined(_IO_FLOAT_EXACT) 176 result |= test(__LINE__, 177 " 12345 1234 11145401322 321.765400 3.217654e+02 5 test-string", 178 "%1$*5$d %2$*6$hi %3$*7$lo %4$*8$f %9$*12$e %10$*13$g %11$*14$s", 179 12345, 1234, 1234567890, printf_float(321.7654), 8, 5, 14, 14, 180 printf_float(321.7654), printf_float(5.0000001), "test-string", 14, 3, 14); 181 #endif 182 #endif 183 #endif 184 /* 58: anti-test */ 185 #ifdef TINY_STDIO 186 result |= test(__LINE__, "%(foo", "%(foo"); 187 #endif 188 #ifndef NO_WIDTH_PREC 189 result |= test(__LINE__, " foo", "%*s", 4, "foo"); 190 #endif 191 #ifndef NO_FLOAT 192 result |= test(__LINE__, " 3.14", "%*.*f", 10, 2, printf_float(3.14159265)); 193 result |= test(__LINE__, "3.14 ", "%-*.*f", 10, 2, printf_float(3.14159265)); 194 # if !(defined(TINY_STDIO) && !defined(_IO_FLOAT_EXACT)) 195 # ifndef LOW_FLOAT 196 # ifdef TINY_STDIO 197 # define SQRT2_60 "1414213562373095000000000000000000000000000000000000000000000.000" 198 # else 199 # define SQRT2_60 "1414213562373095053224405813183213153460812619236586568024064.000" 200 # endif 201 result |= test(__LINE__, SQRT2_60, "%.3f", printf_float(1.4142135623730950e60)); 202 # endif 203 # endif 204 #endif 205 /* 64: anti-test */ 206 /* 65: anti-test */ 207 result |= test(__LINE__, "+hello+", "+%s+", "hello"); 208 result |= test(__LINE__, "+10+", "+%d+", 10); 209 result |= test(__LINE__, "a", "%c", 'a'); 210 result |= test(__LINE__, " ", "%c", 32); 211 result |= test(__LINE__, "$", "%c", 36); 212 result |= test(__LINE__, "10", "%d", 10); 213 214 #ifndef _NANO_FORMATTED_IO 215 result |= test(__LINE__, I("1000000","16960"), "%'d", 1000000); 216 #endif 217 /* 72: anti-test */ 218 /* 73: anti-test */ 219 /* 74: excluded for C */ 220 /* 75: excluded for C */ 221 #ifndef NO_FLOAT 222 #ifdef LOW_FLOAT 223 result |= test(__LINE__, " +7.894561e+08", "%+#22.6e", printf_float(7.89456123e8)); 224 result |= test(__LINE__, "7.894561e+08 ", "%-#22.6e", printf_float(7.89456123e8)); 225 result |= test(__LINE__, " 7.894561e+08", "%#22.6e", printf_float(7.89456123e8)); 226 #else 227 result |= test(__LINE__, "+7.894561230000000e+08", "%+#22.15e", printf_float(7.89456123e8)); 228 result |= test(__LINE__, "7.894561230000000e+08 ", "%-#22.15e", printf_float(7.89456123e8)); 229 result |= test(__LINE__, " 7.894561230000000e+08", "%#22.15e", printf_float(7.89456123e8)); 230 #endif 231 result |= test(__LINE__, "8.e+08", "%#1.1g", printf_float(7.89456123e8)); 232 #endif 233 #ifndef NO_LONGLONG 234 #ifndef NO_WIDTH_PREC 235 result |= test(__LINE__, " +100", "%+8lld", 100LL); 236 #if defined(TINY_STDIO) || !defined(__PICOLIBC__) 237 result |= test(__LINE__, " +100", "%+8Ld", 100LL); 238 #endif 239 result |= test(__LINE__, "+00000100", "%+.8lld", 100LL); 240 result |= test(__LINE__, " +00000100", "%+10.8lld", 100LL); 241 #endif 242 #ifdef TINY_STDIO 243 result |= test(__LINE__, "%_1lld", "%_1lld", 100LL); 244 #endif 245 #ifndef NO_WIDTH_PREC 246 result |= test(__LINE__, "-00100", "%-1.5lld", -100LL); 247 result |= test(__LINE__, " 100", "%5lld", 100LL); 248 result |= test(__LINE__, " -100", "%5lld", -100LL); 249 result |= test(__LINE__, "100 ", "%-5lld", 100LL); 250 result |= test(__LINE__, "-100 ", "%-5lld", -100LL); 251 result |= test(__LINE__, "00100", "%-.5lld", 100LL); 252 result |= test(__LINE__, "-00100", "%-.5lld", -100LL); 253 result |= test(__LINE__, "00100 ", "%-8.5lld", 100LL); 254 result |= test(__LINE__, "-00100 ", "%-8.5lld", -100LL); 255 result |= test(__LINE__, "00100", "%05lld", 100LL); 256 result |= test(__LINE__, "-0100", "%05lld", -100LL); 257 result |= test(__LINE__, " 100", "% lld", 100LL); 258 result |= test(__LINE__, "-100", "% lld", -100LL); 259 result |= test(__LINE__, " 100", "% 5lld", 100LL); 260 result |= test(__LINE__, " -100", "% 5lld", -100LL); 261 result |= test(__LINE__, " 00100", "% .5lld", 100LL); 262 result |= test(__LINE__, "-00100", "% .5lld", -100LL); 263 result |= test(__LINE__, " 00100", "% 8.5lld", 100LL); 264 result |= test(__LINE__, " -00100", "% 8.5lld", -100LL); 265 result |= test(__LINE__, "", "%.0lld", 0LL); 266 result |= test(__LINE__, " 0x00ffffffffffffff9c", "%#+21.18llx", -100LL); 267 result |= test(__LINE__, "0001777777777777777777634", "%#.25llo", -100LL); 268 result |= test(__LINE__, " 01777777777777777777634", "%#+24.20llo", -100LL); 269 result |= test(__LINE__, "0X00000FFFFFFFFFFFFFF9C", "%#+18.21llX", -100LL); 270 result |= test(__LINE__, "001777777777777777777634", "%#+20.24llo", -100LL); 271 result |= test(__LINE__, " 0018446744073709551615", "%#+25.22llu", -1LL); 272 result |= test(__LINE__, " 0018446744073709551615", "%#+25.22llu", -1LL); 273 result |= test(__LINE__, " 0000018446744073709551615", "%#+30.25llu", -1LL); 274 result |= test(__LINE__, " -0000000000000000000001", "%+#25.22lld", -1LL); 275 result |= test(__LINE__, "00144 ", "%#-8.5llo", 100LL); 276 result |= test(__LINE__, "+00100 ", "%#-+ 08.5lld", 100LL); 277 result |= test(__LINE__, "+00100 ", "%#-+ 08.5lld", 100LL); 278 result |= test(__LINE__, "0000000000000000000000000000000000000001", "%.40lld", 1LL); 279 result |= test(__LINE__, " 0000000000000000000000000000000000000001", "% .40lld", 1LL); 280 #endif 281 #endif 282 #ifndef NO_WIDTH_PREC 283 result |= test(__LINE__, " 0000000000000000000000000000000000000001", "% .40d", 1); 284 #endif 285 /* 121: excluded for C */ 286 /* 124: excluded for C */ 287 #ifndef NO_WIDTH_PREC 288 result |= test(__LINE__, " 1", "% d", 1); 289 result |= test(__LINE__, "+1", "%+ d", 1); 290 result |= test(__LINE__, "0x0000000001", "%#012x", 1); 291 result |= test(__LINE__, "0x00000001", "%#04.8x", 1); 292 result |= test(__LINE__, "0x01 ", "%#-08.2x", 1); 293 result |= test(__LINE__, "00000001", "%#08o", 1); 294 #endif 295 result |= test(__LINE__, "0x39", "%p", (void *)57ULL); 296 result |= test(__LINE__, "0x39", "%p", (void *)57U); 297 #ifndef NO_WIDTH_PREC 298 result |= test(__LINE__, "f", "%.1s", "foo"); 299 result |= test(__LINE__, "f", "%.*s", 1, "foo"); 300 result |= test(__LINE__, "foo ", "%*s", -5, "foo"); 301 #endif 302 result |= test(__LINE__, "hello", "hello"); 303 #if defined(TINY_STDIO) && !defined(_HAS_IO_PERCENT_B) 304 result |= test(__LINE__, "%b", "%b"); 305 #endif 306 #ifndef NO_WIDTH_PREC 307 result |= test(__LINE__, " a", "%3c", 'a'); 308 #endif 309 result |= test(__LINE__, "1234", "%3d", 1234); 310 /* 150: excluded for C */ 311 result |= test(__LINE__, "2", "%-1d", 2); 312 #ifndef NO_FLOAT 313 result |= test(__LINE__, "8.6000", "%2.4f", printf_float(8.6)); 314 result |= test(__LINE__, "0.600000", "%0f", printf_float(0.6)); 315 result |= test(__LINE__, "1", "%.0f", printf_float(0.6)); 316 result |= test(__LINE__, "0", "%.0f", printf_float(0.45)); 317 result |= test(__LINE__, "8.6000e+00", "%2.4e", printf_float(8.6)); 318 result |= test(__LINE__, " 8.6000e+00", "% 2.4e", printf_float(8.6)); 319 result |= test(__LINE__, "-8.6000e+00", "% 2.4e", printf_float(-8.6)); 320 result |= test(__LINE__, "+8.6000e+00", "%+2.4e", printf_float(8.6)); 321 result |= test(__LINE__, "8.6", "%2.4g", printf_float(8.6)); 322 #endif 323 result |= test(__LINE__, "-1", "%-i", -1); 324 result |= test(__LINE__, "1", "%-i", 1); 325 #ifndef NO_WIDTH_PREC 326 result |= test(__LINE__, "+1", "%+i", 1); 327 #endif 328 result |= test(__LINE__, "12", "%o", 10); 329 /* 166: excluded for C */ 330 /* 167: excluded for C */ 331 #ifdef TINY_STDIO 332 result |= test(__LINE__, "(null)", "%s", NULL); 333 #endif 334 result |= test(__LINE__, "%%%%", "%s", "%%%%"); 335 result |= test(__LINE__, I("4294967295", "65535"), "%u", -1); 336 #ifdef TINY_STDIO 337 result |= test(__LINE__, "%w", "%w", -1); 338 #endif 339 /* 172: excluded for C */ 340 /* 173: excluded for C */ 341 /* 174: excluded for C */ 342 #ifdef TINY_STDIO 343 result |= test(__LINE__, "%H", "%H", -1); 344 #endif 345 result |= test(__LINE__, "%0", "%%0"); 346 result |= test(__LINE__, "2345", "%hx", 74565); 347 #ifndef _NANO_FORMATTED_IO 348 result |= test(__LINE__, "61", "%hhx", 0x61); 349 result |= test(__LINE__, "61", "%hhx", 0x161); 350 result |= test(__LINE__, "97", "%hhd", 0x61); 351 result |= test(__LINE__, "97", "%hhd", 0x161); 352 result |= test(__LINE__, "-97", "%hhd", -0x61); 353 result |= test(__LINE__, "-97", "%hhd", -0x161); 354 #endif 355 result |= test(__LINE__, "Hallo heimur", "Hallo heimur"); 356 result |= test(__LINE__, "Hallo heimur", "%s", "Hallo heimur"); 357 result |= test(__LINE__, "1024", "%d", 1024); 358 result |= test(__LINE__, "-1024", "%d", -1024); 359 result |= test(__LINE__, "1024", "%i", 1024); 360 result |= test(__LINE__, "-1024", "%i", -1024); 361 result |= test(__LINE__, "1024", "%u", 1024); 362 result |= test(__LINE__, I("4294966272", "64512"), "%u", 4294966272U); 363 result |= test(__LINE__, "777", "%o", 511); 364 result |= test(__LINE__, I("37777777001", "177001"), "%o", 4294966785U); 365 result |= test(__LINE__, I("1234abcd", "abcd"), "%x", 305441741); 366 result |= test(__LINE__, I("edcb5433", "5433"), "%x", 3989525555U); 367 result |= test(__LINE__, I("1234ABCD", "ABCD"), "%X", 305441741); 368 result |= test(__LINE__, I("EDCB5433", "5433"), "%X", 3989525555U); 369 #ifdef BINARY_FORMAT 370 result |= test(__LINE__, I("10010001101001010101111001101", "1010101111001101"), "%b", 305441741); 371 result |= test(__LINE__, I("11101101110010110101010000110011", "101010000110011"), "%b", 3989525555U); 372 result |= test(__LINE__, I("10010001101001010101111001101", "1010101111001101"), "%B", 305441741); 373 result |= test(__LINE__, I("11101101110010110101010000110011", "101010000110011"), "%B", 3989525555U); 374 #endif 375 result |= test(__LINE__, "x", "%c", 'x'); 376 result |= test(__LINE__, "%", "%%"); 377 result |= test(__LINE__, "Hallo heimur", "%+s", "Hallo heimur"); 378 #ifndef NO_WIDTH_PREC 379 result |= test(__LINE__, "+1024", "%+d", 1024); 380 #endif 381 result |= test(__LINE__, "-1024", "%+d", -1024); 382 #ifndef NO_WIDTH_PREC 383 result |= test(__LINE__, "+1024", "%+i", 1024); 384 #endif 385 result |= test(__LINE__, "-1024", "%+i", -1024); 386 result |= test(__LINE__, "1024", "%+u", 1024); 387 result |= test(__LINE__, I("4294966272", "64512"), "%+u", 4294966272U); 388 result |= test(__LINE__, "777", "%+o", 511); 389 result |= test(__LINE__, I("37777777001", "177001"), "%+o", 4294966785U); 390 result |= test(__LINE__, I("1234abcd", "abcd"), "%+x", 305441741); 391 result |= test(__LINE__, I("edcb5433", "5433"), "%+x", 3989525555U); 392 result |= test(__LINE__, I("1234ABCD", "ABCD"), "%+X", 305441741); 393 result |= test(__LINE__, I("EDCB5433", "5433"), "%+X", 3989525555U); 394 result |= test(__LINE__, "x", "%+c", 'x'); 395 result |= test(__LINE__, "Hallo heimur", "% s", "Hallo heimur"); 396 #ifndef NO_WIDTH_PREC 397 result |= test(__LINE__, " 1024", "% d", 1024); 398 #endif 399 result |= test(__LINE__, "-1024", "% d", -1024); 400 #ifndef NO_WIDTH_PREC 401 result |= test(__LINE__, " 1024", "% i", 1024); 402 #endif 403 result |= test(__LINE__, "-1024", "% i", -1024); 404 result |= test(__LINE__, "1024", "% u", 1024); 405 result |= test(__LINE__, I("4294966272", "64512"), "% u", 4294966272U); 406 result |= test(__LINE__, "777", "% o", 511); 407 result |= test(__LINE__, I("37777777001", "177001"), "% o", 4294966785U); 408 result |= test(__LINE__, I("1234abcd", "abcd"), "% x", 305441741); 409 result |= test(__LINE__, I("edcb5433", "5433"), "% x", 3989525555U); 410 result |= test(__LINE__, I("1234ABCD", "ABCD"), "% X", 305441741); 411 result |= test(__LINE__, I("EDCB5433", "5433"), "% X", 3989525555U); 412 result |= test(__LINE__, "x", "% c", 'x'); 413 result |= test(__LINE__, "Hallo heimur", "%+ s", "Hallo heimur"); 414 #ifndef NO_WIDTH_PREC 415 result |= test(__LINE__, "+1024", "%+ d", 1024); 416 #endif 417 result |= test(__LINE__, "-1024", "%+ d", -1024); 418 #ifndef NO_WIDTH_PREC 419 result |= test(__LINE__, "+1024", "%+ i", 1024); 420 #endif 421 result |= test(__LINE__, "-1024", "%+ i", -1024); 422 result |= test(__LINE__, "1024", "%+ u", 1024); 423 result |= test(__LINE__, I("4294966272", "64512"), "%+ u", 4294966272U); 424 result |= test(__LINE__, "777", "%+ o", 511); 425 result |= test(__LINE__, I("37777777001", "177001"), "%+ o", 4294966785U); 426 result |= test(__LINE__, I("1234abcd", "abcd"), "%+ x", 305441741); 427 result |= test(__LINE__, I("edcb5433", "5433"), "%+ x", 3989525555U); 428 result |= test(__LINE__, I("1234ABCD", "ABCD"), "%+ X", 305441741); 429 result |= test(__LINE__, I("EDCB5433", "5433"), "%+ X", 3989525555U); 430 result |= test(__LINE__, "x", "%+ c", 'x'); 431 result |= test(__LINE__, "0777", "%#o", 511); 432 result |= test(__LINE__, I("037777777001", "0177001"), "%#o", 4294966785U); 433 result |= test(__LINE__, I("0x1234abcd", "0xabcd"), "%#x", 305441741); 434 result |= test(__LINE__, I("0xedcb5433", "0x5433"), "%#x", 3989525555U); 435 #ifndef NO_CASE_HEX 436 result |= test(__LINE__, I("0X1234ABCD", "0XABCD"), "%#X", 305441741); 437 result |= test(__LINE__, I("0XEDCB5433", "0X5433"), "%#X", 3989525555U); 438 #endif 439 #ifdef BINARY_FORMAT 440 result |= test(__LINE__, I("0b10010001101001010101111001101", "0b1010101111001101"), "%#b", 305441741); 441 result |= test(__LINE__, I("0b11101101110010110101010000110011", "0b101010000110011"), "%#b", 3989525555U); 442 result |= test(__LINE__, I("0B10010001101001010101111001101", "0B1010101111001101"), "%#B", 305441741); 443 result |= test(__LINE__, I("0B11101101110010110101010000110011", "0B101010000110011"), "%#B", 3989525555U); 444 #endif 445 result |= test(__LINE__, "0", "%#o", 0U); 446 result |= test(__LINE__, "0", "%#x", 0U); 447 result |= test(__LINE__, "0", "%#X", 0U); 448 result |= test(__LINE__, "Hallo heimur", "%1s", "Hallo heimur"); 449 result |= test(__LINE__, "1024", "%1d", 1024); 450 result |= test(__LINE__, "-1024", "%1d", -1024); 451 result |= test(__LINE__, "1024", "%1i", 1024); 452 result |= test(__LINE__, "-1024", "%1i", -1024); 453 result |= test(__LINE__, "1024", "%1u", 1024); 454 result |= test(__LINE__, I("4294966272", "64512"), "%1u", 4294966272U); 455 result |= test(__LINE__, "777", "%1o", 511); 456 result |= test(__LINE__, I("37777777001", "177001"), "%1o", 4294966785U); 457 result |= test(__LINE__, I("1234abcd", "abcd"), "%1x", 305441741); 458 result |= test(__LINE__, I("edcb5433", "5433"), "%1x", 3989525555U); 459 result |= test(__LINE__, I("1234ABCD", "ABCD"), "%1X", 305441741); 460 result |= test(__LINE__, I("EDCB5433", "5433"), "%1X", 3989525555U); 461 result |= test(__LINE__, "x", "%1c", 'x'); 462 #ifndef NO_WIDTH_PREC 463 result |= test(__LINE__, " Hallo", "%20s", "Hallo"); 464 result |= test(__LINE__, " 1024", "%20d", 1024); 465 result |= test(__LINE__, " -1024", "%20d", -1024); 466 result |= test(__LINE__, " 1024", "%20i", 1024); 467 result |= test(__LINE__, " -1024", "%20i", -1024); 468 result |= test(__LINE__, " 1024", "%20u", 1024); 469 result |= test(__LINE__, I(" 4294966272", " 64512"), "%20u", 4294966272U); 470 result |= test(__LINE__, " 777", "%20o", 511); 471 result |= test(__LINE__, I(" 37777777001", " 177001"), "%20o", 4294966785U); 472 result |= test(__LINE__, I(" 1234abcd", " abcd"), "%20x", 305441741); 473 result |= test(__LINE__, I(" edcb5433", " 5433"), "%20x", 3989525555U); 474 result |= test(__LINE__, I(" 1234ABCD", " ABCD"), "%20X", 305441741); 475 result |= test(__LINE__, I(" EDCB5433", " 5433"), "%20X", 3989525555U); 476 result |= test(__LINE__, " x", "%20c", 'x'); 477 result |= test(__LINE__, "Hallo ", "%-20s", "Hallo"); 478 result |= test(__LINE__, "1024 ", "%-20d", 1024); 479 result |= test(__LINE__, "-1024 ", "%-20d", -1024); 480 result |= test(__LINE__, "1024 ", "%-20i", 1024); 481 result |= test(__LINE__, "-1024 ", "%-20i", -1024); 482 result |= test(__LINE__, "1024 ", "%-20u", 1024); 483 result |= test(__LINE__, I("4294966272 ", "64512 "), "%-20u", 4294966272U); 484 result |= test(__LINE__, "777 ", "%-20o", 511); 485 result |= test(__LINE__, I("37777777001 ", "177001 "), "%-20o", 4294966785U); 486 result |= test(__LINE__, I("1234abcd ", "abcd "), "%-20x", 305441741); 487 result |= test(__LINE__, I("edcb5433 ", "5433 "), "%-20x", 3989525555U); 488 result |= test(__LINE__, I("1234ABCD ", "ABCD "), "%-20X", 305441741); 489 result |= test(__LINE__, I("EDCB5433 ", "5433 "), "%-20X", 3989525555U); 490 result |= test(__LINE__, "x ", "%-20c", 'x'); 491 result |= test(__LINE__, "00000000000000001024", "%020d", 1024); 492 result |= test(__LINE__, "-0000000000000001024", "%020d", -1024); 493 result |= test(__LINE__, "00000000000000001024", "%020i", 1024); 494 result |= test(__LINE__, "-0000000000000001024", "%020i", -1024); 495 result |= test(__LINE__, "00000000000000001024", "%020u", 1024); 496 result |= test(__LINE__, I("00000000004294966272", "00000000000000064512"), "%020u", 4294966272U); 497 result |= test(__LINE__, "00000000000000000777", "%020o", 511); 498 result |= test(__LINE__, I("00000000037777777001", "00000000000000177001"), "%020o", 4294966785U); 499 result |= test(__LINE__, I("0000000000001234abcd", "0000000000000000abcd"), "%020x", 305441741); 500 result |= test(__LINE__, I("000000000000edcb5433", "00000000000000005433"), "%020x", 3989525555U); 501 result |= test(__LINE__, I("0000000000001234ABCD", "0000000000000000ABCD"), "%020X", 305441741); 502 result |= test(__LINE__, I("000000000000EDCB5433", "00000000000000005433"), "%020X", 3989525555U); 503 result |= test(__LINE__, " 0777", "%#20o", 511); 504 result |= test(__LINE__, I(" 037777777001", " 0177001"), "%#20o", 4294966785U); 505 result |= test(__LINE__, I(" 0x1234abcd", " 0xabcd"), "%#20x", 305441741); 506 result |= test(__LINE__, I(" 0xedcb5433", " 0x5433"), "%#20x", 3989525555U); 507 result |= test(__LINE__, I(" 0X1234ABCD", " 0XABCD"), "%#20X", 305441741); 508 result |= test(__LINE__, I(" 0XEDCB5433", " 0X5433"), "%#20X", 3989525555U); 509 result |= test(__LINE__, "00000000000000000777", "%#020o", 511); 510 result |= test(__LINE__, I("00000000037777777001", "00000000000000177001"), "%#020o", 4294966785U); 511 result |= test(__LINE__, I("0x00000000001234abcd", "0x00000000000000abcd"), "%#020x", 305441741); 512 result |= test(__LINE__, I("0x0000000000edcb5433", "0x000000000000005433"), "%#020x", 3989525555U); 513 result |= test(__LINE__, I("0X00000000001234ABCD", "0X00000000000000ABCD"), "%#020X", 305441741); 514 result |= test(__LINE__, I("0X0000000000EDCB5433", "0X000000000000005433"), "%#020X", 3989525555U); 515 result |= test(__LINE__, "Hallo ", "%0-20s", "Hallo"); 516 result |= test(__LINE__, "1024 ", "%0-20d", 1024); 517 result |= test(__LINE__, "-1024 ", "%0-20d", -1024); 518 result |= test(__LINE__, "1024 ", "%0-20i", 1024); 519 result |= test(__LINE__, "-1024 ", "%0-20i", -1024); 520 result |= test(__LINE__, "1024 ", "%0-20u", 1024); 521 result |= test(__LINE__, I("4294966272 ", "64512 "), "%0-20u", 4294966272U); 522 result |= test(__LINE__, "777 ", "%-020o", 511); 523 result |= test(__LINE__, I("37777777001 ", "177001 "), "%-020o", 4294966785U); 524 result |= test(__LINE__, I("1234abcd ", "abcd "), "%-020x", 305441741); 525 result |= test(__LINE__, I("edcb5433 ", "5433 "), "%-020x", 3989525555U); 526 result |= test(__LINE__, I("1234ABCD ", "ABCD "), "%-020X", 305441741); 527 result |= test(__LINE__, I("EDCB5433 ", "5433 "), "%-020X", 3989525555U); 528 result |= test(__LINE__, "x ", "%-020c", 'x'); 529 result |= test(__LINE__, " Hallo", "%*s", 20, "Hallo"); 530 result |= test(__LINE__, " 1024", "%*d", 20, 1024); 531 result |= test(__LINE__, " -1024", "%*d", 20, -1024); 532 result |= test(__LINE__, " 1024", "%*i", 20, 1024); 533 result |= test(__LINE__, " -1024", "%*i", 20, -1024); 534 result |= test(__LINE__, " 1024", "%*u", 20, 1024); 535 result |= test(__LINE__, I(" 4294966272", " 64512"), "%*u", 20, 4294966272U); 536 result |= test(__LINE__, " 777", "%*o", 20, 511); 537 result |= test(__LINE__, I(" 37777777001", " 177001"), "%*o", 20, 4294966785U); 538 result |= test(__LINE__, I(" 1234abcd", " abcd"), "%*x", 20, 305441741); 539 result |= test(__LINE__, I(" edcb5433", " 5433"), "%*x", 20, 3989525555U); 540 result |= test(__LINE__, I(" 1234ABCD", " ABCD"), "%*X", 20, 305441741); 541 result |= test(__LINE__, I(" EDCB5433", " 5433"), "%*X", 20, 3989525555U); 542 result |= test(__LINE__, " x", "%*c", 20, 'x'); 543 result |= test(__LINE__, "Hallo heimur", "%.20s", "Hallo heimur"); 544 result |= test(__LINE__, "00000000000000001024", "%.20d", 1024); 545 result |= test(__LINE__, "-00000000000000001024", "%.20d", -1024); 546 result |= test(__LINE__, "00000000000000001024", "%.20i", 1024); 547 result |= test(__LINE__, "-00000000000000001024", "%.20i", -1024); 548 result |= test(__LINE__, "00000000000000001024", "%.20u", 1024); 549 result |= test(__LINE__, I("00000000004294966272", "00000000000000064512"), "%.20u", 4294966272U); 550 result |= test(__LINE__, "00000000000000000777", "%.20o", 511); 551 result |= test(__LINE__, I("00000000037777777001", "00000000000000177001"), "%.20o", 4294966785U); 552 result |= test(__LINE__, I("0000000000001234abcd", "0000000000000000abcd"), "%.20x", 305441741); 553 result |= test(__LINE__, I("000000000000edcb5433", "00000000000000005433"), "%.20x", 3989525555U); 554 result |= test(__LINE__, I("0000000000001234ABCD", "0000000000000000ABCD"), "%.20X", 305441741); 555 result |= test(__LINE__, I("000000000000EDCB5433", "00000000000000005433"), "%.20X", 3989525555U); 556 result |= test(__LINE__, " Hallo", "%20.5s", "Hallo heimur"); 557 result |= test(__LINE__, " 01024", "%20.5d", 1024); 558 result |= test(__LINE__, " -01024", "%20.5d", -1024); 559 result |= test(__LINE__, " 01024", "%20.5i", 1024); 560 result |= test(__LINE__, " -01024", "%20.5i", -1024); 561 result |= test(__LINE__, " 01024", "%20.5u", 1024); 562 result |= test(__LINE__, I(" 4294966272", " 64512"), "%20.5u", 4294966272U); 563 result |= test(__LINE__, " 00777", "%20.5o", 511); 564 result |= test(__LINE__, I(" 37777777001", " 177001"), "%20.5o", 4294966785U); 565 result |= test(__LINE__, I(" 1234abcd", " 0abcd"), "%20.5x", 305441741); 566 result |= test(__LINE__, I(" 00edcb5433", " 0000005433"), "%20.10x", 3989525555U); 567 result |= test(__LINE__, I(" 1234ABCD", " 0ABCD"), "%20.5X", 305441741); 568 result |= test(__LINE__, I(" 00EDCB5433", " 0000005433"), "%20.10X", 3989525555U); 569 result |= test(__LINE__, " 01024", "%020.5d", 1024); 570 result |= test(__LINE__, " -01024", "%020.5d", -1024); 571 result |= test(__LINE__, " 01024", "%020.5i", 1024); 572 result |= test(__LINE__, " -01024", "%020.5i", -1024); 573 result |= test(__LINE__, " 01024", "%020.5u", 1024); 574 result |= test(__LINE__, I(" 4294966272", " 64512"), "%020.5u", 4294966272U); 575 result |= test(__LINE__, " 00777", "%020.5o", 511); 576 result |= test(__LINE__, I(" 37777777001", " 177001"), "%020.5o", 4294966785U); 577 result |= test(__LINE__, I(" 1234abcd", " 0abcd"), "%020.5x", 305441741); 578 result |= test(__LINE__, I(" 00edcb5433", " 0000005433"), "%020.10x", 3989525555U); 579 result |= test(__LINE__, I(" 1234ABCD", " 0ABCD"), "%020.5X", 305441741); 580 result |= test(__LINE__, I(" 00EDCB5433", " 0000005433"), "%020.10X", 3989525555U); 581 result |= test(__LINE__, "", "%.0s", "Hallo heimur"); 582 result |= test(__LINE__, " ", "%20.0s", "Hallo heimur"); 583 result |= test(__LINE__, "", "%.s", "Hallo heimur"); 584 result |= test(__LINE__, " ", "%20.s", "Hallo heimur"); 585 result |= test(__LINE__, " 1024", "%20.0d", 1024); 586 result |= test(__LINE__, " -1024", "%20.d", -1024); 587 result |= test(__LINE__, " ", "%20.d", 0); 588 result |= test(__LINE__, " 1024", "%20.0i", 1024); 589 result |= test(__LINE__, " -1024", "%20.i", -1024); 590 result |= test(__LINE__, " ", "%20.i", 0); 591 result |= test(__LINE__, " 1024", "%20.u", 1024); 592 result |= test(__LINE__, I(" 4294966272", " 64512") , "%20.0u", 4294966272U); 593 result |= test(__LINE__, " ", "%20.u", 0U); 594 result |= test(__LINE__, " 777", "%20.o", 511); 595 result |= test(__LINE__, I(" 37777777001", " 177001"), "%20.0o", 4294966785U); 596 result |= test(__LINE__, " ", "%20.o", 0U); 597 result |= test(__LINE__, I(" 1234abcd", " abcd"), "%20.x", 305441741); 598 result |= test(__LINE__, I(" edcb5433", " 5433"), "%20.0x", 3989525555U); 599 result |= test(__LINE__, " ", "%20.x", 0U); 600 result |= test(__LINE__, I(" 1234ABCD", " ABCD"), "%20.X", 305441741); 601 result |= test(__LINE__, I(" EDCB5433", " 5433"), "%20.0X", 3989525555U); 602 result |= test(__LINE__, " ", "%20.X", 0U); 603 result |= test(__LINE__, "Hallo ", "% -0+*.*s", 20, 5, "Hallo heimur"); 604 result |= test(__LINE__, "+01024 ", "% -0+*.*d", 20, 5, 1024); 605 result |= test(__LINE__, "-01024 ", "% -0+*.*d", 20, 5, -1024); 606 result |= test(__LINE__, "+01024 ", "% -0+*.*i", 20, 5, 1024); 607 result |= test(__LINE__, "-01024 ", "% 0-+*.*i", 20, 5, -1024); 608 result |= test(__LINE__, "01024 ", "% 0-+*.*u", 20, 5, 1024); 609 result |= test(__LINE__, I("4294966272 ", "64512 "), "% 0-+*.*u", 20, 5, 4294966272U); 610 result |= test(__LINE__, "00777 ", "%+ -0*.*o", 20, 5, 511); 611 result |= test(__LINE__, I("37777777001 ", "177001 "), "%+ -0*.*o", 20, 5, 4294966785U); 612 result |= test(__LINE__, I("1234abcd ", "0abcd "), "%+ -0*.*x", 20, 5, 305441741); 613 result |= test(__LINE__, I("00edcb5433 ", "0000005433 "), "%+ -0*.*x", 20, 10, 3989525555U); 614 result |= test(__LINE__, I("1234ABCD ", "0ABCD "), "% -+0*.*X", 20, 5, 305441741); 615 result |= test(__LINE__, I("00EDCB5433 ", "0000005433 "), "% -+0*.*X", 20, 10, 3989525555U); 616 result |= test(__LINE__, "hi x", "%*sx", -3, "hi"); 617 #endif 618 #ifndef NO_FLOAT 619 result |= test(__LINE__, "1.000e-38", "%.3e", printf_float(1e-38)); 620 #ifndef LOW_FLOAT 621 result |= test(__LINE__, "1.000e-308", "%.3e", printf_float(1e-308)); 622 #endif 623 #endif 624 #ifndef _NANO_FORMATTED_IO 625 #ifndef NO_LONGLONG 626 result |= test(__LINE__, "1, 1", "%-*.llu, %-*.llu",1,1ULL,1,1ULL); 627 #endif 628 #endif 629 #ifndef NO_FLOAT 630 result |= test(__LINE__, "1e-09", "%g", printf_float(0.000000001)); 631 result |= test(__LINE__, "1e-08", "%g", printf_float(0.00000001)); 632 result |= test(__LINE__, "1e-07", "%g", printf_float(0.0000001)); 633 result |= test(__LINE__, "1e-06", "%g", printf_float(0.000001)); 634 result |= test(__LINE__, "0.0001", "%g", printf_float(0.0001)); 635 result |= test(__LINE__, "0.001", "%g", printf_float(0.001)); 636 result |= test(__LINE__, "0.01", "%g", printf_float(0.01)); 637 result |= test(__LINE__, "0.1", "%g", printf_float(0.1)); 638 result |= test(__LINE__, "1", "%g", printf_float(1.0)); 639 result |= test(__LINE__, "10", "%g", printf_float(10.0)); 640 result |= test(__LINE__, "100", "%g", printf_float(100.0)); 641 result |= test(__LINE__, "1000", "%g", printf_float(1000.0)); 642 result |= test(__LINE__, "10000", "%g", printf_float(10000.0)); 643 result |= test(__LINE__, "100000", "%g", printf_float(100000.0)); 644 result |= test(__LINE__, "1e+06", "%g", printf_float(1000000.0)); 645 result |= test(__LINE__, "1e+07", "%g", printf_float(10000000.0)); 646 result |= test(__LINE__, "1e+08", "%g", printf_float(100000000.0)); 647 result |= test(__LINE__, "10.0000", "%#.6g", printf_float(10.0)); 648 result |= test(__LINE__, "10", "%.6g", printf_float(10.0)); 649 result |= test(__LINE__, "10.00000000000000000000", "%#.22g", printf_float(10.0)); 650 #endif 651 652 // Regression test for wrong behavior with negative precision in tinystdio 653 // this might fail for configurations not using tinystdio, so for a first 654 // PR, only run these test for tinystdio. 655 #ifndef NO_WIDTH_PREC 656 result |= test(__LINE__, "", "%.*s", 0, "123456"); 657 result |= test(__LINE__, "1234", "%.*s", 4, "123456"); 658 result |= test(__LINE__, "123456", "%.*s", -4, "123456"); 659 result |= test(__LINE__, "42", "%.*d", 0, 42); 660 result |= test(__LINE__, "000042", "%.*d", 6, 42); 661 result |= test(__LINE__, "42", "%.*d", -6, 42); 662 #endif 663 #ifndef NO_FLOAT 664 result |= test(__LINE__, "0", "%.*f", 0, printf_float(0.123)); 665 result |= test(__LINE__, "0.1", "%.*f", 1, printf_float(0.123)); 666 result |= test(__LINE__, "0.123000", "%.*f", -1, printf_float(0.123)); 667 #endif 668 #ifdef _WANT_IO_C99_FORMATS 669 { 670 char c[64]; 671 #ifndef _WANT_IO_LONG_LONG 672 if (sizeof (intmax_t) <= sizeof(long)) 673 #endif 674 #ifndef _NANO_FORMATTED_IO 675 #ifndef NO_WIDTH_PREC 676 result |= test(__LINE__, " 42", "%4jd", (intmax_t)42L); 677 #endif 678 result |= test(__LINE__, "64", "%zu", sizeof c); 679 result |= test(__LINE__, "12", "%td", (c+12) - c); 680 #else 681 (void) c; 682 #endif 683 #ifndef NO_FLOAT 684 result |= test(__LINE__, "0x1p+0", "%a", printf_float(0x1p+0)); 685 result |= test(__LINE__, "0x0p+0", "%a", printf_float(0.0)); 686 result |= test(__LINE__, "-0x0p+0", "%a", printf_float(-0.0)); 687 result |= test(__LINE__, "0x1.9p+4", "%.1a", printf_float(0x1.89p+4)); 688 result |= test(__LINE__, "0x1.8p+4", "%.1a", printf_float(0x1.88p+4)); 689 result |= test(__LINE__, "0x1.8p+4", "%.1a", printf_float(0x1.78p+4)); 690 result |= test(__LINE__, "0x1.7p+4", "%.1a", printf_float(0x1.77p+4)); 691 result |= test(__LINE__, "0x1.fffffep+126", "%a", printf_float(0x1.fffffep+126f)); 692 result |= test(__LINE__, "0x1.234564p-126", "%a", printf_float(0x1.234564p-126f)); 693 result |= test(__LINE__, "0x1.234566p-126", "%a", printf_float(0x1.234566p-126f)); 694 result |= test(__LINE__, "0X1.FFFFFEP+126", "%A", printf_float(0x1.fffffep+126f)); 695 result |= test(__LINE__, "0X1.234564P-126", "%A", printf_float(0x1.234564p-126f)); 696 result |= test(__LINE__, "0X1.234566P-126", "%A", printf_float(0x1.234566p-126f)); 697 result |= test(__LINE__, "0x1.6p+1", "%.1a", printf_float(0x1.6789ap+1f)); 698 result |= test(__LINE__, "0x1.68p+1", "%.2a", printf_float(0x1.6789ap+1f)); 699 result |= test(__LINE__, "0x1.679p+1", "%.3a", printf_float(0x1.6789ap+1f)); 700 result |= test(__LINE__, "0x1.678ap+1", "%.4a", printf_float(0x1.6789ap+1f)); 701 result |= test(__LINE__, "0x1.6789ap+1", "%.5a", printf_float(0x1.6789ap+1f)); 702 result |= test(__LINE__, "0x1.6789a0p+1", "%.6a", printf_float(0x1.6789ap+1f)); 703 result |= test(__LINE__, "0x1.ffp+1", "%.2a", printf_float(0x1.ffp+1f)); 704 result |= test(__LINE__, "0x2.0p+1", "%.1a", printf_float(0x1.ffp+1f)); 705 result |= test(__LINE__, "0x2p+4", "%.a", printf_float(24.0)); 706 result |= test(__LINE__, "0X2P+4", "%.A", printf_float(24.0)); 707 result |= test(__LINE__, "nan", "%a", printf_float(NAN)); 708 result |= test(__LINE__, "-nan", "%a", printf_float(-(FLOAT) NAN)); 709 result |= test(__LINE__, "inf", "%a", printf_float(INFINITY)); 710 result |= test(__LINE__, "-inf", "%a", printf_float(-INFINITY)); 711 result |= test(__LINE__, "NAN", "%A", printf_float(NAN)); 712 result |= test(__LINE__, "-NAN", "%A", printf_float(-(FLOAT) NAN)); 713 result |= test(__LINE__, "INF", "%A", printf_float(INFINITY)); 714 result |= test(__LINE__, "-INF", "%A", printf_float(-(FLOAT) INFINITY)); 715 716 #ifndef NO_LONGDOUBLE 717 #if __LDBL_MANT_DIG__ == 64 && (!defined(__PICOLIBC__) || defined(TINY_STDIO)) 718 /* 719 * x86 and m68k 80-bit format fill the top 720 * hex digit so they generate a different result than 721 * regular formats when using tinystdio or glibc. 722 */ 723 result |= test(__LINE__, "0x8p-3", "%La", 0x1p+0l); 724 result |= test(__LINE__, "0x0p+0", "%La", 0x0p+0l); 725 result |= test(__LINE__, "-0x0p+0", "%La", -0x0p+0l); 726 result |= test(__LINE__, "0xc.4p+1", "%.1La", 0x1.89p+4l); 727 result |= test(__LINE__, "0xc.4p+1", "%.1La", 0x1.88p+4l); 728 result |= test(__LINE__, "0xb.cp+1", "%.1La", 0x1.78p+4l); 729 result |= test(__LINE__, "0xb.cp+1", "%.1La", 0x1.77p+4l); 730 result |= test(__LINE__, "0xf.fffffp+123", "%La", 0x1.fffffep+126l); 731 result |= test(__LINE__, "0x9.1a2b2p-129", "%La", 0x1.234564p-126l); 732 result |= test(__LINE__, "0x9.1a2b3p-129", "%La", 0x1.234566p-126l); 733 result |= test(__LINE__, "0XF.FFFFFP+123", "%LA", 0X1.FFFFFEP+126l); 734 result |= test(__LINE__, "0X9.1A2B2P-129", "%LA", 0X1.234564P-126l); 735 result |= test(__LINE__, "0X9.1A2B3P-129", "%LA", 0X1.234566P-126l); 736 result |= test(__LINE__, "0xb.4p-2", "%.1La", 0x1.6789ap+1l); 737 result |= test(__LINE__, "0xb.3cp-2", "%.2La", 0x1.6789ap+1l); 738 result |= test(__LINE__, "0xb.3c5p-2", "%.3La", 0x1.6789ap+1l); 739 result |= test(__LINE__, "0xb.3c4dp-2", "%.4La", 0x1.6789ap+1l); 740 result |= test(__LINE__, "0xb.3c4d0p-2", "%.5La", 0x1.6789ap+1l); 741 result |= test(__LINE__, "0xb.3c4d00p-2", "%.6La", 0x1.6789ap+1l); 742 result |= test(__LINE__, "0xf.f8p-2", "%.2La", 0x1.ffp+1l); 743 result |= test(__LINE__, "0x1.0p+2", "%.1La", 0x1.ffp+1l); 744 result |= test(__LINE__, "0xcp+1", "%.La", 24.0l); 745 result |= test(__LINE__, "0XCP+1", "%.LA", 24.0l); 746 #else 747 result |= test(__LINE__, "0x1p+0", "%La", (long double) 0x1p+0l); 748 result |= test(__LINE__, "0x0p+0", "%La", 0.0L); 749 result |= test(__LINE__, "-0x0p+0", "%La", -0.0L); 750 result |= test(__LINE__, "0x1.9p+4", "%.1La", 0x1.89p+4L); 751 result |= test(__LINE__, "0x1.8p+4", "%.1La", 0x1.88p+4L); 752 result |= test(__LINE__, "0x1.8p+4", "%.1La", 0x1.78p+4L); 753 result |= test(__LINE__, "0x1.7p+4", "%.1La", 0x1.77p+4L); 754 result |= test(__LINE__, "0x1.fffffep+126", "%La", (long double) 0x1.fffffep+126); 755 result |= test(__LINE__, "0x1.234564p-126", "%La", (long double) 0x1.234564p-126); 756 result |= test(__LINE__, "0x1.234566p-126", "%La", (long double) 0x1.234566p-126); 757 result |= test(__LINE__, "0X1.FFFFFEP+126", "%LA", (long double) 0x1.fffffep+126); 758 result |= test(__LINE__, "0X1.234564P-126", "%LA", (long double) 0x1.234564p-126); 759 result |= test(__LINE__, "0X1.234566P-126", "%LA", (long double) 0x1.234566p-126); 760 result |= test(__LINE__, "0x1.6p+1", "%.1La", (long double) 0x1.6789ap+1); 761 result |= test(__LINE__, "0x1.68p+1", "%.2La", (long double) 0x1.6789ap+1); 762 result |= test(__LINE__, "0x1.679p+1", "%.3La", (long double) 0x1.6789ap+1); 763 result |= test(__LINE__, "0x1.678ap+1", "%.4La", (long double) 0x1.6789ap+1); 764 result |= test(__LINE__, "0x1.6789ap+1", "%.5La", (long double) 0x1.6789ap+1); 765 result |= test(__LINE__, "0x1.6789a0p+1", "%.6La", (long double) 0x1.6789ap+1); 766 result |= test(__LINE__, "0x1.ffp+1", "%.2La", (long double) 0x1.ffp+1); 767 result |= test(__LINE__, "0x2.0p+1", "%.1La", (long double) 0x1.ffp+1); 768 result |= test(__LINE__, "0x2p+4", "%.La", 24.0L); 769 result |= test(__LINE__, "0X2P+4", "%.LA", 24.0L); 770 #endif 771 result |= test(__LINE__, "nan", "%La", (long double) NAN); 772 result |= test(__LINE__, "-nan", "%La", (long double) -NAN); 773 result |= test(__LINE__, "inf", "%La", (long double) INFINITY); 774 result |= test(__LINE__, "-inf", "%La", (long double) -INFINITY); 775 result |= test(__LINE__, "NAN", "%LA", (long double) NAN); 776 result |= test(__LINE__, "-NAN", "%LA", (long double) -NAN); 777 result |= test(__LINE__, "INF", "%LA", (long double) INFINITY); 778 result |= test(__LINE__, "-INF", "%LA", (long double) -INFINITY); 779 #endif 780 #ifdef LOW_FLOAT 781 #ifdef NORMALIZED_A 782 result |= test(__LINE__, "0x1p-149", "%a", printf_float(0x1p-149)); 783 result |= test(__LINE__, "0x1p-127", "%.a", printf_float(0x1p-127)); 784 #else 785 result |= test(__LINE__, "0x0.000002p-126", "%a", printf_float(0x1p-149)); 786 result |= test(__LINE__, "0x0p-126", "%.a", printf_float(0x1p-127)); 787 #endif 788 #else 789 result |= test(__LINE__, "0x1.306efbp-98", "%a", printf_float(3752432815e-39)); 790 #ifdef NORMALIZED_A 791 /* newlib legacy stdio normalizes %a format */ 792 result |= test(__LINE__, "0x1p-1074", "%a", printf_float(0x1p-1074)); 793 result |= test(__LINE__, "0x1p-1023", "%.a", printf_float(0x1p-1023)); 794 #else 795 /* glibc and picolibc show denorms like this */ 796 result |= test(__LINE__, "0x0.0000000000001p-1022", "%a", printf_float(0x1p-1074)); 797 result |= test(__LINE__, "0x0p-1022", "%.a", printf_float(0x1p-1023)); 798 #endif 799 result |= test(__LINE__, "0x1.fffffffffffffp+1022", "%a", printf_float(0x1.fffffffffffffp+1022)); 800 result |= test(__LINE__, "0x1.23456789abcdep-1022", "%a", printf_float(0x1.23456789abcdep-1022)); 801 result |= test(__LINE__, "0x1.23456789abcdfp-1022", "%a", printf_float(0x1.23456789abcdfp-1022)); 802 result |= test(__LINE__, "0X1.FFFFFFFFFFFFFP+1022", "%A", printf_float(0x1.fffffffffffffp+1022)); 803 result |= test(__LINE__, "0X1.23456789ABCDEP-1022", "%A", printf_float(0x1.23456789abcdep-1022)); 804 result |= test(__LINE__, "0X1.23456789ABCDFP-1022", "%A", printf_float(0x1.23456789abcdfp-1022)); 805 result |= test(__LINE__, "0X1.D749096BB98C800P+8", "%.15A", printf_float(0x1.D749096BB98C8p+8)); 806 #endif 807 #endif 808 /* test %ls for wchar_t string */ 809 result |= testw(__LINE__, L"foo", L"%.3ls", L"foobar"); 810 /* test %s for mbchar string */ 811 result |= testw(__LINE__, L"foo", L"%.3s", "foobar"); 812 813 wchar_t wc = 0x1234; 814 815 /* test %lc for wchar_t */ 816 wchar_t wb[2] = { 0x1234, 0 }; 817 result |= testw(__LINE__, wb, L"%lc", wc); 818 819 /* make sure %c truncates to char */ 820 wb[0] = 0x34; 821 result |= testw(__LINE__, wb, L"%c", wc); 822 823 #ifndef NO_MBCHAR 824 wb[0] = 0x3330; 825 result |= testw(__LINE__, wb, L"%s", "㌰"); 826 result |= test(__LINE__, "$㌰$", "$%lc$", 0x3330); 827 #endif 828 #ifndef NO_WCHAR 829 result |= test(__LINE__, "foobar", "%ls", L"foobar"); 830 result |= test(__LINE__, "$c$", "$%lc$", L'c'); 831 #endif 832 } 833 #endif 834