8#ifndef BEAST_UNIT_TEST_REPORTER_HPP
9#define BEAST_UNIT_TEST_REPORTER_HPP
11#include <xrpl/beast/unit_test/amount.h>
12#include <xrpl/beast/unit_test/recorder.h>
14#include <boost/lexical_cast.hpp>
15#include <boost/optional.hpp>
33template <
class =
void>
99 fmtdur(
typename clock_type::duration
const& d);
149 [](
run_time const& t1,
typename clock_type::duration
const& t2) {
150 return t1.second > t2;
152 if (iter !=
top.end())
155 top.resize(
top.size() - 1);
156 top.emplace(iter, r.
name, elapsed);
160 top.emplace_back(r.
name, elapsed);
175 if (results_.top.size() > 0)
177 os_ <<
"Longest suite times:\n";
178 for (
auto const& i : results_.top)
179 os_ <<
std::setw(8) << fmtdur(i.second) <<
" " << i.first <<
'\n';
181 auto const elapsed = clock_type::now() - results_.start;
182 os_ << fmtdur(elapsed) <<
", " <<
amount{results_.suites,
"suite"} <<
", "
183 <<
amount{results_.cases,
"case"} <<
", "
184 <<
amount{results_.total,
"test"} <<
" total, "
193 auto const ms = duration_cast<milliseconds>(d);
195 return boost::lexical_cast<std::string>(ms.count()) +
"ms";
212 results_.add(suite_results_);
220 os_ << suite_results_.name
221 << (case_results_.name.empty() ?
"" : (
" " + case_results_.name))
229 suite_results_.add(case_results_);
236 ++case_results_.total;
243 ++case_results_.failed;
244 ++case_results_.total;
245 os_ <<
"#" << case_results_.total <<
" failed"
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