diff options
| author | Phil Nash | 2015-11-18 08:39:21 +0000 |
|---|---|---|
| committer | Phil Nash | 2015-11-18 08:39:21 +0000 |
| commit | a49f088032be4d9d2e1c87f888254974c79fc5b8 (patch) | |
| tree | 3253b3da15badc7694c694567c546476a7bbebf4 /projects/SelfTest/ExceptionTests.cpp | |
| parent | ed6e9128a4f1d8c5e24be01d8ad9341f83a39562 (diff) | |
| download | catch3-a49f088032be4d9d2e1c87f888254974c79fc5b8.tar.gz | |
exception translators considered even for types deriving from std::exception, now
- also added docs for exception translators
- updated approvals
Diffstat (limited to 'projects/SelfTest/ExceptionTests.cpp')
| -rw-r--r-- | projects/SelfTest/ExceptionTests.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index eb8b7d8f..949962ec 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -106,22 +106,50 @@ private: std::string m_msg; }; +class CustomStdException : public std::exception +{ +public: + CustomStdException( const std::string& msg ) + : m_msg( msg ) + {} + + std::string getMessage() const + { + return m_msg; + } + +private: + std::string m_msg; +}; + + CATCH_TRANSLATE_EXCEPTION( CustomException& ex ) { return ex.getMessage(); } +CATCH_TRANSLATE_EXCEPTION( CustomStdException& ex ) +{ + return ex.getMessage(); +} + CATCH_TRANSLATE_EXCEPTION( double& ex ) { return Catch::toString( ex ); } -TEST_CASE("Unexpected custom exceptions can be translated", "[.][failing]" ) +TEST_CASE("Non-std exceptions can be translated", "[.][failing]" ) { if( Catch::alwaysTrue() ) throw CustomException( "custom exception" ); } +TEST_CASE("Custom std-exceptions can be custom translated", "[.][failing]" ) +{ + if( Catch::alwaysTrue() ) + throw CustomException( "custom std exception" ); +} + inline void throwCustom() { if( Catch::alwaysTrue() ) throw CustomException( "custom exception - not std" ); |