catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Fix for #270 (REQUIRE continues if test throws an exception).
- Commit
a176b9373813b4763a7815791097e45f6aa623c8- Author
- Phil Nash ·
- Parents
e9d35377fa4f
Changes
README.md | 2 +- include/internal/catch_capture.hpp | 2 +- include/internal/catch_version.hpp | 2 +- projects/SelfTest/Baselines/console.std.approved.txt | 13 ++++++++++++- projects/SelfTest/Baselines/console.sw.approved.txt | 13 ++++++++++++- projects/SelfTest/Baselines/junit.sw.approved.txt | 8 +++++++- projects/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 @@  -*v1.0 build 33 (master branch)* +*v1.0 build 34 (master branch)* Build status (on Travis CI) [](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:<line number>: FAILED: due to unexpected exception with message: expected exception +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a require the test should fail +------------------------------------------------------------------------------- +ExceptionTests.cpp:<line number> +............................................................................... + +ExceptionTests.cpp:<line number>: 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:<line number>: FAILED: due to unexpected exception with message: expected exception +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a require the test should fail +------------------------------------------------------------------------------- +ExceptionTests.cpp:<line number> +............................................................................... + +ExceptionTests.cpp:<line number>: 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 @@ <testsuites> - <testsuite name="~_" errors="10" failures="100" tests="677" hostname="tbd" time="{duration}" timestamp="tbd"> + <testsuite name="~_" errors="11" failures="100" tests="678" hostname="tbd" time="{duration}" timestamp="tbd"> <testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/> <testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/> <testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/> @@ -207,6 +207,12 @@ ExceptionTests.cpp:<line number> <testcase classname="global" name="When unchecked exceptions are thrown from functions they are always failures" time="{duration}"> <error message="thisThrows() == 0" type="CHECK"> expected exception +ExceptionTests.cpp:<line number> + </error> + </testcase> + <testcase classname="global" name="When unchecked exceptions are thrown during a require the test should fail" time="{duration}"> + <error message="thisThrows() == 0" type="REQUIRE"> +expected exception ExceptionTests.cpp:<line number> </error> </testcase> 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 @@ </Expression> <OverallResult success="false"/> </TestCase> + <TestCase name="When unchecked exceptions are thrown during a require the test should fail"> + <Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ExceptionTests.cpp" > + <Original> + thisThrows() == 0 + </Original> + <Expanded> + thisThrows() == 0 + </Expanded> + <Exception filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ExceptionTests.cpp" > + expected exception + </Exception> + </Expression> + <OverallResult success="false"/> + </TestCase> <TestCase name="When unchecked exceptions are thrown, but caught, they do not affect the test"> <OverallResult success="true"/> </TestCase> @@ -7214,7 +7228,7 @@ there" </Section> <OverallResult success="true"/> </TestCase> - <OverallResults successes="567" failures="110"/> + <OverallResults successes="567" failures="111"/> </Group> - <OverallResults successes="567" failures="110"/> + <OverallResults successes="567" failures="111"/> </Catch> 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