From a176b9373813b4763a7815791097e45f6aa623c8 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Sat, 12 Apr 2014 19:07:24 +0100 Subject: [PATCH] Fix for #270 (REQUIRE continues if test throws an exception). Added test case that reproduced the bug then applied the fix. --- README.md | 2 +- include/internal/catch_capture.hpp | 2 +- include/internal/catch_version.hpp | 2 +- .../Baselines/console.std.approved.txt | 13 ++++++++++++- .../SelfTest/Baselines/console.sw.approved.txt | 13 ++++++++++++- .../SelfTest/Baselines/junit.sw.approved.txt | 8 +++++++- .../SelfTest/Baselines/xml.sw.approved.txt | 18 ++++++++++++++++-- projects/SelfTest/ExceptionTests.cpp | 6 ++++++ single_include/catch.hpp | 8 ++++---- 9 files changed, 60 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1f7c9e68..f2807e59 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](catch-logo-small.png) -*v1.0 build 33 (master branch)* +*v1.0 build 34 (master branch)* Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 5055cddf..41b7670d 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 | Catch::ResultDisposition::ContinueOnFailure, expr ); \ + resultDisposition, expr ); \ } \ } while( Catch::isTrue( false ) ) diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index ef1d2371..72b166dc 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -13,7 +13,7 @@ namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 33, "master" ); + Version libraryVersion( 1, 0, 34, "master" ); } #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index e1df1550..20634449 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -331,6 +331,17 @@ ExceptionTests.cpp:: FAILED: due to unexpected exception with message: expected exception +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a require the test should fail +------------------------------------------------------------------------------- +ExceptionTests.cpp: +............................................................................... + +ExceptionTests.cpp:: FAILED: + REQUIRE( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + ------------------------------------------------------------------------------- Unexpected custom exceptions can be translated ------------------------------------------------------------------------------- @@ -750,5 +761,5 @@ with expansion: "first" == "second" =============================================================================== -122 test cases - 36 failed (658 assertions - 91 failed) +123 test cases - 37 failed (659 assertions - 92 failed) diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index a3e3fef5..0999e0f8 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -1110,6 +1110,17 @@ ExceptionTests.cpp:: FAILED: due to unexpected exception with message: expected exception +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a require the test should fail +------------------------------------------------------------------------------- +ExceptionTests.cpp: +............................................................................... + +ExceptionTests.cpp:: FAILED: + REQUIRE( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + ------------------------------------------------------------------------------- When unchecked exceptions are thrown, but caught, they do not affect the test ------------------------------------------------------------------------------- @@ -6958,5 +6969,5 @@ with expansion: true =============================================================================== -122 test cases - 51 failed (677 assertions - 110 failed) +123 test cases - 52 failed (678 assertions - 111 failed) diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 406bda64..7e171097 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,5 +1,5 @@ - + @@ -207,6 +207,12 @@ 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 8215ee7c..c1cabda3 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -1426,6 +1426,20 @@ + + + + thisThrows() == 0 + + + thisThrows() == 0 + + + expected exception + + + + @@ -7214,7 +7228,7 @@ there" - + - + diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index 2dac0c15..a193b226 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -66,6 +66,12 @@ 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]" ) +{ + REQUIRE( thisThrows() == 0 ); + FAIL( "This should never happen" ); +} + TEST_CASE( "When unchecked exceptions are thrown, but caught, they do not affect the test", "" ) { try diff --git a/single_include/catch.hpp b/single_include/catch.hpp index 052a761f..d6cec7a9 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * CATCH v1.0 build 33 (master branch) - * Generated: 2014-03-24 18:11:50.426554 + * CATCH v1.0 build 34 (master branch) + * Generated: 2014-04-12 19:07:02.688717 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -1599,7 +1599,7 @@ struct TestFailureException{}; throw; \ } catch( ... ) { \ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), \ - resultDisposition | Catch::ResultDisposition::ContinueOnFailure, expr ); \ + resultDisposition, expr ); \ } \ } while( Catch::isTrue( false ) ) @@ -6598,7 +6598,7 @@ namespace Catch { namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 33, "master" ); + Version libraryVersion( 1, 0, 34, "master" ); } // #included from: catch_message.hpp