Skip to content

Instantly share code, notes, and snippets.

@webmaster128
Created December 8, 2015 10:08
Show Gist options
  • Save webmaster128/61b16767742fb1f2bfa3 to your computer and use it in GitHub Desktop.
Save webmaster128/61b16767742fb1f2bfa3 to your computer and use it in GitHub Desktop.
/*
* 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