Last active
August 29, 2015 14:03
-
-
Save lshort/d3b7322868a5f1ed8cb0 to your computer and use it in GitHub Desktop.
ExpectExceptionBasic
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
template<typename ExecLambda> | |
void expect_exception( ExecLambda exec_lambda, bool expect_to_throw) | |
{ | |
bool threw; | |
decltype( exec_lambda() ) x; | |
try { | |
x = exec_lambda(); | |
threw = false; | |
} | |
catch (...) { | |
threw = true; | |
} | |
if ( expect_to_throw != threw ) | |
throw ""; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment