Skip to content

Commit

Permalink
Remove duplicated non-standard test, and increase disabled warnings f…
Browse files Browse the repository at this point in the history
…or same test

One invalid test was duplicated, so I removed the implementatino outside of the TEST_WITH_NON_STANDARD_FORMAT_STRINGS block.

Within that block, I disabled two other warnings (one which needed a new pragma definition), because Clang shows one and GCC shows the other in my setup.
  • Loading branch information
phillipjohnston authored and eyalroz committed Jan 25, 2022
1 parent 8367345 commit f4bef6c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/test_suite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ do { \
#define DISABLE_WARNING_PRINTF_FORMAT
#define DISABLE_WARNING_PRINTF_FORMAT_EXTRA_ARGS
#define DISABLE_WARNING_PRINTF_FORMAT_OVERFLOW
#define DISABLE_WARNING_PRINTF_FORMAT_INVALID_SPECIFIER

#elif defined(__GNUC__) || defined(__clang__)
#define DO_PRAGMA(X) _Pragma(#X)
Expand All @@ -94,20 +95,24 @@ do { \
#define DISABLE_WARNING_PRINTF_FORMAT_EXTRA_ARGS DISABLE_WARNING(-Wformat-extra-args)
#if defined(__clang__)
#define DISABLE_WARNING_PRINTF_FORMAT_OVERFLOW
#define DISABLE_WARNING_PRINTF_FORMAT_INVALID_SPECIFIER DISABLE_WARNING(-Wformat-invalid-specifier)
#else
#define DISABLE_WARNING_PRINTF_FORMAT_OVERFLOW DISABLE_WARNING(-Wformat-overflow)
#define DISABLE_WARNING_PRINTF_FORMAT_INVALID_SPECIFIER
#endif
#else
#define DISABLE_WARNING_PUSH
#define DISABLE_WARNING_POP
#define DISABLE_WARNING_PRINTF_FORMAT
#define DISABLE_WARNING_PRINTF_FORMAT_EXTRA_ARGS
#define DISABLE_WARNING_PRINTF_FORMAT_INVALID_SPECIFIER
#endif

#ifdef TEST_WITH_NON_STANDARD_FORMAT_STRINGS
DISABLE_WARNING_PUSH
DISABLE_WARNING_PRINTF_FORMAT
DISABLE_WARNING_PRINTF_FORMAT_EXTRA_ARGS
DISABLE_WARNING_PRINTF_FORMAT_INVALID_SPECIFIER
#endif

#if defined(_MSC_VER)
Expand Down Expand Up @@ -1073,7 +1078,6 @@ TEST_CASE("string length", "[]" ) {
PRINTING_CHECK("123", ==, sprintf_, buffer, "%.7s", "123");
PRINTING_CHECK("", ==, sprintf_, buffer, "%.7s", "");
PRINTING_CHECK("1234ab", ==, sprintf_, buffer, "%.4s%.2s", "123456", "abcdef");
PRINTING_CHECK(".2s", ==, sprintf_, buffer, "%.4.2s", "123456");
PRINTING_CHECK("123", ==, sprintf_, buffer, "%.*s", 3, "123456");

DISABLE_WARNING_PUSH
Expand All @@ -1087,6 +1091,8 @@ TEST_CASE("string length (non-standard format)", "[]" ) {
char buffer[100];
DISABLE_WARNING_PUSH
DISABLE_WARNING_PRINTF_FORMAT
DISABLE_WARNING_PRINTF_FORMAT_EXTRA_ARGS
DISABLE_WARNING_PRINTF_FORMAT_INVALID_SPECIFIER
PRINTING_CHECK(".2s", ==, sprintf_, buffer, "%.4.2s", "123456");
DISABLE_WARNING_POP
}
Expand Down

0 comments on commit f4bef6c

Please sign in to comment.