6#ifndef MIMICPP_REPORTS_HPP
7#define MIMICPP_REPORTS_HPP
80 template <pr
int_iterator OutIter>
81 OutIter print_times_state(OutIter out,
const std::size_t current,
const std::size_t min,
const std::size_t max)
83 const auto verbalizeValue = [](OutIter o,
const std::size_t value)
87 case 0:
return format::format_to(std::move(o),
"never");
88 case 1:
return format::format_to(std::move(o),
"once");
89 case 2:
return format::format_to(std::move(o),
"twice");
90 default:
return format::format_to(std::move(o),
"{} times", value);
96 out = format::format_to(
98 "already saturated (matched ");
99 out = verbalizeValue(std::move(out), current);
100 return format::format_to(std::move(out),
")");
105 return format::format_to(
107 "accepts further matches (matched {} out of {} times)",
112 const auto verbalizeInterval = [verbalizeValue](OutIter o,
const std::size_t start,
const std::size_t end)
116 return format::format_to(
118 "between {} and {} times",
123 o = format::format_to(std::move(o),
"exactly ");
124 return verbalizeValue(std::move(o), end);
127 out = format::format_to(std::move(out),
"matched ");
128 out = verbalizeValue(std::move(out), current);
129 out = format::format_to(std::move(out),
" - ");
130 out = verbalizeInterval(std::move(out), min, max);
131 return format::format_to(std::move(out),
" is expected");
134 struct control_state_printer
136 template <pr
int_iterator OutIter>
139 out = print_times_state(
145 if (
const auto sequenceCount = std::ranges::ssize(state.
sequenceRatings);
148 out = format::format_to(
150 ",\n\tand is the current element of {} sequence(s).",
157 template <pr
int_iterator OutIter>
160 out = print_times_state(
168 return format::format_to(
170 ",\n\tbut is not the current element of {} sequence(s) ({} total).",
175 template <pr
int_iterator OutIter>
178 out = print_times_state(
184 if (
const auto sequenceCount = std::ranges::ssize(state.
sequences);
187 out = format::format_to(
189 ",\n\tand is part of {} sequence(s).",
242 template <
typename Return,
typename... Params>
247 .returnTypeIndex =
typeid(Return),
248 .argDetails = std::apply(
251 return std::vector<CallReport::Arg>{
253 .typeIndex =
typeid(Params),
269 template <pr
int_iterator OutIter>
272 out = format::format_to(
278 out = format::format_to(
282 out = format::format_to(
285 "value category: {}\n"
293 out = format::format_to(
296 for (
const std::size_t i : std::views::iota(0u, std::ranges::size(report.
argDetails)))
298 out = format::format_to(
340 class detail::Printer<ExpectationReport>
343 template <pr
int_iterator OutIter>
344 static OutIter
print(OutIter out,
const ExpectationReport& report)
346 out = format::format_to(
348 "Expectation report:\n");
350 if (report.sourceLocation)
352 out = format::format_to(
357 *report.sourceLocation);
358 out = format::format_to(
363 if (report.timesDescription)
365 out = format::format_to(
368 *report.timesDescription);
371 if (std::ranges::any_of(
372 report.expectationDescriptions,
373 [](
const auto& desc) { return desc.has_value(); }))
375 out = format::format_to(
378 for (
const auto& desc
379 : report.expectationDescriptions
380 | std::views::filter([](
const auto& desc) { return desc.has_value(); }))
382 out = format::format_to(
389 if (report.finalizerDescription)
391 out = format::format_to(
394 *report.finalizerDescription);
465 if (!std::holds_alternative<state_applicable>(report.controlReport))
474 class detail::Printer<MatchReport>
477 template <pr
int_iterator OutIter>
478 static OutIter
print(OutIter out,
const MatchReport& report)
480 std::vector<StringT> matchedExpectationDescriptions{};
481 std::vector<StringT> unmatchedExpectationDescriptions{};
483 for (
const auto& [isMatching, description] : report.expectationReports)
489 matchedExpectationDescriptions.emplace_back(*description);
493 unmatchedExpectationDescriptions.emplace_back(*description);
501 out = format::format_to(
503 "Matched expectation: {{\n");
507 out = format::format_to(
509 "Inapplicable, but otherwise matched expectation: {{\n"
512 std::bind_front(control_state_printer{}, std::move(out)),
513 report.controlReport);
514 out = format::format_to(std::move(out),
"\n");
518 out = format::format_to(
520 "Unmatched expectation: {{\n");
529 if (report.sourceLocation)
531 out = format::format_to(
536 *report.sourceLocation);
537 out = format::format_to(
542 if (!std::ranges::empty(unmatchedExpectationDescriptions))
544 out = format::format_to(
547 for (
const auto& desc : unmatchedExpectationDescriptions)
549 out = format::format_to(
556 if (!std::ranges::empty(matchedExpectationDescriptions))
558 out = format::format_to(
561 for (
const auto& desc : matchedExpectationDescriptions)
563 out = format::format_to(
570 return format::format_to(
Definition Reports.hpp:208
std::type_index typeIndex
Definition Reports.hpp:210
friend bool operator==(const Arg &, const Arg &)=default
StringT stateString
Definition Reports.hpp:211
Contains the extracted info from a typed call::Info.
Definition Reports.hpp:205
std::type_index returnTypeIndex
Definition Reports.hpp:217
friend bool operator==(const CallReport &lhs, const CallReport &rhs)
Definition Reports.hpp:224
Constness fromConstness
Definition Reports.hpp:221
ValueCategory fromCategory
Definition Reports.hpp:220
std::vector< Arg > argDetails
Definition Reports.hpp:218
std::source_location fromLoc
Definition Reports.hpp:219
Contains the extracted info from a typed expectation.
Definition Reports.hpp:320
std::optional< StringT > finalizerDescription
Definition Reports.hpp:323
std::optional< StringT > timesDescription
Definition Reports.hpp:324
std::optional< std::source_location > sourceLocation
Definition Reports.hpp:322
std::vector< std::optional< StringT > > expectationDescriptions
Definition Reports.hpp:325
friend bool operator==(const ExpectationReport &lhs, const ExpectationReport &rhs)
Definition Reports.hpp:328
Information a used expectation policy.
Definition Reports.hpp:426
std::optional< StringT > description
Definition Reports.hpp:429
friend bool operator==(const Expectation &, const Expectation &)=default
bool isMatching
Definition Reports.hpp:428
Information about the used finalizer.
Definition Reports.hpp:413
std::optional< StringT > description
Definition Reports.hpp:415
friend bool operator==(const Finalize &, const Finalize &)=default
Contains the detailed information for match outcomes.
Definition Reports.hpp:407
std::vector< Expectation > expectationReports
Definition Reports.hpp:438
Finalize finalizeReport
Definition Reports.hpp:436
friend bool operator==(const MatchReport &lhs, const MatchReport &rhs)
Definition Reports.hpp:441
control_state_t controlReport
Definition Reports.hpp:437
std::optional< std::source_location > sourceLocation
Definition Reports.hpp:435
ValueCategory fromCategory
Definition Call.hpp:47
std::source_location fromSourceLocation
Definition Call.hpp:49
ArgListT args
Definition Call.hpp:46
Constness fromConstness
Definition Call.hpp:48
MatchResult evaluate_match_report(const MatchReport &report) noexcept
Determines, whether a match report actually denotes a full, inapplicable or no match.
Definition Reports.hpp:458
CallReport make_call_report(const call::Info< Return, Params... > &callInfo)
Generates the call report for a given call info.
Definition Reports.hpp:244
std::variant< state_inapplicable, state_applicable, state_saturated > control_state_t
Definition Reports.hpp:73
constexpr detail::PrintFn print
Functional object, converting the given object to its textual representation.
Definition Printer.hpp:597
Definition BoostTest.hpp:20
MatchResult
Definition Fwd.hpp:181
void unreachable()
Invokes undefined behavior.
Definition Utility.hpp:93
constexpr bool is_same_source_location(const std::source_location &lhs, const std::source_location &rhs) noexcept
Definition Utility.hpp:41
ValueCategory
Definition Fwd.hpp:195
Constness
Definition Fwd.hpp:188
std::basic_string< CharT, CharTraitsT > StringT
Definition Fwd.hpp:207
Definition Reports.hpp:52
std::vector< sequence::rating > sequenceRatings
Definition Reports.hpp:56
int count
Definition Reports.hpp:55
int min
Definition Reports.hpp:53
friend bool operator==(const state_applicable &, const state_applicable &)=default
int max
Definition Reports.hpp:54
Definition Reports.hpp:40
std::vector< sequence::rating > sequenceRatings
Definition Reports.hpp:44
int count
Definition Reports.hpp:43
friend bool operator==(const state_inapplicable &, const state_inapplicable &)=default
int min
Definition Reports.hpp:41
int max
Definition Reports.hpp:42
std::vector< sequence::Tag > inapplicableSequences
Definition Reports.hpp:45
Definition Reports.hpp:63
int max
Definition Reports.hpp:65
std::vector< sequence::Tag > sequences
Definition Reports.hpp:67
int count
Definition Reports.hpp:66
friend bool operator==(const state_saturated &, const state_saturated &)=default
int min
Definition Reports.hpp:64