Sequoia
Loading...
Searching...
No Matches
Summary.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2020. //
3// Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. //
4// (See accompanying file LICENSE.md or copy at //
5// https://www.gnu.org/licenses/gpl-3.0.en.html) //
7
8#pragma once
9
16
17#include <optional>
18
19namespace sequoia::testing
20{
22 enum class summary_detail { none=0, absent_checks=1, failure_messages=2, timings=4};
23}
24
25NAMESPACE_SEQUOIA_AS_BITMASK
26{
27 template<>
28 struct as_bitmask<sequoia::testing::summary_detail> : std::true_type
29 {};
30}
31
32namespace sequoia::testing
33{
34 template<std::forward_iterator Iter> void pad_right(Iter begin, Iter end, std::string_view suffix)
35 {
36 auto maxIter{std::ranges::max_element(begin, end, std::ranges::less{}, [](const std::string& s) { return s.size(); })};
37
38 const auto maxChars{maxIter->size()};
39
40 for(; begin != end; ++begin)
41 {
42 auto& s{*begin};
43 s += std::string(maxChars - s.size(), ' ') += std::string{suffix};
44 }
45 }
46
47 template<std::forward_iterator Iter> void pad_left(Iter begin, Iter end, const std::size_t minChars)
48 {
49 auto maxIter{std::ranges::max_element(begin, end, std::ranges::less{}, [](const std::string& s) { return s.size(); })};
50
51 const auto maxChars{std::ranges::max(maxIter->size(), minChars)};
52
53 for(; begin != end; ++begin)
54 {
55 auto& s{*begin};
56 s = std::string(maxChars - s.size(), ' ') + s;
57 }
58 }
59
60 using opt_duration = std::optional<log_summary::duration>;
61
63 {
64 std::string time, unit;
65 };
66
67 [[nodiscard]]
68 stringified_duration stringify(const log_summary::duration& d);
69
70 [[nodiscard]]
71 std::string report_time(const log_summary& log, opt_duration duration);
72
73 [[nodiscard]]
74 std::string summarize(const log_summary& log, std::string_view namesuffix, opt_duration duration, const summary_detail verbosity, indentation ind_0, indentation ind_1);
75
76 [[nodiscard]]
77 std::string summarize(const log_summary& log, std::string_view namesuffix, summary_detail verbosity, indentation ind_0, indentation ind_1);
78}
Utilities to aid logical operations.
summary_detail
Definition: Summary.hpp:22
Utilities for recording the outcome of tests.
Type-safe mechanism for indentations.
Definition: Indent.hpp:22
Summaries data generated by the logger, for the purposes of reporting.
Definition: TestLogger.hpp:299
Definition: Summary.hpp:63