Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/Test/ExceptionTests.cpp
diff options
context:
space:
mode:
authorPhil Nash2011-04-20 15:40:40 +0100
committerPhil Nash2011-04-20 15:40:40 +0100
commit9430a2c4c803fcb078204f87533c92dc947f4560 (patch)
tree7e3916c5991e2e4e4621a45ebf0d2cb5bafbe464 /Test/ExceptionTests.cpp
parentd4117b920833fa0aec2fd14a48baa6e1c08a2746 (diff)
downloadcatch3-9430a2c4c803fcb078204f87533c92dc947f4560.tar.gz
First cut of custom exception support
Diffstat (limited to 'Test/ExceptionTests.cpp')
-rw-r--r--Test/ExceptionTests.cpp33
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" );
+}