Add stringification support to std::exception and deriving classes

This support is based on overriden `std::exception::what` method, so
if an exception does not do so meaningfully, the message is still
pointless.

This is only used as a fallback, both `StringMaker` specialization and
`operator<<` overload have priority..
This commit is contained in:
Martin Hořeňovský
2018-05-12 17:46:25 +02:00
parent c323658483
commit 6c5c4c43a0
7 changed files with 147 additions and 26 deletions

View File

@@ -335,12 +335,12 @@ Matchers.tests.cpp:<line number>
Matchers.tests.cpp:<line number>: FAILED:
CHECK_THROWS_MATCHES( throws(3), SpecialException, ExceptionMatcher{1} )
with expansion:
{?} special exception has value of 1
std::exception special exception has value of 1
Matchers.tests.cpp:<line number>: FAILED:
REQUIRE_THROWS_MATCHES( throws(4), SpecialException, ExceptionMatcher{1} )
with expansion:
{?} special exception has value of 1
std::exception special exception has value of 1
-------------------------------------------------------------------------------
Expected exceptions that don't throw or unexpected exceptions fail the test
@@ -1084,6 +1084,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
test cases: 206 | 153 passed | 49 failed | 4 failed as expected
assertions: 1061 | 933 passed | 107 failed | 21 failed as expected
test cases: 207 | 154 passed | 49 failed | 4 failed as expected
assertions: 1064 | 936 passed | 107 failed | 21 failed as expected