REQUIRE_THROWS_AS is now reported with expected type as well

Also updated tests to reflect this change.
This commit is contained in:
Martin Hořeňovský 2017-02-09 12:41:16 +01:00
parent e543cc0646
commit 9952dda524
5 changed files with 19 additions and 19 deletions

View File

@ -87,7 +87,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \ #define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
if( __catchResult.allowThrows() ) \ if( __catchResult.allowThrows() ) \
try { \ try { \
static_cast<void>(expr); \ static_cast<void>(expr); \

View File

@ -131,7 +131,7 @@ ExceptionTests.cpp:<line number>
............................................................................... ...............................................................................
ExceptionTests.cpp:<line number>: FAILED: ExceptionTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_AS( throwCustom() ) REQUIRE_THROWS_AS( throwCustom(), std::exception )
due to unexpected exception with message: due to unexpected exception with message:
custom exception - not std custom exception - not std
@ -245,12 +245,12 @@ ExceptionTests.cpp:<line number>
............................................................................... ...............................................................................
ExceptionTests.cpp:<line number>: FAILED: ExceptionTests.cpp:<line number>: FAILED:
CHECK_THROWS_AS( thisThrows() ) CHECK_THROWS_AS( thisThrows(), std::string )
due to unexpected exception with message: due to unexpected exception with message:
expected exception expected exception
ExceptionTests.cpp:<line number>: FAILED: ExceptionTests.cpp:<line number>: FAILED:
CHECK_THROWS_AS( thisDoesntThrow() ) CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error )
because no exception was thrown where one was expected: because no exception was thrown where one was expected:
ExceptionTests.cpp:<line number>: FAILED: ExceptionTests.cpp:<line number>: FAILED:

View File

@ -852,7 +852,7 @@ ExceptionTests.cpp:<line number>
............................................................................... ...............................................................................
ExceptionTests.cpp:<line number>: FAILED: ExceptionTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_AS( throwCustom() ) REQUIRE_THROWS_AS( throwCustom(), std::exception )
due to unexpected exception with message: due to unexpected exception with message:
custom exception - not std custom exception - not std
@ -1096,12 +1096,12 @@ ExceptionTests.cpp:<line number>
............................................................................... ...............................................................................
ExceptionTests.cpp:<line number>: FAILED: ExceptionTests.cpp:<line number>: FAILED:
CHECK_THROWS_AS( thisThrows() ) CHECK_THROWS_AS( thisThrows(), std::string )
due to unexpected exception with message: due to unexpected exception with message:
expected exception expected exception
ExceptionTests.cpp:<line number>: FAILED: ExceptionTests.cpp:<line number>: FAILED:
CHECK_THROWS_AS( thisDoesntThrow() ) CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error )
because no exception was thrown where one was expected: because no exception was thrown where one was expected:
ExceptionTests.cpp:<line number>: FAILED: ExceptionTests.cpp:<line number>: FAILED:
@ -7878,7 +7878,7 @@ ExceptionTests.cpp:<line number>
ExceptionTests.cpp:<line number>: ExceptionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THROWS_AS( thisThrows() ) REQUIRE_THROWS_AS( thisThrows(), std::domain_error )
ExceptionTests.cpp:<line number>: ExceptionTests.cpp:<line number>:
PASSED: PASSED:

View File

@ -101,7 +101,7 @@ ExceptionTests.cpp:<line number>
</error> </error>
</testcase> </testcase>
<testcase classname="global" name="Custom exceptions can be translated when testing for throwing as something else" time="{duration}"> <testcase classname="global" name="Custom exceptions can be translated when testing for throwing as something else" time="{duration}">
<error message="throwCustom()" type="REQUIRE_THROWS_AS"> <error message="throwCustom(), std::exception" type="REQUIRE_THROWS_AS">
custom exception - not std custom exception - not std
ExceptionTests.cpp:<line number> ExceptionTests.cpp:<line number>
</error> </error>
@ -171,11 +171,11 @@ MiscTests.cpp:<line number>
<testcase classname="Exception messages can be tested for" name="different case" time="{duration}"/> <testcase classname="Exception messages can be tested for" name="different case" time="{duration}"/>
<testcase classname="Exception messages can be tested for" name="wildcarded" time="{duration}"/> <testcase classname="Exception messages can be tested for" name="wildcarded" time="{duration}"/>
<testcase classname="global" name="Expected exceptions that don't throw or unexpected exceptions fail the test" time="{duration}"> <testcase classname="global" name="Expected exceptions that don't throw or unexpected exceptions fail the test" time="{duration}">
<error message="thisThrows()" type="CHECK_THROWS_AS"> <error message="thisThrows(), std::string" type="CHECK_THROWS_AS">
expected exception expected exception
ExceptionTests.cpp:<line number> ExceptionTests.cpp:<line number>
</error> </error>
<failure message="thisDoesntThrow()" type="CHECK_THROWS_AS"> <failure message="thisDoesntThrow(), std::domain_error" type="CHECK_THROWS_AS">
ExceptionTests.cpp:<line number> ExceptionTests.cpp:<line number>
</failure> </failure>
<error message="thisThrows()" type="CHECK_NOTHROW"> <error message="thisThrows()" type="CHECK_NOTHROW">

View File

@ -920,10 +920,10 @@
<TestCase name="Custom exceptions can be translated when testing for throwing as something else" tags="[!throws][.][failing][hide]"> <TestCase name="Custom exceptions can be translated when testing for throwing as something else" tags="[!throws][.][failing][hide]">
<Expression success="false" type="REQUIRE_THROWS_AS" filename="projects/<exe-name>/ExceptionTests.cpp" > <Expression success="false" type="REQUIRE_THROWS_AS" filename="projects/<exe-name>/ExceptionTests.cpp" >
<Original> <Original>
throwCustom() throwCustom(), std::exception
</Original> </Original>
<Expanded> <Expanded>
throwCustom() throwCustom(), std::exception
</Expanded> </Expanded>
<Exception filename="projects/<exe-name>/ExceptionTests.cpp" > <Exception filename="projects/<exe-name>/ExceptionTests.cpp" >
custom exception - not std custom exception - not std
@ -1221,10 +1221,10 @@
<TestCase name="Expected exceptions that don't throw or unexpected exceptions fail the test" tags="[!throws][.][failing][hide]"> <TestCase name="Expected exceptions that don't throw or unexpected exceptions fail the test" tags="[!throws][.][failing][hide]">
<Expression success="false" type="CHECK_THROWS_AS" filename="projects/<exe-name>/ExceptionTests.cpp" > <Expression success="false" type="CHECK_THROWS_AS" filename="projects/<exe-name>/ExceptionTests.cpp" >
<Original> <Original>
thisThrows() thisThrows(), std::string
</Original> </Original>
<Expanded> <Expanded>
thisThrows() thisThrows(), std::string
</Expanded> </Expanded>
<Exception filename="projects/<exe-name>/ExceptionTests.cpp" > <Exception filename="projects/<exe-name>/ExceptionTests.cpp" >
expected exception expected exception
@ -1232,10 +1232,10 @@
</Expression> </Expression>
<Expression success="false" type="CHECK_THROWS_AS" filename="projects/<exe-name>/ExceptionTests.cpp" > <Expression success="false" type="CHECK_THROWS_AS" filename="projects/<exe-name>/ExceptionTests.cpp" >
<Original> <Original>
thisDoesntThrow() thisDoesntThrow(), std::domain_error
</Original> </Original>
<Expanded> <Expanded>
thisDoesntThrow() thisDoesntThrow(), std::domain_error
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="false" type="CHECK_NOTHROW" filename="projects/<exe-name>/ExceptionTests.cpp" > <Expression success="false" type="CHECK_NOTHROW" filename="projects/<exe-name>/ExceptionTests.cpp" >
@ -8400,10 +8400,10 @@ there"
<TestCase name="When checked exceptions are thrown they can be expected or unexpected" tags="[!throws]"> <TestCase name="When checked exceptions are thrown they can be expected or unexpected" tags="[!throws]">
<Expression success="true" type="REQUIRE_THROWS_AS" filename="projects/<exe-name>/ExceptionTests.cpp" > <Expression success="true" type="REQUIRE_THROWS_AS" filename="projects/<exe-name>/ExceptionTests.cpp" >
<Original> <Original>
thisThrows() thisThrows(), std::domain_error
</Original> </Original>
<Expanded> <Expanded>
thisThrows() thisThrows(), std::domain_error
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_NOTHROW" filename="projects/<exe-name>/ExceptionTests.cpp" > <Expression success="true" type="REQUIRE_NOTHROW" filename="projects/<exe-name>/ExceptionTests.cpp" >