mimic++ v4
Loading...
Searching...
No Matches
mimicpp::ScopedExpectation Class Reference

Takes the ownership of an expectation and check whether it's satisfied during destruction. More...

#include <Expectation.hpp>

Public Member Functions

 ~ScopedExpectation () noexcept(false)
 Removes the owned expectation from the ExpectationCollection and checks, whether it's satisfied.
 
template<typename Signature >
 ScopedExpectation (std::shared_ptr< ExpectationCollection< Signature > > collection, std::shared_ptr< typename ExpectationCollection< Signature >::ExpectationT > expectation) noexcept
 Constructor, which generates the type-erase storage.
 
template<typename T >
requires requires(const std::source_location& loc) { { std::declval<T&&>().finalize(loc) } -> std::convertible_to<ScopedExpectation>; }
 explicit (false) const expr ScopedExpectation(T &&object
 A constructor, which accepts objects, which can be finalized (e.g. ExpectationBuilder).
 
ScopedExpectationoperator= (const ScopedExpectation &)=delete
 Deleted copy-assignment-operator.
 
 ScopedExpectation (ScopedExpectation &&)=default
 Defaulted move-constructor.
 
ScopedExpectationoperator= (ScopedExpectation &&)=default
 Defaulted move-assignment-operator.
 
bool is_satisfied () const
 Queries the stored expectation, whether it's satisfied.
 
const std::source_location & from () const noexcept
 Queries the stored expectation for it's stored source-location.
 

Public Attributes

const std::source_location & loc
 

Detailed Description

Takes the ownership of an expectation and check whether it's satisfied during destruction.

The owned Expectation is type-erased. This comes in handy, when users want to store ScopedExpectations in a single container.

Constructor & Destructor Documentation

◆ ~ScopedExpectation()

mimicpp::ScopedExpectation::~ScopedExpectation ( )
inline

Removes the owned expectation from the ExpectationCollection and checks, whether it's satisfied.

Exceptions
Incases of an unsatisfied expectation, the destructor is expected to throw of terminate otherwise.

◆ ScopedExpectation() [1/2]

template<typename Signature >
mimicpp::ScopedExpectation::ScopedExpectation ( std::shared_ptr< ExpectationCollection< Signature > > collection,
std::shared_ptr< typename ExpectationCollection< Signature >::ExpectationT > expectation )
inlineexplicitnodiscardnoexcept

Constructor, which generates the type-erase storage.

Template Parameters
SignatureThe signature.
Parameters
collectionThe expectation collection, the expectation will be attached to.
expectationThe expectation.

◆ ScopedExpectation() [2/2]

mimicpp::ScopedExpectation::ScopedExpectation ( ScopedExpectation && )
nodiscarddefault

Defaulted move-constructor.

Member Function Documentation

◆ explicit()

template<typename T >
requires requires(const std::source_location& loc) { { std::declval<T&&>().finalize(loc) } -> std::convertible_to<ScopedExpectation>; }
mimicpp::ScopedExpectation::explicit ( false ) const &&
nodiscard

A constructor, which accepts objects, which can be finalized (e.g. ExpectationBuilder).

Template Parameters
TThe object type.
Parameters
objectThe object to be finalized.
locThe source-location.

◆ from()

const std::source_location & mimicpp::ScopedExpectation::from ( ) const
inlinenodiscardnoexcept

Queries the stored expectation for it's stored source-location.

Returns
The stored source-location.

◆ is_satisfied()

bool mimicpp::ScopedExpectation::is_satisfied ( ) const
inlinenodiscard

Queries the stored expectation, whether it's satisfied.

Returns
True, if satisfied.

◆ operator=() [1/2]

ScopedExpectation & mimicpp::ScopedExpectation::operator= ( const ScopedExpectation & )
delete

Deleted copy-assignment-operator.

◆ operator=() [2/2]

ScopedExpectation & mimicpp::ScopedExpectation::operator= ( ScopedExpectation && )
default

Defaulted move-assignment-operator.

Member Data Documentation

◆ loc

const std::source_location& mimicpp::ScopedExpectation::loc
Initial value:
= std::source_location::current())
: ScopedExpectation{std::forward<T>(object).finalize(loc)}
{
}
Takes the ownership of an expectation and check whether it's satisfied during destruction.
Definition Expectation.hpp:568
const std::source_location & loc
Definition Expectation.hpp:679
ScopedExpectation(std::shared_ptr< ExpectationCollection< Signature > > collection, std::shared_ptr< typename ExpectationCollection< Signature >::ExpectationT > expectation) noexcept
Constructor, which generates the type-erase storage.
Definition Expectation.hpp:655

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