30 #define CATCH_CONFIG_MAIN 40 #include "../printf.h" 41 #include "../printf.c" 84 REQUIRE(!strcmp(buffer,
"-1000"));
93 va_start(args, buffer);
101 va_start(args, buffer);
109 va_start(args, buffer);
130 REQUIRE(!strcmp(buffer,
"-1"));
141 REQUIRE(!strcmp(buffer,
" 42"));
144 REQUIRE(!strcmp(buffer,
"-42"));
147 REQUIRE(!strcmp(buffer,
" 42"));
150 REQUIRE(!strcmp(buffer,
" -42"));
153 REQUIRE(!strcmp(buffer,
" 42"));
156 REQUIRE(!strcmp(buffer,
" -42"));
162 REQUIRE(!strcmp(buffer,
" -42.987"));
165 REQUIRE(!strcmp(buffer,
" 42.987"));
168 REQUIRE(!strcmp(buffer,
"Hello testing"));
174 REQUIRE(!strcmp(buffer,
"-1024"));
177 REQUIRE(!strcmp(buffer,
" 1024"));
180 REQUIRE(!strcmp(buffer,
"-1024"));
183 REQUIRE(!strcmp(buffer,
"1024"));
186 REQUIRE(!strcmp(buffer,
"4294966272"));
189 REQUIRE(!strcmp(buffer,
"777"));
192 REQUIRE(!strcmp(buffer,
"37777777001"));
195 REQUIRE(!strcmp(buffer,
"1234abcd"));
198 REQUIRE(!strcmp(buffer,
"edcb5433"));
201 REQUIRE(!strcmp(buffer,
"1234ABCD"));
204 REQUIRE(!strcmp(buffer,
"EDCB5433"));
215 REQUIRE(!strcmp(buffer,
"+42"));
218 REQUIRE(!strcmp(buffer,
"-42"));
221 REQUIRE(!strcmp(buffer,
" +42"));
224 REQUIRE(!strcmp(buffer,
" -42"));
230 REQUIRE(!strcmp(buffer,
" -42"));
233 REQUIRE(!strcmp(buffer,
"Hello testing"));
236 REQUIRE(!strcmp(buffer,
"+1024"));
239 REQUIRE(!strcmp(buffer,
"-1024"));
242 REQUIRE(!strcmp(buffer,
"+1024"));
245 REQUIRE(!strcmp(buffer,
"-1024"));
248 REQUIRE(!strcmp(buffer,
"1024"));
251 REQUIRE(!strcmp(buffer,
"4294966272"));
254 REQUIRE(!strcmp(buffer,
"777"));
257 REQUIRE(!strcmp(buffer,
"37777777001"));
260 REQUIRE(!strcmp(buffer,
"1234abcd"));
263 REQUIRE(!strcmp(buffer,
"edcb5433"));
266 REQUIRE(!strcmp(buffer,
"1234ABCD"));
269 REQUIRE(!strcmp(buffer,
"EDCB5433"));
283 REQUIRE(!strcmp(buffer,
"42"));
286 REQUIRE(!strcmp(buffer,
"42"));
289 REQUIRE(!strcmp(buffer,
"-42"));
292 REQUIRE(!strcmp(buffer,
"00042"));
295 REQUIRE(!strcmp(buffer,
"-0042"));
298 REQUIRE(!strcmp(buffer,
"000000000000042"));
301 REQUIRE(!strcmp(buffer,
"-00000000000042"));
304 REQUIRE(!strcmp(buffer,
"000000000042.12"));
307 REQUIRE(!strcmp(buffer,
"00000000042.988"));
310 REQUIRE(!strcmp(buffer,
"-00000042.98760"));
318 REQUIRE(!strcmp(buffer,
"42"));
321 REQUIRE(!strcmp(buffer,
"-42"));
324 REQUIRE(!strcmp(buffer,
"42 "));
327 REQUIRE(!strcmp(buffer,
"-42 "));
330 REQUIRE(!strcmp(buffer,
"42 "));
333 REQUIRE(!strcmp(buffer,
"-42 "));
336 REQUIRE(!strcmp(buffer,
"42"));
342 REQUIRE(!strcmp(buffer,
"42 "));
345 REQUIRE(!strcmp(buffer,
"-42 "));
348 REQUIRE(!strcmp(buffer,
"42 "));
351 REQUIRE(!strcmp(buffer,
"-42 "));
354 REQUIRE(!strcmp(buffer,
"42"));
357 REQUIRE(!strcmp(buffer,
"-42"));
360 REQUIRE(!strcmp(buffer,
"42 "));
363 REQUIRE(!strcmp(buffer,
"-42 "));
366 REQUIRE(!strcmp(buffer,
"42 "));
369 REQUIRE(!strcmp(buffer,
"-42 "));
372 #ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL 373 REQUIRE(!strcmp(buffer,
"-4.200e+01 "));
379 #ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL 380 REQUIRE(!strcmp(buffer,
"-42.0 "));
397 REQUIRE(!strcmp(buffer,
"0x0000614e"));
399 REQUIRE(!strcmp(buffer,
"0b110"));
407 REQUIRE(!strcmp(buffer,
"Hello testing"));
410 REQUIRE(!strcmp(buffer,
"Hello testing"));
413 REQUIRE(!strcmp(buffer,
"1024"));
416 REQUIRE(!strcmp(buffer,
"-1024"));
419 REQUIRE(!strcmp(buffer,
"1024"));
422 REQUIRE(!strcmp(buffer,
"-1024"));
425 REQUIRE(!strcmp(buffer,
"1024"));
428 REQUIRE(!strcmp(buffer,
"4294966272"));
431 REQUIRE(!strcmp(buffer,
"777"));
434 REQUIRE(!strcmp(buffer,
"37777777001"));
437 REQUIRE(!strcmp(buffer,
"1234abcd"));
440 REQUIRE(!strcmp(buffer,
"edcb5433"));
443 REQUIRE(!strcmp(buffer,
"1234ABCD"));
446 REQUIRE(!strcmp(buffer,
"EDCB5433"));
457 REQUIRE(!strcmp(buffer,
"Hello testing"));
460 REQUIRE(!strcmp(buffer,
"1024"));
463 REQUIRE(!strcmp(buffer,
"-1024"));
466 REQUIRE(!strcmp(buffer,
"1024"));
469 REQUIRE(!strcmp(buffer,
"-1024"));
472 REQUIRE(!strcmp(buffer,
"1024"));
475 REQUIRE(!strcmp(buffer,
"4294966272"));
478 REQUIRE(!strcmp(buffer,
"777"));
481 REQUIRE(!strcmp(buffer,
"37777777001"));
484 REQUIRE(!strcmp(buffer,
"1234abcd"));
487 REQUIRE(!strcmp(buffer,
"edcb5433"));
490 REQUIRE(!strcmp(buffer,
"1234ABCD"));
493 REQUIRE(!strcmp(buffer,
"EDCB5433"));
504 REQUIRE(!strcmp(buffer,
" Hello"));
507 REQUIRE(!strcmp(buffer,
" 1024"));
510 REQUIRE(!strcmp(buffer,
" -1024"));
513 REQUIRE(!strcmp(buffer,
" 1024"));
516 REQUIRE(!strcmp(buffer,
" -1024"));
519 REQUIRE(!strcmp(buffer,
" 1024"));
522 REQUIRE(!strcmp(buffer,
" 4294966272"));
525 REQUIRE(!strcmp(buffer,
" 777"));
528 REQUIRE(!strcmp(buffer,
" 37777777001"));
531 REQUIRE(!strcmp(buffer,
" 1234abcd"));
534 REQUIRE(!strcmp(buffer,
" edcb5433"));
537 REQUIRE(!strcmp(buffer,
" 1234ABCD"));
540 REQUIRE(!strcmp(buffer,
" EDCB5433"));
543 REQUIRE(!strcmp(buffer,
" x"));
551 REQUIRE(!strcmp(buffer,
" Hello"));
554 REQUIRE(!strcmp(buffer,
" 1024"));
557 REQUIRE(!strcmp(buffer,
" -1024"));
560 REQUIRE(!strcmp(buffer,
" 1024"));
563 REQUIRE(!strcmp(buffer,
" -1024"));
566 REQUIRE(!strcmp(buffer,
" 1024"));
569 REQUIRE(!strcmp(buffer,
" 4294966272"));
572 REQUIRE(!strcmp(buffer,
" 777"));
575 REQUIRE(!strcmp(buffer,
" 37777777001"));
578 REQUIRE(!strcmp(buffer,
" 1234abcd"));
581 REQUIRE(!strcmp(buffer,
" edcb5433"));
584 REQUIRE(!strcmp(buffer,
" 1234ABCD"));
587 REQUIRE(!strcmp(buffer,
" EDCB5433"));
590 REQUIRE(!strcmp(buffer,
" x"));
598 REQUIRE(!strcmp(buffer,
"Hello "));
601 REQUIRE(!strcmp(buffer,
"1024 "));
604 REQUIRE(!strcmp(buffer,
"-1024 "));
607 REQUIRE(!strcmp(buffer,
"1024 "));
610 REQUIRE(!strcmp(buffer,
"-1024 "));
613 REQUIRE(!strcmp(buffer,
"1024 "));
616 REQUIRE(!strcmp(buffer,
"1024.1234 "));
619 REQUIRE(!strcmp(buffer,
"4294966272 "));
622 REQUIRE(!strcmp(buffer,
"777 "));
625 REQUIRE(!strcmp(buffer,
"37777777001 "));
628 REQUIRE(!strcmp(buffer,
"1234abcd "));
631 REQUIRE(!strcmp(buffer,
"edcb5433 "));
634 REQUIRE(!strcmp(buffer,
"1234ABCD "));
637 REQUIRE(!strcmp(buffer,
"EDCB5433 "));
640 REQUIRE(!strcmp(buffer,
"x "));
643 REQUIRE(!strcmp(buffer,
"| 9| |9 | | 9|"));
646 REQUIRE(!strcmp(buffer,
"| 10| |10| | 10|"));
649 REQUIRE(!strcmp(buffer,
"| 9| |9 | | 9|"));
652 REQUIRE(!strcmp(buffer,
"| 10| |10 | | 10|"));
660 REQUIRE(!strcmp(buffer,
"Hello "));
663 REQUIRE(!strcmp(buffer,
"1024 "));
666 REQUIRE(!strcmp(buffer,
"-1024 "));
669 REQUIRE(!strcmp(buffer,
"1024 "));
672 REQUIRE(!strcmp(buffer,
"-1024 "));
675 REQUIRE(!strcmp(buffer,
"1024 "));
678 REQUIRE(!strcmp(buffer,
"4294966272 "));
681 REQUIRE(!strcmp(buffer,
"777 "));
684 REQUIRE(!strcmp(buffer,
"37777777001 "));
687 REQUIRE(!strcmp(buffer,
"1234abcd "));
690 REQUIRE(!strcmp(buffer,
"edcb5433 "));
693 REQUIRE(!strcmp(buffer,
"1234ABCD "));
696 REQUIRE(!strcmp(buffer,
"EDCB5433 "));
699 REQUIRE(!strcmp(buffer,
"x "));
707 REQUIRE(!strcmp(buffer,
"00000000000000001024"));
710 REQUIRE(!strcmp(buffer,
"-0000000000000001024"));
713 REQUIRE(!strcmp(buffer,
"00000000000000001024"));
716 REQUIRE(!strcmp(buffer,
"-0000000000000001024"));
719 REQUIRE(!strcmp(buffer,
"00000000000000001024"));
722 REQUIRE(!strcmp(buffer,
"00000000004294966272"));
725 REQUIRE(!strcmp(buffer,
"00000000000000000777"));
728 REQUIRE(!strcmp(buffer,
"00000000037777777001"));
731 REQUIRE(!strcmp(buffer,
"0000000000001234abcd"));
734 REQUIRE(!strcmp(buffer,
"000000000000edcb5433"));
737 REQUIRE(!strcmp(buffer,
"0000000000001234ABCD"));
740 REQUIRE(!strcmp(buffer,
"000000000000EDCB5433"));
748 REQUIRE(!strcmp(buffer,
"00000000000000001024"));
751 REQUIRE(!strcmp(buffer,
"-00000000000000001024"));
754 REQUIRE(!strcmp(buffer,
"00000000000000001024"));
757 REQUIRE(!strcmp(buffer,
"-00000000000000001024"));
760 REQUIRE(!strcmp(buffer,
"00000000000000001024"));
763 REQUIRE(!strcmp(buffer,
"00000000004294966272"));
766 REQUIRE(!strcmp(buffer,
"00000000000000000777"));
769 REQUIRE(!strcmp(buffer,
"00000000037777777001"));
772 REQUIRE(!strcmp(buffer,
"0000000000001234abcd"));
775 REQUIRE(!strcmp(buffer,
"000000000000edcb5433"));
778 REQUIRE(!strcmp(buffer,
"0000000000001234ABCD"));
781 REQUIRE(!strcmp(buffer,
"000000000000EDCB5433"));
789 REQUIRE(!strcmp(buffer,
"00000000000000001024"));
792 REQUIRE(!strcmp(buffer,
"-0000000000000001024"));
795 REQUIRE(!strcmp(buffer,
"00000000000000001024"));
798 REQUIRE(!strcmp(buffer,
"-0000000000000001024"));
801 REQUIRE(!strcmp(buffer,
"00000000000000001024"));
804 REQUIRE(!strcmp(buffer,
"00000000004294966272"));
807 REQUIRE(!strcmp(buffer,
"00000000000000000777"));
810 REQUIRE(!strcmp(buffer,
"00000000037777777001"));
813 REQUIRE(!strcmp(buffer,
"0x00000000001234abcd"));
816 REQUIRE(!strcmp(buffer,
"0x0000000000edcb5433"));
819 REQUIRE(!strcmp(buffer,
"0X00000000001234ABCD"));
822 REQUIRE(!strcmp(buffer,
"0X0000000000EDCB5433"));
830 REQUIRE(!strcmp(buffer,
" 1024"));
833 REQUIRE(!strcmp(buffer,
" -1024"));
836 REQUIRE(!strcmp(buffer,
" 1024"));
839 REQUIRE(!strcmp(buffer,
" -1024"));
842 REQUIRE(!strcmp(buffer,
" 1024"));
845 REQUIRE(!strcmp(buffer,
" 4294966272"));
848 REQUIRE(!strcmp(buffer,
" 0777"));
851 REQUIRE(!strcmp(buffer,
" 037777777001"));
854 REQUIRE(!strcmp(buffer,
" 0x1234abcd"));
857 REQUIRE(!strcmp(buffer,
" 0xedcb5433"));
860 REQUIRE(!strcmp(buffer,
" 0X1234ABCD"));
863 REQUIRE(!strcmp(buffer,
" 0XEDCB5433"));
871 REQUIRE(!strcmp(buffer,
" 01024"));
874 REQUIRE(!strcmp(buffer,
" -01024"));
877 REQUIRE(!strcmp(buffer,
" 01024"));
880 REQUIRE(!strcmp(buffer,
" -01024"));
886 REQUIRE(!strcmp(buffer,
" 4294966272"));
889 REQUIRE(!strcmp(buffer,
" 00777"));
892 REQUIRE(!strcmp(buffer,
" 37777777001"));
895 REQUIRE(!strcmp(buffer,
" 1234abcd"));
898 REQUIRE(!strcmp(buffer,
" 00edcb5433"));
901 REQUIRE(!strcmp(buffer,
" 1234ABCD"));
904 REQUIRE(!strcmp(buffer,
" 00EDCB5433"));
913 REQUIRE(!strcmp(buffer,
"-5"));
916 REQUIRE(!strcmp(buffer,
"-5"));
919 REQUIRE(!strcmp(buffer,
" -5"));
922 REQUIRE(!strcmp(buffer,
" -5"));
926 REQUIRE(!strcmp(buffer,
"-5"));
929 REQUIRE(!strcmp(buffer,
"-5"));
932 REQUIRE(!strcmp(buffer,
"-05"));
935 REQUIRE(!strcmp(buffer,
"-005"));
944 REQUIRE(!strcmp(buffer,
"-5.0"));
947 REQUIRE(!strcmp(buffer,
"-5.0"));
950 REQUIRE(!strcmp(buffer,
" -5.0"));
952 #ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL 954 REQUIRE(!strcmp(buffer,
" -5"));
957 REQUIRE(!strcmp(buffer,
"-5.0e+00"));
960 REQUIRE(!strcmp(buffer,
" -5.0e+00"));
965 REQUIRE(!strcmp(buffer,
"-5.0"));
968 REQUIRE(!strcmp(buffer,
"-5.0"));
971 REQUIRE(!strcmp(buffer,
"-05.0"));
975 REQUIRE(!strcmp(buffer,
"-5"));
978 REQUIRE(!strcmp(buffer,
"-5"));
981 REQUIRE(!strcmp(buffer,
"-05"));
983 #ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL 985 REQUIRE(!strcmp(buffer,
"-005.0e+00"));
988 REQUIRE(!strcmp(buffer,
"-05E+00"));
991 REQUIRE(!strcmp(buffer,
"-05"));
1002 REQUIRE(!strcmp(buffer,
" "));
1008 REQUIRE(!strcmp(buffer,
" "));
1011 REQUIRE(!strcmp(buffer,
" 1024"));
1014 REQUIRE(!strcmp(buffer,
" -1024"));
1017 REQUIRE(!strcmp(buffer,
" "));
1020 REQUIRE(!strcmp(buffer,
" 1024"));
1023 REQUIRE(!strcmp(buffer,
" -1024"));
1026 REQUIRE(!strcmp(buffer,
" "));
1029 REQUIRE(!strcmp(buffer,
" 1024"));
1032 REQUIRE(!strcmp(buffer,
" 4294966272"));
1035 REQUIRE(!strcmp(buffer,
" "));
1038 REQUIRE(!strcmp(buffer,
" 777"));
1041 REQUIRE(!strcmp(buffer,
" 37777777001"));
1044 REQUIRE(!strcmp(buffer,
" "));
1047 REQUIRE(!strcmp(buffer,
" 1234abcd"));
1050 REQUIRE(!strcmp(buffer,
" 1234abcd"));
1053 REQUIRE(!strcmp(buffer,
" 1234abcd 12345"));
1056 REQUIRE(!strcmp(buffer,
" edcb5433"));
1059 REQUIRE(!strcmp(buffer,
" "));
1062 REQUIRE(!strcmp(buffer,
" 1234ABCD"));
1065 REQUIRE(!strcmp(buffer,
" EDCB5433"));
1068 REQUIRE(!strcmp(buffer,
" "));
1071 REQUIRE(!strcmp(buffer,
" "));
1074 REQUIRE(!strcmp(buffer,
" "));
1083 REQUIRE(!strcmp(buffer,
" nan"));
1086 REQUIRE(!strcmp(buffer,
" inf"));
1089 REQUIRE(!strcmp(buffer,
"-inf "));
1091 #ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL 1093 REQUIRE(!strcmp(buffer,
" +inf"));
1097 REQUIRE(!strcmp(buffer,
"3.1415"));
1100 REQUIRE(!strcmp(buffer,
"30343.142"));
1103 REQUIRE(!strcmp(buffer,
"34"));
1106 REQUIRE(!strcmp(buffer,
"1"));
1109 REQUIRE(!strcmp(buffer,
"2"));
1112 REQUIRE(!strcmp(buffer,
"1.6"));
1115 REQUIRE(!strcmp(buffer,
"42.90"));
1118 REQUIRE(!strcmp(buffer,
"42.895200000"));
1121 REQUIRE(!strcmp(buffer,
"42.8952230000"));
1126 REQUIRE(!strcmp(buffer,
"42.895223123000"));
1131 REQUIRE(!strcmp(buffer,
"42.895223877000"));
1134 REQUIRE(!strcmp(buffer,
" 42.90"));
1137 REQUIRE(!strcmp(buffer,
"+42.90"));
1140 REQUIRE(!strcmp(buffer,
"+42.9"));
1143 REQUIRE(!strcmp(buffer,
"42.500000"));
1146 REQUIRE(!strcmp(buffer,
"42.5"));
1149 REQUIRE(!strcmp(buffer,
"42167.000000"));
1152 REQUIRE(!strcmp(buffer,
"-12345.987654321"));
1155 REQUIRE(!strcmp(buffer,
"4.0"));
1158 REQUIRE(!strcmp(buffer,
"4"));
1161 REQUIRE(!strcmp(buffer,
"4"));
1164 REQUIRE(!strcmp(buffer,
"3"));
1167 REQUIRE(!strcmp(buffer,
"3.5"));
1170 REQUIRE(!strcmp(buffer,
"a0.5 "));
1173 REQUIRE(!strcmp(buffer,
"a0.5 end"));
1175 #ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL 1177 REQUIRE(!strcmp(buffer,
"12345.7"));
1180 REQUIRE(!strcmp(buffer,
"12345.68"));
1183 REQUIRE(!strcmp(buffer,
"1.2346E+08"));
1186 REQUIRE(!strcmp(buffer,
"12345.0"));
1189 REQUIRE(!strcmp(buffer,
" +1.235e+08"));
1192 REQUIRE(!strcmp(buffer,
"0.0012"));
1195 REQUIRE(!strcmp(buffer,
" +0.001234"));
1198 REQUIRE(!strcmp(buffer,
"+001.234e-05"));
1201 REQUIRE(!strcmp(buffer,
"-1.23e-308"));
1204 REQUIRE(!strcmp(buffer,
"+1.230E+308"));
1209 #ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL 1210 REQUIRE(!strcmp(buffer,
"1.0e+20"));
1217 std::stringstream str;
1219 for (
float i = -100000; i < 100000; i += 1) {
1222 str << std::fixed << i / 10000;
1223 fail = fail || !!strcmp(buffer, str.str().c_str());
1228 #ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL 1230 str.setf(std::ios::scientific, std::ios::floatfield);
1231 for (
float i = -1e20; i < 1e20; i += 1e15) {
1235 fail = fail || !!strcmp(buffer, str.str().c_str());
1246 REQUIRE(!strcmp(buffer,
"0"));
1249 REQUIRE(!strcmp(buffer,
"1234"));
1252 REQUIRE(!strcmp(buffer,
"32767"));
1255 REQUIRE(!strcmp(buffer,
"-32767"));
1258 REQUIRE(!strcmp(buffer,
"30"));
1261 REQUIRE(!strcmp(buffer,
"-2147483647"));
1264 REQUIRE(!strcmp(buffer,
"2147483647"));
1267 REQUIRE(!strcmp(buffer,
"30"));
1270 REQUIRE(!strcmp(buffer,
"-9223372036854775807"));
1273 REQUIRE(!strcmp(buffer,
"9223372036854775807"));
1276 REQUIRE(!strcmp(buffer,
"100000"));
1279 REQUIRE(!strcmp(buffer,
"4294967295"));
1282 REQUIRE(!strcmp(buffer,
"281474976710656"));
1285 REQUIRE(!strcmp(buffer,
"18446744073709551615"));
1288 REQUIRE(!strcmp(buffer,
"2147483647"));
1291 REQUIRE(!strcmp(buffer,
"2147483647"));
1293 if (
sizeof(
size_t) ==
sizeof(
long)) {
1295 REQUIRE(!strcmp(buffer,
"-2147483647"));
1299 REQUIRE(!strcmp(buffer,
"-2147483647"));
1303 REQUIRE(!strcmp(buffer,
"1110101001100000"));
1306 REQUIRE(!strcmp(buffer,
"101111000110000101001110"));
1309 REQUIRE(!strcmp(buffer,
"165140"));
1312 REQUIRE(!strcmp(buffer,
"57060516"));
1315 REQUIRE(!strcmp(buffer,
"12345678"));
1318 REQUIRE(!strcmp(buffer,
"1234567891234567"));
1321 REQUIRE(!strcmp(buffer,
"abcdefab"));
1324 REQUIRE(!strcmp(buffer,
"ABCDEFAB"));
1327 REQUIRE(!strcmp(buffer,
"v"));
1330 REQUIRE(!strcmp(buffer,
"wv"));
1333 REQUIRE(!strcmp(buffer,
"A Test"));
1336 REQUIRE(!strcmp(buffer,
"255"));
1339 REQUIRE(!strcmp(buffer,
"13398"));
1341 test::sprintf(buffer,
"%s%hhi %hu",
"Test", 10000, 0xFFFFFFFF);
1342 REQUIRE(!strcmp(buffer,
"Test16 65535"));
1345 REQUIRE(!strcmp(buffer,
"a"));
1348 if (
sizeof(intmax_t) ==
sizeof(
long)) {
1350 REQUIRE(!strcmp(buffer,
"-2147483647"));
1354 REQUIRE(!strcmp(buffer,
"-2147483647"));
1363 if (
sizeof(
void*) == 4U) {
1364 REQUIRE(!strcmp(buffer,
"00001234"));
1367 REQUIRE(!strcmp(buffer,
"0000000000001234"));
1371 if (
sizeof(
void*) == 4U) {
1372 REQUIRE(!strcmp(buffer,
"12345678"));
1375 REQUIRE(!strcmp(buffer,
"0000000012345678"));
1378 test::sprintf(buffer,
"%p-%p", (
void*)0x12345678U, (
void*)0x7EDCBA98U);
1379 if (
sizeof(
void*) == 4U) {
1380 REQUIRE(!strcmp(buffer,
"12345678-7EDCBA98"));
1383 REQUIRE(!strcmp(buffer,
"0000000012345678-000000007EDCBA98"));
1386 if (
sizeof(uintptr_t) ==
sizeof(uint64_t)) {
1388 REQUIRE(!strcmp(buffer,
"00000000FFFFFFFF"));
1392 REQUIRE(!strcmp(buffer,
"FFFFFFFF"));
1401 REQUIRE(!strcmp(buffer,
"kmarco"));
1409 REQUIRE(!strcmp(buffer,
"This"));
1412 REQUIRE(!strcmp(buffer,
"test"));
1415 REQUIRE(!strcmp(buffer,
"123"));
1421 REQUIRE(!strcmp(buffer,
"1234ab"));
1424 REQUIRE(!strcmp(buffer,
".2s"));
1427 REQUIRE(!strcmp(buffer,
"123"));
1440 buffer[0] = (char)0xA5;
1442 REQUIRE(buffer[0] == (
char)0xA5);
1445 buffer[0] = (char)0xCC;
1450 REQUIRE(!strcmp(buffer,
"H"));
1459 REQUIRE(!strcmp(buffer,
"01234"));
1463 REQUIRE(!strcmp(buffer,
"01234"));
1467 REQUIRE(!strcmp(buffer,
"01234"));
1475 REQUIRE(strlen(buffer) == 2U);
1485 test::sprintf(buffer,
"%u%u%ctest%d %s", 5, 3000,
'a', -20,
"bit");
1486 REQUIRE(!strcmp(buffer,
"53000atest-20 bit"));
1489 REQUIRE(!strcmp(buffer,
"0.33"));
1492 REQUIRE(!strcmp(buffer,
"1"));
1495 REQUIRE(!strcmp(buffer,
"foo"));
1498 REQUIRE(!strcmp(buffer,
" "));
1501 REQUIRE(!strcmp(buffer,
" 00004"));
1504 REQUIRE(!strcmp(buffer,
"hi x"));
1506 #ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL 1508 REQUIRE(!strcmp(buffer,
"0.33"));
1511 REQUIRE(!strcmp(buffer,
"3.33e-01"));
static void vsnprintf_builder_1(char *buffer,...)
static void vprintf_builder_1(char *buffer,...)
static char printf_buffer[100]
TEST_CASE("printf", "[]")
static void vsnprintf_builder_3(char *buffer,...)
static void _out_fct(char character, void *buffer, size_t idx, size_t maxlen)
int fctprintf(void(*out)(char character, void *arg), void *arg, const char *format,...)
void _putchar(char character)