21 #include <boost/test/unit_test.hpp> 31 using namespace boost;
33 Timer TestOutputHelper::m_timer;
34 size_t TestOutputHelper::m_currTest = 0;
35 size_t TestOutputHelper::m_maxTests = 0;
36 string TestOutputHelper::m_currentTestName =
"n/a";
37 string TestOutputHelper::m_currentTestCaseName =
"n/a";
38 string TestOutputHelper::m_currentTestFileName =
"n/a";
39 std::vector<TestOutputHelper::execTimeName> TestOutputHelper::m_execTimeResults;
40 void TestOutputHelper::initTest(
int _maxTests)
43 BasicAuthority::init();
46 m_currentTestCaseName = boost::unit_test::framework::current_test_case().p_name;
47 std::cout <<
"Test Case \"" + m_currentTestCaseName +
"\": " << std::endl;
48 m_maxTests = _maxTests;
55 BasicAuthority::init();
58 m_currentTestCaseName = boost::unit_test::framework::current_test_case().p_name;
59 std::cout <<
"Test Case \"" + m_currentTestCaseName +
"\": " << std::endl;
60 m_maxTests = _v.
get_obj().size();
67 int m_testsPerProgs =
std::max(1, (
int)(m_maxTests / 4));
68 if (m_currTest % m_testsPerProgs == 0 || m_currTest == m_maxTests)
70 int percent = int(m_currTest*100/m_maxTests);
71 std::cout << percent <<
"%";
74 std::cout << std::endl;
77 if (test::Options::get().singleTest && test::Options::get().singleTestName != _testName)
86 m_currentTestName = _testName;
90 void TestOutputHelper::finishTest()
92 if (Options::get().exectimelog)
95 res.first = m_timer.elapsed();
96 res.second = caseName();
97 std::cout << res.second +
" time: " +
toString(res.first) << std::endl;
98 m_execTimeResults.push_back(res);
102 void TestOutputHelper::printTestExecStats()
104 if (Options::get().exectimelog)
106 std::cout << std::left;
107 std::sort(m_execTimeResults.begin(), m_execTimeResults.end(), [](
execTimeName _a,
execTimeName _b) {
return (_b.first < _a.first); });
108 for (
size_t i = 0; i < m_execTimeResults.size(); i++)
109 std::cout << setw(45) << m_execTimeResults[i].second << setw(25) <<
" time: " +
toString(m_execTimeResults[i].first) << std::endl;
const Object & get_obj() const
std::pair< double, std::string > execTimeName
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Fixture class for boost output when running testeth.
std::hash for asio::adress
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
Class for handling testeth custom options.
mConfig::Object_type mObject
dev::WithExisting max(dev::WithExisting _a, dev::WithExisting _b)