aboutsummaryrefslogtreecommitdiffstats
path: root/TestHelper.h
diff options
context:
space:
mode:
Diffstat (limited to 'TestHelper.h')
-rw-r--r--TestHelper.h44
1 files changed, 41 insertions, 3 deletions
diff --git a/TestHelper.h b/TestHelper.h
index c4dde1a6..91ec977d 100644
--- a/TestHelper.h
+++ b/TestHelper.h
@@ -22,7 +22,9 @@
#pragma once
#include <functional>
+
#include <boost/test/unit_test.hpp>
+
#include "JsonSpiritHeaders.h"
#include <libethereum/State.h>
#include <libevm/ExtVMFace.h>
@@ -42,17 +44,53 @@ void connectClients(Client& c1, Client& c2);
namespace 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()
+/// @param _expression The expression for which to make sure no exceptions are thrown
+/// @param _message A message to act as a prefix to the expression's error information
+#define ETH_TEST_REQUIRE_NO_THROW(_expression, _message) \
+ do \
+ { \
+ try \
+ { \
+ _expression; \
+ } \
+ catch (boost::exception const& _e) \
+ { \
+ auto msg = std::string(_message"\n") + boost::diagnostic_information(_e); \
+ BOOST_FAIL(msg); \
+ } \
+ } while (0)
+
+/// 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()
+/// @param _expression The expression for which to make sure no exceptions are thrown
+/// @param _message A message to act as a prefix to the expression's error information
+#define ETH_TEST_CHECK_NO_THROW(_expression, _message) \
+ do \
+ { \
+ try \
+ { \
+ _expression; \
+ } \
+ catch (boost::exception const& _e) \
+ { \
+ auto msg = std::string(_message"\n") + boost::diagnostic_information(_e); \
+ BOOST_MESSAGE(msg); \
+ } \
+ } while (0)
+
+
class ImportTest
{
public:
- ImportTest(json_spirit::mObject& _o) : m_TestObject(_o) {}
+ ImportTest(json_spirit::mObject& _o) : m_statePre(Address(), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) {}
ImportTest(json_spirit::mObject& _o, bool isFiller);
-
// imports
void importEnv(json_spirit::mObject& _o);
void importState(json_spirit::mObject& _o, eth::State& _state);
void importTransaction(json_spirit::mObject& _o);
- void exportTest(bytes _output, eth::State& _statePost);
+ void exportTest(bytes const& _output, eth::State const& _statePost);
eth::State m_statePre;
eth::State m_statePost;