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>
34template <
class =
void>
100 fmtdur(
typename clock_type::duration
const& d);
150 [](
run_time const& t1,
typename clock_type::duration
const& t2) {
151 return t1.second > t2;
153 if (iter !=
top.end())
156 top.resize(
top.size() - 1);
157 top.emplace(iter, r.
name, elapsed);
161 top.emplace_back(r.
name, elapsed);
176 if (results_.top.size() > 0)
178 os_ <<
"Longest suite times:\n";
179 for (
auto const& i : results_.top)
180 os_ <<
std::setw(8) << fmtdur(i.second) <<
" " << i.first <<
'\n';
182 auto const elapsed = clock_type::now() - results_.start;
183 os_ << fmtdur(elapsed) <<
", " <<
amount{results_.suites,
"suite"} <<
", "
184 <<
amount{results_.cases,
"case"} <<
", "
185 <<
amount{results_.total,
"test"} <<
" total, "
194 auto const ms = duration_cast<milliseconds>(d);
196 return boost::lexical_cast<std::string>(ms.count()) +
"ms";
213 results_.add(suite_results_);
221 os_ << suite_results_.name
222 << (case_results_.name.empty() ?
"" : (
" " + case_results_.name))
230 suite_results_.add(case_results_);
237 ++case_results_.total;
244 ++case_results_.failed;
245 ++case_results_.total;
246 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