Add std::exception as a base clase off std::runtime_error and provide unit test for it.
This commit is contained in:

committed by
lefticus@gmail.com

parent
0b97fcb4df
commit
d9a92a5148
21
unittests/eval_catch_exception_test.cpp
Normal file
21
unittests/eval_catch_exception_test.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
// Tests to make sure that the order in which function dispatches occur is correct
|
||||
|
||||
#include <chaiscript/chaiscript.hpp>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
chaiscript::ChaiScript chai;
|
||||
|
||||
try {
|
||||
chai.eval("throw(runtime_error(\"error\"));");
|
||||
} catch (const chaiscript::Boxed_Value &bv) {
|
||||
const std::exception &e = chaiscript::boxed_cast<const std::exception &>(bv);
|
||||
if (e.what() == std::string("error"))
|
||||
{
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
Reference in New Issue
Block a user