diff --git a/appveyor.yml b/appveyor.yml index 859bd06..7440cb4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,7 @@ version: '{build}' skip_tags: true +skip_branch_with_pr: true install: [] @@ -13,9 +14,8 @@ - VSVERSION: Visual Studio 14 2015 - VSVERSION: Visual Studio 15 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - # VS 2019 is tested in GitHub Actions instead. - # - VSVERSION: Visual Studio 16 2019 - # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + - VSVERSION: Visual Studio 16 2019 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 platform: - Win32 @@ -25,11 +25,15 @@ exclude: - platform: x64 VSVERSION: Visual Studio 9 2008 + # VS 2019 / 64-bit is tested in GitHub Actions instead. + - platform: x64 + VSVERSION: Visual Studio 16 2019 configuration: - Debug - - RelWithDebInfo - - MinSizeRel + # Removed to reduce configuration explosion. + # - RelWithDebInfo + # - MinSizeRel - Release build_script: diff --git a/appveyor.yml b/appveyor.yml index 859bd06..7440cb4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,7 @@ version: '{build}' skip_tags: true +skip_branch_with_pr: true install: [] @@ -13,9 +14,8 @@ - VSVERSION: Visual Studio 14 2015 - VSVERSION: Visual Studio 15 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - # VS 2019 is tested in GitHub Actions instead. - # - VSVERSION: Visual Studio 16 2019 - # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + - VSVERSION: Visual Studio 16 2019 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 platform: - Win32 @@ -25,11 +25,15 @@ exclude: - platform: x64 VSVERSION: Visual Studio 9 2008 + # VS 2019 / 64-bit is tested in GitHub Actions instead. + - platform: x64 + VSVERSION: Visual Studio 16 2019 configuration: - Debug - - RelWithDebInfo - - MinSizeRel + # Removed to reduce configuration explosion. + # - RelWithDebInfo + # - MinSizeRel - Release build_script: diff --git a/test/type_printers.inc b/test/type_printers.inc index c521657..5aa591e 100644 --- a/test/type_printers.inc +++ b/test/type_printers.inc @@ -12,8 +12,6 @@ #error #endif -#define TO_S_X(val) #val -#define S(val) TO_S_X(val) FILE *old = utest_state.output; FILE *out = tmpfile(); ASSERT_TRUE(!!out); @@ -45,7 +43,7 @@ fflush(out); rewind(out); char buf[1024] = {'\0'}; - size_t n = fread(buf, 1, sizeof buf, out); + const size_t n = fread(buf, 1, sizeof buf, out); fclose(out); utest_state.output = old; ASSERT_EQ(n, expected_len); diff --git a/appveyor.yml b/appveyor.yml index 859bd06..7440cb4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,7 @@ version: '{build}' skip_tags: true +skip_branch_with_pr: true install: [] @@ -13,9 +14,8 @@ - VSVERSION: Visual Studio 14 2015 - VSVERSION: Visual Studio 15 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - # VS 2019 is tested in GitHub Actions instead. - # - VSVERSION: Visual Studio 16 2019 - # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + - VSVERSION: Visual Studio 16 2019 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 platform: - Win32 @@ -25,11 +25,15 @@ exclude: - platform: x64 VSVERSION: Visual Studio 9 2008 + # VS 2019 / 64-bit is tested in GitHub Actions instead. + - platform: x64 + VSVERSION: Visual Studio 16 2019 configuration: - Debug - - RelWithDebInfo - - MinSizeRel + # Removed to reduce configuration explosion. + # - RelWithDebInfo + # - MinSizeRel - Release build_script: diff --git a/test/type_printers.inc b/test/type_printers.inc index c521657..5aa591e 100644 --- a/test/type_printers.inc +++ b/test/type_printers.inc @@ -12,8 +12,6 @@ #error #endif -#define TO_S_X(val) #val -#define S(val) TO_S_X(val) FILE *old = utest_state.output; FILE *out = tmpfile(); ASSERT_TRUE(!!out); @@ -45,7 +43,7 @@ fflush(out); rewind(out); char buf[1024] = {'\0'}; - size_t n = fread(buf, 1, sizeof buf, out); + const size_t n = fread(buf, 1, sizeof buf, out); fclose(out); utest_state.output = old; ASSERT_EQ(n, expected_len); diff --git a/utest.h b/utest.h index 045dd4b..26bf890 100644 --- a/utest.h +++ b/utest.h @@ -381,6 +381,15 @@ #define utest_type_printer(...) UTEST_PRINTF("undef") #endif +#ifdef _MSC_VER +#define UTEST_SURPRESS_WARNING_BEGIN \ + __pragma(warning(push)) __pragma(warning(disable : 4127)) +#define UTEST_SURPRESS_WARNING_END __pragma(warning(pop)) +#else +#define UTEST_SURPRESS_WARNING_BEGIN +#define UTEST_SURPRESS_WARNING_END +#endif + #if defined(__cplusplus) && (__cplusplus >= 201103L) #define UTEST_AUTO(x) auto #elif !defined(__cplusplus) @@ -412,7 +421,7 @@ #if defined(__clang__) #define UTEST_EXPECT(x, y, cond) \ - { \ + UTEST_SURPRESS_WARNING_BEGIN do { \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wlanguage-extension-token\"") \ _Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"") \ @@ -430,10 +439,12 @@ UTEST_PRINTF("\n"); \ *utest_result = 1; \ } \ - } + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #elif defined(__GNUC__) #define UTEST_EXPECT(x, y, cond) \ - { \ + UTEST_SURPRESS_WARNING_BEGIN do { \ UTEST_AUTO(x) xEval = (x); \ UTEST_AUTO(y) yEval = (y); \ if (!((xEval)cond(yEval))) { \ @@ -446,32 +457,44 @@ UTEST_PRINTF("\n"); \ *utest_result = 1; \ } \ - } + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #else #define UTEST_EXPECT(x, y, cond) \ - { \ + UTEST_SURPRESS_WARNING_BEGIN do { \ if (!((x)cond(y))) { \ UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ *utest_result = 1; \ } \ - } + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #endif #define EXPECT_TRUE(x) \ - if (!(x)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : true\n"); \ - UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ - *utest_result = 1; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (!(x)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : true\n"); \ + UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ + *utest_result = 1; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define EXPECT_FALSE(x) \ - if (x) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : false\n"); \ - UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ - *utest_result = 1; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (x) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : false\n"); \ + UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ + *utest_result = 1; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define EXPECT_EQ(x, y) UTEST_EXPECT(x, y, ==) #define EXPECT_NE(x, y) UTEST_EXPECT(x, y, !=) @@ -481,40 +504,56 @@ #define EXPECT_GE(x, y) UTEST_EXPECT(x, y, >=) #define EXPECT_STREQ(x, y) \ - if (0 != strcmp(x, y)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%s\"\n", x); \ - UTEST_PRINTF(" Actual : \"%s\"\n", y); \ - *utest_result = 1; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (0 != strcmp(x, y)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%s\"\n", x); \ + UTEST_PRINTF(" Actual : \"%s\"\n", y); \ + *utest_result = 1; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define EXPECT_STRNE(x, y) \ - if (0 == strcmp(x, y)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%s\"\n", x); \ - UTEST_PRINTF(" Actual : \"%s\"\n", y); \ - *utest_result = 1; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (0 == strcmp(x, y)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%s\"\n", x); \ + UTEST_PRINTF(" Actual : \"%s\"\n", y); \ + *utest_result = 1; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define EXPECT_STRNEQ(x, y, n) \ - if (0 != UTEST_STRNCMP(x, y, n)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, n), x); \ - UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, n), y); \ - *utest_result = 1; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (0 != UTEST_STRNCMP(x, y, n)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, n), x); \ + UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, n), y); \ + *utest_result = 1; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define EXPECT_STRNNE(x, y, n) \ - if (0 == UTEST_STRNCMP(x, y, n)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, n), x); \ - UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, n), y); \ - *utest_result = 1; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (0 == UTEST_STRNCMP(x, y, n)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, n), x); \ + UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, n), y); \ + *utest_result = 1; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #if defined(__clang__) #define UTEST_ASSERT(x, y, cond) \ - { \ + UTEST_SURPRESS_WARNING_BEGIN do { \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wlanguage-extension-token\"") \ _Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"") \ @@ -533,10 +572,12 @@ *utest_result = 1; \ return; \ } \ - } + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #elif defined(__GNUC__) #define UTEST_ASSERT(x, y, cond) \ - { \ + UTEST_SURPRESS_WARNING_BEGIN do { \ UTEST_AUTO(x) xEval = (x); \ UTEST_AUTO(y) yEval = (y); \ if (!((xEval)cond(yEval))) { \ @@ -550,35 +591,47 @@ *utest_result = 1; \ return; \ } \ - } + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #else #define UTEST_ASSERT(x, y, cond) \ - { \ + UTEST_SURPRESS_WARNING_BEGIN do { \ if (!((x)cond(y))) { \ UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ *utest_result = 1; \ return; \ } \ - } + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #endif #define ASSERT_TRUE(x) \ - if (!(x)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : true\n"); \ - UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ - *utest_result = 1; \ - return; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (!(x)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : true\n"); \ + UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ + *utest_result = 1; \ + return; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define ASSERT_FALSE(x) \ - if (x) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : false\n"); \ - UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ - *utest_result = 1; \ - return; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (x) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : false\n"); \ + UTEST_PRINTF(" Actual : %s\n", (x) ? "true" : "false"); \ + *utest_result = 1; \ + return; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define ASSERT_EQ(x, y) UTEST_ASSERT(x, y, ==) #define ASSERT_NE(x, y) UTEST_ASSERT(x, y, !=) @@ -588,40 +641,56 @@ #define ASSERT_GE(x, y) UTEST_ASSERT(x, y, >=) #define ASSERT_STREQ(x, y) \ - if (0 != strcmp(x, y)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%s\"\n", x); \ - UTEST_PRINTF(" Actual : \"%s\"\n", y); \ - *utest_result = 1; \ - return; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (0 != strcmp(x, y)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%s\"\n", x); \ + UTEST_PRINTF(" Actual : \"%s\"\n", y); \ + *utest_result = 1; \ + return; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define ASSERT_STRNE(x, y) \ - if (0 == strcmp(x, y)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%s\"\n", x); \ - UTEST_PRINTF(" Actual : \"%s\"\n", y); \ - *utest_result = 1; \ - return; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (0 == strcmp(x, y)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%s\"\n", x); \ + UTEST_PRINTF(" Actual : \"%s\"\n", y); \ + *utest_result = 1; \ + return; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define ASSERT_STRNEQ(x, y, n) \ - if (0 != UTEST_STRNCMP(x, y, n)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, n), x); \ - UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, n), y); \ - *utest_result = 1; \ - return; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (0 != UTEST_STRNCMP(x, y, n)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, n), x); \ + UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, n), y); \ + *utest_result = 1; \ + return; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define ASSERT_STRNNE(x, y, n) \ - if (0 == UTEST_STRNCMP(x, y, n)) { \ - UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ - UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, n), x); \ - UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, n), y); \ - *utest_result = 1; \ - return; \ - } + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (0 == UTEST_STRNCMP(x, y, n)) { \ + UTEST_PRINTF("%s:%u: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, n), x); \ + UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, n), y); \ + *utest_result = 1; \ + return; \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END #define UTEST(SET, NAME) \ UTEST_EXTERN struct utest_state_s utest_state; \