diff --git a/utest/ctest.h b/utest/ctest.h index d316b1494..037f7f28d 100644 --- a/utest/ctest.h +++ b/utest/ctest.h @@ -28,7 +28,10 @@ #define WEAK #endif +#ifndef __MSC_VER #include /* intmax_t, uintmax_t, PRI* */ +#endif + #include /* size_t */ typedef void (*SetupFunc)(void*); @@ -72,6 +75,13 @@ struct ctest { #define __CTEST_NO_TIME #define CTEST_NO_COLORS +#if __MSC_VER >= 1500 +#include +#else +#include +#define CTEST_NO_INTTYPES +#endif + #ifndef CTEST_ADD_TESTS_MANUALLY #pragma section(".ctest$a") #pragma section(".ctest$u") @@ -480,11 +490,19 @@ void assert_data(const unsigned char* exp, size_t expsize, const char* caller, int line) { size_t i; if (expsize != realsize) { +#ifndef CTEST_NO_INTTYPES CTEST_ERR("%s:%d expected %" PRIuMAX " bytes, got %" PRIuMAX, caller, line, (uintmax_t) expsize, (uintmax_t) realsize); +#else + CTEST_ERR("%s:%d expected %u bytes, got %u", caller, line, (uintmax_t) expsize, (uintmax_t) realsize); +#endif } for (i=0; i exp2) { +#ifndef CTEST_NO_INTTYPES CTEST_ERR("%s:%d expected %" PRIdMAX "-%" PRIdMAX ", got %" PRIdMAX, caller, line, exp1, exp2, real); +#else + CTEST_ERR("%s:%d expected %d-%d, got %d", caller, line, exp1, exp2, real); +#endif } }