diff options
| author | Phil Nash | 2011-04-20 15:40:40 +0100 |
|---|---|---|
| committer | Phil Nash | 2011-04-20 15:40:40 +0100 |
| commit | 9430a2c4c803fcb078204f87533c92dc947f4560 (patch) | |
| tree | 7e3916c5991e2e4e4621a45ebf0d2cb5bafbe464 /Test/ExceptionTests.cpp | |
| parent | d4117b920833fa0aec2fd14a48baa6e1c08a2746 (diff) | |
| download | catch3-9430a2c4c803fcb078204f87533c92dc947f4560.tar.gz | |
First cut of custom exception support
Diffstat (limited to 'Test/ExceptionTests.cpp')
| -rw-r--r-- | Test/ExceptionTests.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Test/ExceptionTests.cpp b/Test/ExceptionTests.cpp index e0332be8..caad6fd8 100644 --- a/Test/ExceptionTests.cpp +++ b/Test/ExceptionTests.cpp @@ -62,3 +62,36 @@ TEST_CASE( "./succeeding/exceptions/implicit", "When unchecked exceptions are th { } } + +class CustomException +{ +public: + CustomException( const std::string& msg ) + : m_msg( msg ) + {} + + std::string getMessage() const + { + return m_msg; + } + +private: + std::string m_msg; +}; + + +namespace Catch +{ + ExceptionTranslator<CustomException> translator; + + template<> + std::string ExceptionTranslator<CustomException>::translate( CustomException& ex ) const + { + return ex.getMessage(); + } +} + +TEST_CASE_NORETURN( "./succeeding/exceptions/custom", "" ) +{ + throw CustomException( "custom exception" ); +} |