Mercurial > hg > th-libs
comparison tests.c @ 724:388d72f4189d
Add some tests for PRI* printf specifiers to test 64bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 18 Oct 2021 01:56:09 +0300 |
parents | 3ea040bb0dca |
children | 31bc1ed07cf5 |
comparison
equal
deleted
inserted
replaced
723:10f2eba7c59b | 724:388d72f4189d |
---|---|
821 test_snprintf(buf, buf2, i_vals[i1]); | 821 test_snprintf(buf, buf2, i_vals[i1]); |
822 } | 822 } |
823 } | 823 } |
824 } | 824 } |
825 | 825 |
826 if (test_set_start("printf() integer 64bit")) | 826 if (test_set_start("printf() integer 64bit generic")) |
827 { | 827 { |
828 int64_t i_vals64[] = { | 828 int64_t i_vals64[] = { |
829 0, -0, 1, -1, 10, -10, 512, -512, -1024, | 829 0, -0, 1, -1, 10, -10, 512, -512, -1024, |
830 612342, -612342, 0x1fff, 0x8000000, -123456789, | 830 612342, -612342, 0x1fff, 0x8000000, -123456789, |
831 4294967295, -2147483648, | 831 4294967295, -2147483648, |
838 for (i4 = 0; i4 < NCOUNT(i_mods); i4++) | 838 for (i4 = 0; i4 < NCOUNT(i_mods); i4++) |
839 for (i3 = 0; i3 < NCOUNT(i_types); i3++) | 839 for (i3 = 0; i3 < NCOUNT(i_types); i3++) |
840 for (i2 = 0; i2 < NCOUNT(i_fmts); i2++) | 840 for (i2 = 0; i2 < NCOUNT(i_fmts); i2++) |
841 { | 841 { |
842 snprintf(buf2, sizeof(buf2), "%%%s%sll%s", i_mods[i4], i_fmts[i2], i_types[i3]); | 842 snprintf(buf2, sizeof(buf2), "%%%s%sll%s", i_mods[i4], i_fmts[i2], i_types[i3]); |
843 test_snprintf(buf, buf2, i_vals64[i1]); | |
844 } | |
845 } | |
846 } | |
847 | |
848 if (test_set_start("printf() integer 64bit PRI* specifiers")) | |
849 { | |
850 int64_t i_vals64[] = { | |
851 0, -0, 1, -1, 10, -10, 512, -512, -1024, | |
852 612342, -612342, 0x1fff, 0x8000000, -123456789, | |
853 4294967295, -2147483648, | |
854 0x3342344341fff, 0x1f8000000, }; | |
855 | |
856 for (i1 = 0; i1 < NCOUNT(i_vals64); i1++) | |
857 { | |
858 snprintf(buf, sizeof(buf), "%" PRId64, i_vals64[i1]); | |
859 | |
860 for (i4 = 0; i3 < NCOUNT(i_mods); i3++) | |
861 for (i2 = 0; i2 < NCOUNT(i_fmts); i2++) | |
862 { | |
863 snprintf(buf2, sizeof(buf2), "%%%s%s" PRId64, i_mods[i3], i_fmts[i2]); | |
864 test_snprintf(buf, buf2, i_vals64[i1]); | |
865 | |
866 snprintf(buf2, sizeof(buf2), "%%%s%s" PRIx64, i_mods[i3], i_fmts[i2]); | |
867 test_snprintf(buf, buf2, i_vals64[i1]); | |
868 | |
869 snprintf(buf2, sizeof(buf2), "%%%s%s" PRIX64, i_mods[i3], i_fmts[i2]); | |
843 test_snprintf(buf, buf2, i_vals64[i1]); | 870 test_snprintf(buf, buf2, i_vals64[i1]); |
844 } | 871 } |
845 } | 872 } |
846 } | 873 } |
847 | 874 |