Created
December 8, 2015 10:08
-
-
Save webmaster128/61b16767742fb1f2bfa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Example for https://github.com/philsquared/Catch/issues/539 | |
* compiled using | |
* g++ -std=c++11 -I./single_include extest.cpp && ./a.out | |
* in the Catch repo checkout | |
*/ | |
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file | |
#include "catch.hpp" | |
class MyException1 : public std::exception | |
{ | |
public: | |
const char* what() const noexcept override | |
{ | |
return ""; | |
} | |
}; | |
class MyException2 : public std::exception | |
{ | |
public: | |
const char* what() const noexcept override | |
{ | |
return "Some whatever message"; | |
} | |
}; | |
TEST_CASE( "std::exception", "[factorial]" ) { | |
throw std::exception(); | |
} | |
TEST_CASE( "Exception with empty what()", "[factorial]" ) { | |
throw MyException1(); | |
} | |
TEST_CASE( "Exception with custom what()", "[factorial]" ) { | |
throw MyException2(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment