7#include <xrpl/beast/unit_test/amount.h>
8#include <xrpl/beast/unit_test/recorder.h>
10#include <boost/lexical_cast.hpp>
11#include <boost/optional.hpp>
29template <
class =
void>
95 fmtdur(
typename clock_type::duration
const& d);
145 [](
run_time const& t1,
typename clock_type::duration
const& t2) {
146 return t1.second > t2;
148 if (iter !=
top.end())
151 top.resize(
top.size() - 1);
152 top.emplace(iter, r.
name, elapsed);
156 top.emplace_back(r.
name, elapsed);
171 if (results_.top.size() > 0)
173 os_ <<
"Longest suite times:\n";
174 for (
auto const& i : results_.top)
175 os_ <<
std::setw(8) << fmtdur(i.second) <<
" " << i.first <<
'\n';
177 auto const elapsed = clock_type::now() - results_.start;
178 os_ << fmtdur(elapsed) <<
", " <<
amount{results_.suites,
"suite"} <<
", "
179 <<
amount{results_.cases,
"case"} <<
", " <<
amount{results_.total,
"test"} <<
" total, "
188 auto const ms = duration_cast<milliseconds>(d);
190 return boost::lexical_cast<std::string>(ms.count()) +
"ms";
207 results_.add(suite_results_);
215 os_ << suite_results_.name << (case_results_.name.empty() ?
"" : (
" " + case_results_.name))
223 suite_results_.add(case_results_);
230 ++case_results_.total;
237 ++case_results_.failed;
238 ++case_results_.total;
239 os_ <<
"#" << case_results_.total <<
" failed" << (reason.
empty() ?
"" :
": ") << reason
Utility for producing nicely composed output of amounts with units.
A simple test runner that writes everything to a stream in real time.
virtual void on_log(std::string const &s) override
Called when a test logs output.
suite_results suite_results_
reporter(reporter const &)=delete
virtual void on_case_end() override
Called when a new case ends.
case_results case_results_
reporter & operator=(reporter const &)=delete
virtual void on_suite_begin(suite_info const &info) override
Called when a new suite starts.
virtual void on_case_begin(std::string const &name) override
Called when a new case starts.
virtual void on_fail(std::string const &reason) override
Called for each failing condition.
static std::string fmtdur(typename clock_type::duration const &d)
virtual void on_suite_end() override
Called when a suite ends.
virtual void on_pass() override
Called for each passing condition.
Unit test runner interface.
Associates a unit test type with metadata.
std::string full_name() const
Return the canonical suite name as a string.
T setprecision(T... args)
case_results(std::string name_="")
clock_type::time_point start
std::vector< run_time > top
void add(suite_results const &r)
void add(case_results const &r)
suite_results(std::string name_="")
clock_type::time_point start