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

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

#include <Owner.hpp>

Collaboration diagram for mimicpp::expectation::Owner:
[legend]

Public Member Functions

 Owner (Owner const &)=delete
 Deleted copy-constructor.
Owner & operator= (Owner const &)=delete
 Deleted copy-assignment-operator.
 ~Owner () noexcept(false)
 Removes the owned expectation from the Registry and checks whether it's satisfied.
 Owner (Registry::Ptr registry, Expectation expectation)
 Constructor, which generates the type-erase storage.
template<detail::finalizable T>
 explicit (false) const expr Owner(T &&object
 A constructor accepting objects, which can be finalized (i.e., expectation::Builder).
Owner & operator= (Owner &&)=default
 Defaulted move-assignment-operator.
bool is_satisfied () const
 Queries the stored expectation, whether it's satisfied.
bool is_applicable () const
 Queries the stored expectation, whether it's applicable.
util::SourceLocation const & from () const noexcept
 Queries the stored expectation for it's stored source-location.
StringT const & mock_name () const noexcept
 Queries the stored expectation for the name of the related mock.

Public Attributes

util::SourceLocation loc

Detailed Description

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

Instances of this type have exclusive ownership of their attached expectations, which will be checked during destruction.

{
mimicpp::Mock<void()> mock{};
SCOPED_EXP mock.expect_call(); // This creates a `mimicpp::ScopedExpectation` with a unique name.
mock();
} // The expectation is checked here.

They can be freely passed around and may even outlive their target-mock.

std::optional<mimicpp::ScopedExpectation> expectation{};
{
mimicpp::Mock<void()> mock{};
expectation = mock.expect_call();
mock();
}
expectation.reset(); // The expectation is checked here, even though the actual mock-target is already destroyed.

Constructor & Destructor Documentation

◆ Owner() [1/2]

mimicpp::expectation::Owner::Owner ( Owner const & )
delete

Deleted copy-constructor.

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

◆ ~Owner()

mimicpp::expectation::Owner::~Owner ( )
inline

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

Attention
In case of an unsatisfied expectation, the destructor is expected to throw or terminate otherwise.

◆ Owner() [2/2]

mimicpp::expectation::Owner::Owner ( Registry::Ptr registry,
Expectation expectation )
inlineexplicitnodiscard

Constructor, which generates the type-erase storage.

Parameters
registryThe target expectation registry.
expectationThe target expectation.

Member Function Documentation

◆ explicit()

template<detail::finalizable T>
mimicpp::expectation::Owner::explicit ( false ) const &&
nodiscard

A constructor accepting objects, which can be finalized (i.e., expectation::Builder).

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

◆ from()

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

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

Returns
The stored source-location.

◆ is_applicable()

bool mimicpp::expectation::Owner::is_applicable ( ) const
inlinenodiscard

Queries the stored expectation, whether it's applicable.

Returns
True, if applicable.

◆ is_satisfied()

bool mimicpp::expectation::Owner::is_satisfied ( ) const
inlinenodiscard

Queries the stored expectation, whether it's satisfied.

Returns
True, if satisfied.

◆ mock_name()

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

Queries the stored expectation for the name of the related mock.

Returns
The stored mock-name.

◆ operator=() [1/2]

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

Defaulted move-assignment-operator.

Here is the call graph for this function:

◆ operator=() [2/2]

Owner & mimicpp::expectation::Owner::operator= ( Owner const & )
delete

Deleted copy-assignment-operator.

Here is the call graph for this function:

Member Data Documentation

◆ loc

util::SourceLocation mimicpp::expectation::Owner::loc
nodiscard
Initial value:
= {})
: Owner{std::forward<T>(object).finalize(std::move(loc))}
{
}
Owner(Owner&&) = default
Takes the ownership of an expectation and checks whether it's satisfied during destruction.
Definition Owner.hpp:42
Owner(Owner const &)=delete
Deleted copy-constructor.
util::SourceLocation loc
Definition Owner.hpp:86

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