comparison tests.c @ 532:ad64c3f7cf64

Adjust printf int formatting test values and format specifiers.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 28 Dec 2019 13:29:59 +0200
parents 94d4130cc29c
children ef0d732fabe0
comparison
equal deleted inserted replaced
531:f43c961cc85d 532:ad64c3f7cf64
578 578
579 579
580 // 580 //
581 // Test series for printf() 581 // Test series for printf()
582 // 582 //
583 char *i_fmts[] = { "", "05", "6", ".4", "8.5", "08.5", "3", "2.2", "3", "1", "18", "018", ".0", "0" }; 583 char *i_fmts[] = { "", "05", "6", ".4", "8.5", "08.5", "3", "2.1", "3", "1", "18", "018", ".0", "0" };
584 char *i_mods[] = { "", "-", "+", "#", }; 584 char *i_mods[] = { "", "-", "+", "#", };
585 char *i_types[] = { "d", "u", "i", "x", "X", "o", }; 585 char *i_types[] = { "d", "u", "i", "x", "X", "o", };
586 if (test_set_start("printf() integer")) 586 if (test_set_start("printf() integer"))
587 { 587 {
588 int i_vals[] = { 588 int i_vals[] = {
589 0, -0, -1, 2, -2, 512, -1024, 612342, 589 0, -0, 1, -1, 10, -10, 512, -512, -1024,
590 -612342, 0x1fff, 0x8000000, -123456789, 590 612342, -612342, 0x1fff, 0x8000000, -123456789,
591 4294967295, -2147483648 }; 591 4294967295, -2147483648 };
592 592
593 for (i1 = 0; i1 < NCOUNT(i_vals); i1++) 593 for (i1 = 0; i1 < NCOUNT(i_vals); i1++)
594 { 594 {
595 snprintf(buf, sizeof(buf), "%d", i_vals[i1]); 595 snprintf(buf, sizeof(buf), "%d", i_vals[i1]);
604 } 604 }
605 } 605 }
606 606
607 if (test_set_start("printf() integer 64bit")) 607 if (test_set_start("printf() integer 64bit"))
608 { 608 {
609 int64_t i_vals64[] = { 0, -0, -1, 2, -2, 612342, -612342, 0x3342344341fff, 0x1f8000000, }; 609 int64_t i_vals64[] = {
610 0, -0, 1, -1, 10, -10,
611 0x3342344341fff, 0x1f8000000, };
610 612
611 for (i1 = 0; i1 < NCOUNT(i_vals64); i1++) 613 for (i1 = 0; i1 < NCOUNT(i_vals64); i1++)
612 { 614 {
613 snprintf(buf, sizeof(buf), "%" PRId64, i_vals64[i1]); 615 snprintf(buf, sizeof(buf), "%" PRId64, i_vals64[i1]);
614 616