From 1bccc03213b374e30b7bcfddcddffa8d7de1b680 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Sat, 12 Apr 2014 19:20:46 +0100 Subject: [PATCH] Secondary fix for #270 (addresses same issue with CHECK) --- include/internal/catch_capture.hpp | 2 +- .../Baselines/console.std.approved.txt | 17 ++++++++++++++-- .../Baselines/console.sw.approved.txt | 17 ++++++++++++++-- .../SelfTest/Baselines/junit.sw.approved.txt | 10 ++++++++-- .../SelfTest/Baselines/xml.sw.approved.txt | 20 ++++++++++++++++--- projects/SelfTest/ExceptionTests.cpp | 8 +++++++- 6 files changed, 63 insertions(+), 11 deletions(-) diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 41b7670d..451bc41c 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -87,7 +87,7 @@ struct TestFailureException{}; throw; \ } catch( ... ) { \ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), \ - resultDisposition, expr ); \ + Catch::ResultDisposition::Normal, expr ); \ } \ } while( Catch::isTrue( false ) ) diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 20634449..5f23df59 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -332,7 +332,8 @@ due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- -When unchecked exceptions are thrown during a require the test should fail +When unchecked exceptions are thrown during a REQUIRE the test should abort +fail ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -342,6 +343,18 @@ ExceptionTests.cpp:: FAILED: due to unexpected exception with message: expected exception +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a CHECK the test should abort and +fail +------------------------------------------------------------------------------- +ExceptionTests.cpp: +............................................................................... + +ExceptionTests.cpp:: FAILED: + CHECK( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + ------------------------------------------------------------------------------- Unexpected custom exceptions can be translated ------------------------------------------------------------------------------- @@ -761,5 +774,5 @@ with expansion: "first" == "second" =============================================================================== -123 test cases - 37 failed (659 assertions - 92 failed) +124 test cases - 38 failed (660 assertions - 93 failed) diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 0999e0f8..12f74797 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -1111,7 +1111,8 @@ due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- -When unchecked exceptions are thrown during a require the test should fail +When unchecked exceptions are thrown during a REQUIRE the test should abort +fail ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1121,6 +1122,18 @@ ExceptionTests.cpp:: FAILED: due to unexpected exception with message: expected exception +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a CHECK the test should abort and +fail +------------------------------------------------------------------------------- +ExceptionTests.cpp: +............................................................................... + +ExceptionTests.cpp:: FAILED: + CHECK( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + ------------------------------------------------------------------------------- When unchecked exceptions are thrown, but caught, they do not affect the test ------------------------------------------------------------------------------- @@ -6969,5 +6982,5 @@ with expansion: true =============================================================================== -123 test cases - 52 failed (678 assertions - 111 failed) +124 test cases - 53 failed (679 assertions - 112 failed) diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 7e171097..90b2c6c3 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,5 +1,5 @@ - + @@ -210,9 +210,15 @@ expected exception ExceptionTests.cpp: - + expected exception +ExceptionTests.cpp: + + + + +expected exception ExceptionTests.cpp: diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index c1cabda3..ada68ac3 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -1426,7 +1426,21 @@ - + + + + thisThrows() == 0 + + + thisThrows() == 0 + + + expected exception + + + + + thisThrows() == 0 @@ -7228,7 +7242,7 @@ there" - + - + diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index a193b226..9a325c55 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -66,12 +66,18 @@ TEST_CASE( "When unchecked exceptions are thrown from functions they are always CHECK( thisThrows() == 0 ); } -TEST_CASE( "When unchecked exceptions are thrown during a require the test should fail", "[.][failing]" ) +TEST_CASE( "When unchecked exceptions are thrown during a REQUIRE the test should abort fail", "[.][failing]" ) { REQUIRE( thisThrows() == 0 ); FAIL( "This should never happen" ); } +TEST_CASE( "When unchecked exceptions are thrown during a CHECK the test should abort and fail", "[.][failing]" ) +{ + CHECK( thisThrows() == 0 ); + FAIL( "This should never happen" ); +} + TEST_CASE( "When unchecked exceptions are thrown, but caught, they do not affect the test", "" ) { try