Added portable size_t printf format code

This commit is contained in:
Snaipe 2015-03-16 15:12:18 +01:00
parent 476b4cb1fe
commit edd62ccd71
2 changed files with 10 additions and 4 deletions

View file

@ -57,6 +57,12 @@
# define UNUSED __attribute__((unused))
# ifdef _WIN32
# define SIZE_T_FORMAT "%Iu"
# else
# define SIZE_T_FORMAT "%zu"
# endif
# ifdef __GNUC__
# define FORMAT(Archetype, Index, Ftc) __attribute__((format(Archetype, Index, Ftc)))
# else

View file

@ -57,7 +57,7 @@ ReportHook(PRE_INIT)(struct criterion_test *test) {
ReportHook(POST_TEST)(struct criterion_test_stats *stats) {
if (criterion_options.enable_tap_format) {
criterion_important("%s %lu - %s::%s\n",
criterion_important("%s " SIZE_T_FORMAT " - %s::%s\n",
stats->failed ? "not ok" : "ok",
tap_test_index++,
stats->test->category,
@ -93,13 +93,13 @@ ReportHook(PRE_ALL)(struct criterion_test_set *set) {
for (struct criterion_test **test = set->tests; i < set->nb_tests; ++i)
if (!(test[i])->data->disabled)
++enabled_count;
criterion_important("1..%lu\n", enabled_count);
criterion_important("1.." SIZE_T_FORMAT "\n", enabled_count);
}
}
ReportHook(POST_ALL)(struct criterion_global_stats *stats) {
if (criterion_options.enable_tap_format) return;
criterion_important("Synthesis: %lu tests were run. %lu passed, %lu failed (with %lu crashes)\n",
criterion_important("Synthesis: " SIZE_T_FORMAT " tests were run. " SIZE_T_FORMAT " passed, " SIZE_T_FORMAT " failed (with " SIZE_T_FORMAT " crashes)\n",
stats->nb_tests,
stats->tests_passed,
stats->tests_failed,
@ -119,7 +119,7 @@ ReportHook(ASSERT)(struct criterion_assert_stats *stats) {
ReportHook(TEST_CRASH)(struct criterion_test_stats *stats) {
if (criterion_options.enable_tap_format) {
criterion_important("not ok %lu - %s::%s unexpected signal after %s:%u\n",
criterion_important("not ok " SIZE_T_FORMAT " - %s::%s unexpected signal after %s:%u\n",
tap_test_index++,
stats->test->category,
stats->test->name,