mimic++ v9.2.1
Loading...
Searching...
No Matches
mimicpp::BasicScopedSequence< Strategy > Class Template Reference

A sequence type that verifies its owned expectations during destruction. More...

#include <ScopedSequence.hpp>

Inheritance diagram for mimicpp::BasicScopedSequence< Strategy >:
[legend]
Collaboration diagram for mimicpp::BasicScopedSequence< Strategy >:
[legend]

Public Member Functions

 BasicScopedSequence (BasicScopedSequence const &)=delete
 Deleted copy-constructor.
 
BasicScopedSequenceoperator= (BasicScopedSequence const &)=delete
 Deleted copy-assignment operator.
 
 ~BasicScopedSequence () noexcept(false)
 Possibly throwing destructor, checking the owned expectations in order of construction.
 
 BasicScopedSequence (auto &&... canary, util::SourceLocation loc={})
 Default-constructor.
 
 BasicScopedSequence (BasicScopedSequence &&)=default
 Defaulted move-constructor.
 
BasicScopedSequenceoperator= (BasicScopedSequence &&)=default
 Defaulted move-assignment operator.
 
BasicScopedSequenceoperator+= (sequence::detail::ExpectationBuilderFinalizer< BasicScopedSequence > &&builder)
 Attaches a newly constructed expectation.
 
std::deque< ScopedExpectation > const & expectations () const noexcept
 Retrieves the collection of explicitly owned expectations.
 

Detailed Description

template<auto Strategy>
class mimicpp::BasicScopedSequence< Strategy >

A sequence type that verifies its owned expectations during destruction.

Template Parameters
StrategyThe sequence strategy employed.

This type offers a convenient mechanism for chaining multiple expectations into a sequence, and it monitors whether they are fulfilled upon destruction.

In essence, it behaves similarly to manually attaching expectations via expect::in_sequence to a sequence. The primary distinction is that if an expectation is not satisfied, this type will report the first unfulfilled expectation. In contrast, when expectations are manually constructed as ScopedExpectation, the last created expectation (due to the stack’s order) would typically be reported.

Nevertheless, all standard sequence rules also apply.

namespace expect = mimicpp::expect;
mimicpp::Mock<void()> mock{};
sequence += mock.expect_call() // (1)
and expect::at_most(1);
sequence += mock.expect_call(); // (2)
mock(); // matches (1)
mock(); // matches (2)

Constructor & Destructor Documentation

◆ BasicScopedSequence() [1/3]

template<auto Strategy>
mimicpp::BasicScopedSequence< Strategy >::BasicScopedSequence ( BasicScopedSequence< Strategy > const & )
nodiscarddelete

Deleted copy-constructor.

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

◆ ~BasicScopedSequence()

template<auto Strategy>
mimicpp::BasicScopedSequence< Strategy >::~BasicScopedSequence ( )
inline

Possibly throwing destructor, checking the owned expectations in order of construction.

Here is the call graph for this function:

◆ BasicScopedSequence() [2/3]

template<auto Strategy>
mimicpp::BasicScopedSequence< Strategy >::BasicScopedSequence ( auto &&... canary,
util::SourceLocation loc = {} )
inlineexplicitnodiscard

Default-constructor.

◆ BasicScopedSequence() [3/3]

template<auto Strategy>
mimicpp::BasicScopedSequence< Strategy >::BasicScopedSequence ( BasicScopedSequence< Strategy > && )
nodiscarddefault

Defaulted move-constructor.

Here is the call graph for this function:

Member Function Documentation

◆ expectations()

template<auto Strategy>
std::deque< ScopedExpectation > const & mimicpp::BasicScopedSequence< Strategy >::expectations ( ) const
inlinenodiscardnoexcept

Retrieves the collection of explicitly owned expectations.

Returns
A constant reference to the collection of attached expectations.
Note
This function returns only those expectations that were explicitly attached using the operator +=, and not every expectation that is currently queued in the sequence (i.e. by manually using expect::in_sequence).
Here is the caller graph for this function:

◆ operator+=()

template<auto Strategy>
BasicScopedSequence & mimicpp::BasicScopedSequence< Strategy >::operator+= ( sequence::detail::ExpectationBuilderFinalizer< BasicScopedSequence< Strategy > > && builder)
inline

Attaches a newly constructed expectation.

Parameters
builderThe expectation-builder that will be finalized.
Returns
A mutable reference to the current instance.

This function augments the provided expectation-builder with an additional sequence-policy for this sequence and finalizes its construction. Additionally, the sequence takes over the ownership of the constructed ScopedExpectation.

Here is the call graph for this function:

◆ operator=() [1/2]

template<auto Strategy>
BasicScopedSequence & mimicpp::BasicScopedSequence< Strategy >::operator= ( BasicScopedSequence< Strategy > && )
default

Defaulted move-assignment operator.

Returns
A mutable reference to the current instance.
Here is the call graph for this function:

◆ operator=() [2/2]

template<auto Strategy>
BasicScopedSequence & mimicpp::BasicScopedSequence< Strategy >::operator= ( BasicScopedSequence< Strategy > const & )
delete

Deleted copy-assignment operator.

Here is the call graph for this function:

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