mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Improving ETH_TEST() exceptions
- Properly printing fail check/require message same way as BOOST implementation does - Also add a Test Pass Checkpoint call to be sure the last checkpoint is reported properly - Catch any sort of exception in the no throw
This commit is contained in:
parent
52e9a85d62
commit
3efbe46a49
40
TestHelper.h
40
TestHelper.h
@ -46,39 +46,55 @@ namespace test
|
|||||||
|
|
||||||
/// Make sure that no Exception is thrown during testing. If one is thrown show its info and fail the test.
|
/// Make sure that no Exception is thrown during testing. If one is thrown show its info and fail the test.
|
||||||
/// Our version of BOOST_REQUIRE_NO_THROW()
|
/// Our version of BOOST_REQUIRE_NO_THROW()
|
||||||
/// @param _expression The expression for which to make sure no exceptions are thrown
|
/// @param _statenent The statement for which to make sure no exceptions are thrown
|
||||||
/// @param _message A message to act as a prefix to the expression's error information
|
/// @param _message A message to act as a prefix to the expression's error information
|
||||||
#define ETH_TEST_REQUIRE_NO_THROW(_expression, _message) \
|
#define ETH_TEST_REQUIRE_NO_THROW(_statement, _message) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
try \
|
try \
|
||||||
{ \
|
{ \
|
||||||
_expression; \
|
BOOST_TEST_PASSPOINT(); \
|
||||||
|
_statement; \
|
||||||
} \
|
} \
|
||||||
catch (boost::exception const& _e) \
|
catch (boost::exception const& _e) \
|
||||||
{ \
|
{ \
|
||||||
auto msg = std::string(_message"\n") + boost::diagnostic_information(_e); \
|
auto msg = std::string(_message" due to an exception thrown by " \
|
||||||
BOOST_FAIL(msg); \
|
BOOST_STRINGIZE(_statement)"\n") + boost::diagnostic_information(_e); \
|
||||||
|
BOOST_CHECK_IMPL(false, msg, REQUIRE, CHECK_MSG); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
catch (...) \
|
||||||
|
{ \
|
||||||
|
BOOST_CHECK_IMPL( false, "Unknown exception thrown by " \
|
||||||
|
BOOST_STRINGIZE(_statement), REQUIRE, CHECK_MSG); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
/// Check if an Exception is thrown during testing. If one is thrown show its info and continue the test
|
/// Check if an Exception is thrown during testing. If one is thrown show its info and continue the test
|
||||||
/// Our version of BOOST_CHECK_NO_THROW()
|
/// Our version of BOOST_CHECK_NO_THROW()
|
||||||
/// @param _expression The expression for which to make sure no exceptions are thrown
|
/// @param _statement The statement for which to make sure no exceptions are thrown
|
||||||
/// @param _message A message to act as a prefix to the expression's error information
|
/// @param _message A message to act as a prefix to the expression's error information
|
||||||
#define ETH_TEST_CHECK_NO_THROW(_expression, _message) \
|
#define ETH_TEST_CHECK_NO_THROW(_statement, _message) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
try \
|
try \
|
||||||
{ \
|
{ \
|
||||||
_expression; \
|
BOOST_TEST_PASSPOINT(); \
|
||||||
|
_statement; \
|
||||||
} \
|
} \
|
||||||
catch (boost::exception const& _e) \
|
catch (boost::exception const& _e) \
|
||||||
{ \
|
{ \
|
||||||
auto msg = std::string(_message"\n") + boost::diagnostic_information(_e); \
|
auto msg = std::string(_message" due to an exception thrown by " \
|
||||||
BOOST_MESSAGE(msg); \
|
BOOST_STRINGIZE(_statement)"\n") + boost::diagnostic_information(_e); \
|
||||||
|
BOOST_CHECK_IMPL(false, msg, CHECK, CHECK_MSG); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
catch (...) \
|
||||||
|
{ \
|
||||||
|
BOOST_CHECK_IMPL( false, "Unknown exception thrown by " \
|
||||||
|
BOOST_STRINGIZE(_statement), CHECK, CHECK_MSG ); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
|
|
||||||
class ImportTest
|
class ImportTest
|
||||||
|
Loading…
Reference in New Issue
Block a user