mimic++ v4
Loading...
Searching...
No Matches
mimicpp::BasicReporter< successReporter, warningReporter, failReporter > Class Template Reference

A reporter, which creates text messages and reports them via the provided callbacks. More...

#include <Reporter.hpp>

Inheritance diagram for mimicpp::BasicReporter< successReporter, warningReporter, failReporter >:
[legend]
Collaboration diagram for mimicpp::BasicReporter< successReporter, warningReporter, failReporter >:
[legend]

Public Member Functions

void report_no_matches (const CallReport call, const std::vector< MatchReport > matchReports) override
 Expects reports about all none matching expectations. This is only called, if there are no better options available.
 
void report_inapplicable_matches (const CallReport call, const std::vector< MatchReport > matchReports) override
 Expects reports about all inapplicable matching expectations. This is only called, if there are no better options available.
 
void report_full_match (const CallReport call, const MatchReport matchReport) noexcept override
 Expects the report about a full matching expectation.
 
void report_unfulfilled_expectation (const ExpectationReport expectationReport) override
 Expects the report of an unfulfilled expectation.
 
void report_error (const StringT message) override
 Expects rather unspecific errors.
 
void report_unhandled_exception (const CallReport call, const ExpectationReport expectationReport, const std::exception_ptr exception) override
 Expects reports about unhandled exceptions, during handle_call.
 

Detailed Description

template<std::invocable< const StringT & > auto successReporter, std::invocable< const StringT & > auto warningReporter, std::invocable< const StringT & > auto failReporter>
class mimicpp::BasicReporter< successReporter, warningReporter, failReporter >

A reporter, which creates text messages and reports them via the provided callbacks.

Template Parameters
successReporterThe success reporter callback.
warningReporterThe warning reporter callback.
failReporterThe fail reporter callback. This reporter must never return!

Member Function Documentation

◆ report_error()

template<std::invocable< const StringT & > auto successReporter, std::invocable< const StringT & > auto warningReporter, std::invocable< const StringT & > auto failReporter>
void mimicpp::BasicReporter< successReporter, warningReporter, failReporter >::report_error ( const StringT message)
inlineoverridevirtual

Expects rather unspecific errors.

Parameters
messageThe error message.

This function is called, when an unspecific error occurs.

Note
In general, it is expected that this function does not return, but throws an exception instead. But, as this function may be called due to any reason, implementations shall check whether an uncaught exception already exists (e.g. via std::uncaught_exceptions) before throwing by themselves.
See also
DefaultReporter::report_error for an example.

Implements mimicpp::IReporter.

◆ report_full_match()

template<std::invocable< const StringT & > auto successReporter, std::invocable< const StringT & > auto warningReporter, std::invocable< const StringT & > auto failReporter>
void mimicpp::BasicReporter< successReporter, warningReporter, failReporter >::report_full_match ( const CallReport call,
const MatchReport matchReport )
inlineoverridevirtualnoexcept

Expects the report about a full matching expectation.

Parameters
callThe call report.
matchReportReport of the full matching expectation.

This function is called, when a match has been found. There are no other expectations on the behavior of this function; except the noexcept guarantee. Implementations shall simply return to the caller.

Implements mimicpp::IReporter.

◆ report_inapplicable_matches()

template<std::invocable< const StringT & > auto successReporter, std::invocable< const StringT & > auto warningReporter, std::invocable< const StringT & > auto failReporter>
void mimicpp::BasicReporter< successReporter, warningReporter, failReporter >::report_inapplicable_matches ( const CallReport call,
const std::vector< MatchReport > matchReports )
inlineoverridevirtual

Expects reports about all inapplicable matching expectations. This is only called, if there are no better options available.

Parameters
callThe call report.
matchReportsReports of all inapplicable matching expectations.

This function is called, when no applicable match has been found, but actually the call expectations are fulfilled. This in fact happens, when the times policy is already saturated (e.g. it was once expected and already matched once) or otherwise not applicable (e.g. a sequence element is not the current element).

Attention
Derived reporter implementations must never return and shall instead leave the function via a thrown exception or a terminating mechanism (e.g. std::terminate). Otherwise, this will result in undefined behavior.

Implements mimicpp::IReporter.

◆ report_no_matches()

template<std::invocable< const StringT & > auto successReporter, std::invocable< const StringT & > auto warningReporter, std::invocable< const StringT & > auto failReporter>
void mimicpp::BasicReporter< successReporter, warningReporter, failReporter >::report_no_matches ( const CallReport call,
const std::vector< MatchReport > matchReports )
inlineoverridevirtual

Expects reports about all none matching expectations. This is only called, if there are no better options available.

Parameters
callThe call report.
matchReportsReports of all none matching expectations.

This function is called, when no match has been found and there are no other expectations, which are matching but inapplicable. In fact, this is the fallback reporting mechanism, for unmatched calls.

Note
matchReports may be empty.
Attention
Derived reporter implementations must never return and shall instead leave the function via a thrown exception or a terminating mechanism (e.g. std::terminate). Otherwise, this will result in undefined behavior.

Implements mimicpp::IReporter.

◆ report_unfulfilled_expectation()

template<std::invocable< const StringT & > auto successReporter, std::invocable< const StringT & > auto warningReporter, std::invocable< const StringT & > auto failReporter>
void mimicpp::BasicReporter< successReporter, warningReporter, failReporter >::report_unfulfilled_expectation ( const ExpectationReport expectationReport)
inlineoverridevirtual

Expects the report of an unfulfilled expectation.

Parameters
expectationReportThe expectation report.

This function is called, when an unfulfilled expectation goes out of scope. In fact this happens, when the times policy is not satisfied.

Note
In general, it is expected that this function does not return, but throws an exception instead. But, as this function is always called when an unfulfilled expectation goes out of scope, implementations shall check whether an uncaught exception already exists (e.g. via std::uncaught_exceptions) before throwing by themselves.
See also
DefaultReporter::report_unfulfilled_expectation for an example.

Implements mimicpp::IReporter.

◆ report_unhandled_exception()

template<std::invocable< const StringT & > auto successReporter, std::invocable< const StringT & > auto warningReporter, std::invocable< const StringT & > auto failReporter>
void mimicpp::BasicReporter< successReporter, warningReporter, failReporter >::report_unhandled_exception ( const CallReport call,
const ExpectationReport expectationReport,
const std::exception_ptr exception )
inlineoverridevirtual

Expects reports about unhandled exceptions, during handle_call.

Parameters
callThe call report.
expectationReportThe expectation report.
exceptionThe exception.

This function is called, when an expectation throws during a matches call. There are no expectations on the behavior of this function. As this function is called inside a catch block, throwing exceptions will result in a terminate call.

Implements mimicpp::IReporter.


The documentation for this class was generated from the following file: