Skip to content

Instantly share code, notes, and snippets.

@lshort
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lshort/d3b7322868a5f1ed8cb0 to your computer and use it in GitHub Desktop.
Save lshort/d3b7322868a5f1ed8cb0 to your computer and use it in GitHub Desktop.
ExpectExceptionBasic
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