aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/tests.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-12-21 10:37:54 -0500
committerJack Lloyd <[email protected]>2015-12-21 10:37:54 -0500
commit3467948a1fd8c0e12650197e9e29636e57b0fcdb (patch)
tree0fb1b295864d137ef78c1921b60a7d689d14ee5a /src/tests/tests.cpp
parent66fb50a462d72c106bd4a4102a1faff92bd5f7e2 (diff)
Add missing try/catch in signature verification test.
Improve diagnostics when an exception escapes a test GH #369
Diffstat (limited to 'src/tests/tests.cpp')
-rw-r--r--src/tests/tests.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index b0292926e..4d035c0c8 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -667,7 +667,7 @@ std::vector<Test::Result> Text_Based_Test::run()
{
std::vector<Test::Result> results;
- std::string who;
+ std::string header, header_or_name = m_data_src;
VarMap vars;
size_t test_cnt = 0;
@@ -679,7 +679,8 @@ std::vector<Test::Result> Text_Based_Test::run()
if(line[0] == '[' && line[line.size()-1] == ']')
{
- who = line.substr(1, line.size() - 2);
+ header = line.substr(1, line.size() - 2);
+ header_or_name = header;
test_cnt = 0;
continue;
}
@@ -690,7 +691,8 @@ std::vector<Test::Result> Text_Based_Test::run()
if(equal_i == std::string::npos)
{
- results.push_back(Test::Result::Failure(who, "invalid input '" + line + "'"));
+ results.push_back(Test::Result::Failure(header_or_name,
+ "invalid input '" + line + "'"));
continue;
}
@@ -698,7 +700,8 @@ std::vector<Test::Result> Text_Based_Test::run()
std::string val = strip_ws(std::string(line.begin() + equal_i + 1, line.end()));
if(m_required_keys.count(key) == 0 && m_optional_keys.count(key) == 0)
- results.push_back(Test::Result::Failure(who, test_id + " failed unknown key " + key));
+ results.push_back(Test::Result::Failure(header_or_name,
+ test_id + " failed unknown key " + key));
vars[key] = val;
@@ -709,7 +712,7 @@ std::vector<Test::Result> Text_Based_Test::run()
++test_cnt;
uint64_t start = Test::timestamp();
- Test::Result result = run_one_test(who, vars);
+ Test::Result result = run_one_test(header, vars);
result.set_ns_consumed(Test::timestamp() - start);
if(result.tests_failed())
@@ -718,7 +721,8 @@ std::vector<Test::Result> Text_Based_Test::run()
}
catch(std::exception& e)
{
- results.push_back(Test::Result::Failure(who, "test " + std::to_string(test_cnt) +
+ results.push_back(Test::Result::Failure(header_or_name,
+ "test " + std::to_string(test_cnt) +
" failed with exception '" + e.what() + "'"));
}