mimic++ v10.0.1
Loading...
Searching...
No Matches
mimicpp::expectation::Expectation Class Reference

The type-erased expectation type with shared ownership. More...

#include <Expectation.hpp>

Public Member Functions

virtual ~Expectation ()=default
 Defaulted virtual destructor.
 Expectation (Expectation const &)=default
 Defaulted copy-constructor.
Expectation & operator= (Expectation const &)=default
 Defaulted copy-assignment-operator.
 Expectation (Expectation &&)=default
 Defaulted move-constructor.
Expectation & operator= (Expectation &&)=default
 Defaulted move-assignment-operator.
template<typename Signature, control_policy ControlPolicy, finalize_policy_for< Signature > FinalizePolicy, expectation_policy_for< Signature >... Policies>
 Expectation (std::in_place_type_t< Signature > const, util::SourceLocation from, reporting::TargetReport target, ControlPolicy controlPolicy, FinalizePolicy finalizePolicy, Policies... policies)
 Constructs the expectation with the given arguments.
util::SourceLocation const & from () const noexcept
 Returns the source-location, where this expectation was created.
StringT const & mock_name () const noexcept
 Returns the name of the related mock.
reporting::ExpectationReport report () const
 Creates a report of the internal state.
bool is_satisfied () const noexcept
 Queries all policies, whether they are satisfied.
bool is_applicable () const noexcept
 Queries the control policy, whether it's in the applicable state.
template<typename Return, typename... Args>
std::optional< MatchResults > matches (call::Info< Return, Args... > const &callInfo) const
 Queries all policies, whether they accept the given call.
template<typename Return, typename... Args>
Return consume (call::Info< Return, Args... > const &callInfo)
 Informs all policies that the given call was accepted.

Friends

bool operator== (Expectation const &, Expectation const &)=default

Detailed Description

The type-erased expectation type with shared ownership.

This type serves as a value-type for a single expectation and can be freely copied around, without duplicating the actual expectation.

Constructor & Destructor Documentation

◆ ~Expectation()

virtual mimicpp::expectation::Expectation::~Expectation ( )
virtualdefault

Defaulted virtual destructor.

◆ Expectation() [1/3]

mimicpp::expectation::Expectation::Expectation ( Expectation const & )
default

Defaulted copy-constructor.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Expectation() [2/3]

mimicpp::expectation::Expectation::Expectation ( Expectation && )
default

Defaulted move-constructor.

Here is the call graph for this function:

◆ Expectation() [3/3]

template<typename Signature, control_policy ControlPolicy, finalize_policy_for< Signature > FinalizePolicy, expectation_policy_for< Signature >... Policies>
mimicpp::expectation::Expectation::Expectation ( std::in_place_type_t< Signature > const ,
util::SourceLocation from,
reporting::TargetReport target,
ControlPolicy controlPolicy,
FinalizePolicy finalizePolicy,
Policies... policies )
inlineexplicitnodiscard

Constructs the expectation with the given arguments.

Template Parameters
SignatureThe target signature.
ControlPolicyThe control-policy type.
FinalizePolicyThe finalize-policy type.
PoliciesThe expectation-policies types.
Parameters
fromThe source-location, where this expectation was created.
targetInformation about the target-mock.
controlPolicyThe control-policy.
finalizePolicyThe finalize-policy.
policiesThe expectation-policies.
Here is the call graph for this function:

Member Function Documentation

◆ consume()

template<typename Return, typename... Args>
Return mimicpp::expectation::Expectation::consume ( call::Info< Return, Args... > const & callInfo)
inlinenodiscard

Informs all policies that the given call was accepted.

Parameters
callInfoThe call to be consumed.

This function is called when a match was made.

◆ from()

util::SourceLocation const & mimicpp::expectation::Expectation::from ( ) const
inlinenodiscardnoexcept

Returns the source-location, where this expectation was created.

Returns
Immutable reference to the source-location.
Here is the caller graph for this function:

◆ is_applicable()

bool mimicpp::expectation::Expectation::is_applicable ( ) const
inlinenodiscardnoexcept

Queries the control policy, whether it's in the applicable state.

Returns
Returns true if the expectation is applicable.

◆ is_satisfied()

bool mimicpp::expectation::Expectation::is_satisfied ( ) const
inlinenodiscardnoexcept

Queries all policies, whether they are satisfied.

Returns
Returns true if all policies are satisfied.

◆ matches()

template<typename Return, typename... Args>
std::optional< MatchResults > mimicpp::expectation::Expectation::matches ( call::Info< Return, Args... > const & callInfo) const
inlinenodiscard

Queries all policies, whether they accept the given call.

Parameters
callInfoThe call to be matched.
Returns
the requirements outcomes when the call matches the expectation signature; otherwise std::nullopt is returned.

◆ mock_name()

StringT const & mimicpp::expectation::Expectation::mock_name ( ) const
inlinenodiscardnoexcept

Returns the name of the related mock.

Returns
Immutable reference to the mock-name.

◆ operator=() [1/2]

Expectation & mimicpp::expectation::Expectation::operator= ( Expectation && )
default

Defaulted move-assignment-operator.

Here is the call graph for this function:

◆ operator=() [2/2]

Expectation & mimicpp::expectation::Expectation::operator= ( Expectation const & )
default

Defaulted copy-assignment-operator.

Here is the call graph for this function:

◆ report()

reporting::ExpectationReport mimicpp::expectation::Expectation::report ( ) const
inlinenodiscard

Creates a report of the internal state.

Returns
A newly generated report.

◆ operator==

bool operator== ( Expectation const & ,
Expectation const &  )
friend

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