From 5824b56a5e68f4a5b2cf63bf650e6294267c5f1d Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 5 Jun 2012 10:38:18 +0100 Subject: [PATCH] Cleaned up some GCC/LLVM warnings --- projects/SelfTest/ConditionTests.cpp | 17 ++++++++++++----- projects/SelfTest/ExceptionTests.cpp | 5 +++++ projects/SelfTest/TestMain.cpp | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/projects/SelfTest/ConditionTests.cpp b/projects/SelfTest/ConditionTests.cpp index cb56bfa8..4d2fb945 100644 --- a/projects/SelfTest/ConditionTests.cpp +++ b/projects/SelfTest/ConditionTests.cpp @@ -189,7 +189,14 @@ TEST_CASE( "./succeeding/conditions/int literals", REQUIRE( (std::numeric_limits::max)() > ul ); } -TEST_CASE( "./succeeding/conditions//long_to_unsigned_x", +// Disable warnings about sign conversions for the next two tests +// (as we are deliberately invoking them) +// - Current only disabled for GCC/ LLVM. Should add VC++ too +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wsign-conversion" + +TEST_CASE( "./succeeding/conditions//long_to_unsigned_x", "comparisons between int variables" ) { long long_var = 1L; @@ -204,9 +211,7 @@ TEST_CASE( "./succeeding/conditions//long_to_unsigned_x", REQUIRE( long_var == unsigned_long_var ); } -// These are not built normally to avoid warnings about signed/ unsigned -#ifdef ALLOW_TESTS_THAT_WARN -TEST_CASE( "succeeding/conditions/negative ints", +TEST_CASE( "./succeeding/conditions/negative ints", "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" ) { CHECK( ( -1 > 2u ) ); @@ -219,7 +224,9 @@ TEST_CASE( "succeeding/conditions/negative ints", CHECK( ( minInt > 2u ) ); CHECK( minInt > 2u ); } -#endif + +#pragma GCC diagnostic pop + inline const char* returnsConstNull(){ return NULL; } inline char* returnsNull(){ return NULL; } diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index 376ce809..72e21b51 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -112,6 +112,9 @@ TEST_CASE_NORETURN( "./failing/exceptions/custom/double", "Unexpected custom exc throw double( 3.14 ); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" + TEST_CASE( "./failing/exceptions/in-section", "Exceptions thrown from sections report file/ line or section" ) { SECTION( "the section", "" ) @@ -123,6 +126,8 @@ TEST_CASE( "./failing/exceptions/in-section", "Exceptions thrown from sections r } } +#pragma GCC diagnostic pop + TEST_CASE( "./succeeding/exceptions/error messages", "The error messages produced by exceptions caught by Catch matched the expected form" ) { Catch::EmbeddedRunner runner; diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index bc782549..093005be 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -33,7 +33,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results" SECTION( "selftest/test counts/succeeding tests", "Number of 'succeeding' tests is fixed" ) { runner.runMatching( "./succeeding/*" ); - CHECK( runner.getTotals().assertions.passed == 277 ); + CHECK( runner.getTotals().assertions.passed == 283 ); CHECK( runner.getTotals().assertions.failed == 0 ); }