From b1e26e28e3996abb2c45edf481681a491a357f32 Mon Sep 17 00:00:00 2001 From: Christoph Jentzsch Date: Wed, 19 Nov 2014 14:30:42 +0100 Subject: Add Log tests --- TestHelper.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index 1b13f9e8..a0e2d572 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -287,6 +287,18 @@ void checkStorage(map _expectedStore, map _resultStore, } } +void checkLog(LogEntries _resultLogs, LogEntries _expectedLogs) +{ + BOOST_REQUIRE_EQUAL(_resultLogs.size(), _expectedLogs.size()); + + for (size_t i = 0; i < _resultLogs.size(); ++i) + { + BOOST_CHECK(_resultLogs[i].address == _expectedLogs[i].address); + BOOST_CHECK(_resultLogs[i].topics == _expectedLogs[i].topics); + BOOST_CHECK(_resultLogs[i].data == _expectedLogs[i].data); + } +} + std::string getTestPath() { string testPath; -- cgit v1.2.3 From 16be7563e1a5e0b2b16859b46058a88adc76c203 Mon Sep 17 00:00:00 2001 From: Christoph Jentzsch Date: Thu, 20 Nov 2014 20:41:35 +0100 Subject: Specify user defined test --- TestHelper.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index 114399a4..4ce17589 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -310,12 +310,13 @@ void userDefinedTest(string testTypeFlag, std::function= boost::unit_test::framework::master_test_suite().argc) + if (i + 2 >= boost::unit_test::framework::master_test_suite().argc) { - cnote << "Missing filename\nUsage: testeth " << testTypeFlag << " \n"; + cnote << "Missing filename\nUsage: testeth " << testTypeFlag << " \n"; return; } string filename = boost::unit_test::framework::master_test_suite().argv[i + 1]; + string testname = boost::unit_test::framework::master_test_suite().argv[i + 2]; int currentVerbosity = g_logVerbosity; g_logVerbosity = 12; try @@ -325,7 +326,19 @@ void userDefinedTest(string testTypeFlag, std::function 0, "Contents of " + filename + " is empty. "); json_spirit::read_string(s, v); - doTests(v, false); + json_spirit::mObject oSingleTest; + + json_spirit::mObject::const_iterator pos = v.get_obj().find(testname); + if (pos == v.get_obj().end()) + { + cnote << "Could not find test: " << testname << " in " << filename << "\n"; + return; + } + else + oSingleTest[pos->first] = pos->second; + + json_spirit::mValue v_singleTest(oSingleTest); + doTests(v_singleTest, false); } catch (Exception const& _e) { -- cgit v1.2.3 From e450bde11357bf4d138b8008c5c201d9ee91ce3e Mon Sep 17 00:00:00 2001 From: Christoph Jentzsch Date: Thu, 20 Nov 2014 22:21:08 +0100 Subject: style --- TestHelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index 4ce17589..d724eb39 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -310,7 +310,7 @@ void userDefinedTest(string testTypeFlag, std::function= boost::unit_test::framework::master_test_suite().argc) + if (boost::unit_test::framework::master_test_suite().argc <= i + 2) { cnote << "Missing filename\nUsage: testeth " << testTypeFlag << " \n"; return; -- cgit v1.2.3 From 70a1f73047d884f83cf2b706179f0bbc801e34f6 Mon Sep 17 00:00:00 2001 From: Christoph Jentzsch Date: Fri, 21 Nov 2014 07:42:41 +0100 Subject: style --- TestHelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index 66370ca3..c4128932 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -293,8 +293,8 @@ void checkLog(LogEntries _resultLogs, LogEntries _expectedLogs) for (size_t i = 0; i < _resultLogs.size(); ++i) { - BOOST_CHECK(_resultLogs[i].address == _expectedLogs[i].address); - BOOST_CHECK(_resultLogs[i].topics == _expectedLogs[i].topics); + BOOST_CHECK_EQUAL(_resultLogs[i].address, _expectedLogs[i].address); + BOOST_CHECK_EQUAL(_resultLogs[i].topics, _expectedLogs[i].topics); BOOST_CHECK(_resultLogs[i].data == _expectedLogs[i].data); } } -- cgit v1.2.3