6#ifndef MIMICPP_SCOPED_SEQUENCE_HPP
7#define MIMICPP_SCOPED_SEQUENCE_HPP
18#ifndef MIMICPP_DETAIL_IS_MODULE
23namespace mimicpp::sequence::detail
25 template <
typename Sequence>
26 class ExpectationBuilderFinalizer
29 ExpectationBuilderFinalizer(ExpectationBuilderFinalizer
const&) =
delete;
30 ExpectationBuilderFinalizer& operator=(ExpectationBuilderFinalizer
const&) =
delete;
31 ExpectationBuilderFinalizer(ExpectationBuilderFinalizer&&) =
delete;
32 ExpectationBuilderFinalizer& operator=(ExpectationBuilderFinalizer&&) =
delete;
34 ~ExpectationBuilderFinalizer() =
default;
36 template <
typename Signature,
auto state,
typename... Args>
38 explicit(
false) ExpectationBuilderFinalizer(
39 expectation::BasicBuilder<Signature, state, Args...>&& builder,
40 util::SourceLocation loc = {})
42 [&builder, loc = std::move(loc)](
Sequence& sequence) mutable {
53 MIMICPP_ASSERT(m_FinalizeFn,
"Finalize-Function was already consumed.");
56 std::exchange(m_FinalizeFn,
nullptr),
85 template <auto Strategy>
87 :
public sequence::detail::BasicSequenceInterface<sequence::Id, Strategy>
111 : sequence::detail::BasicSequenceInterface<sequence::Id, Strategy>{std::move(loc)}
113 static_assert(0u ==
sizeof...(canary),
"ScopedSequence does not accept constructor arguments.");
139 m_Expectations.attach(builder.finalize(*
this));
154 return m_Expectations.expectations();
#define MIMICPP_ASSERT(condition, msg)
Definition Config.hpp:54
#define MIMICPP_DETAIL_MODULE_EXPORT
Definition Config.hpp:19
A sequence type that verifies its owned expectations during destruction.
Definition ScopedSequence.hpp:88
BasicScopedSequence & operator=(BasicScopedSequence const &)=delete
Deleted copy-assignment operator.
~BasicScopedSequence() noexcept(false)=default
Possibly throwing destructor, checking the owned expectations in order of construction.
BasicScopedSequence(BasicScopedSequence const &)=delete
Deleted copy-constructor.
std::deque< ScopedExpectation > const & expectations() const noexcept
Retrieves the collection of explicitly owned expectations.
Definition ScopedSequence.hpp:152
BasicScopedSequence & operator=(BasicScopedSequence &&)=default
Defaulted move-assignment operator.
BasicScopedSequence(BasicScopedSequence &&)=default
Defaulted move-constructor.
BasicScopedSequence & operator+=(sequence::detail::ExpectationBuilderFinalizer< BasicScopedSequence > &&builder)
Attaches a newly constructed expectation.
Definition ScopedSequence.hpp:137
Collects scoped expectations and verifies them during destruction.
Definition Collector.hpp:32
LazySequence Sequence
The default sequence type (LazySequence).
Definition Sequence.hpp:472
BasicScopedSequence< sequence::detail::LazyStrategy{}> LazyScopedSequence
The scoped-sequence type with lazy strategy.
Definition ScopedSequence.hpp:171
LazyScopedSequence ScopedSequence
The default scoped-sequence type (lazy strategy).
Definition ScopedSequence.hpp:177
BasicScopedSequence< sequence::detail::GreedyStrategy{}> GreedyScopedSequence
The scoped-sequence type with greedy strategy.
Definition ScopedSequence.hpp:165
constexpr auto in_sequence(sequence::detail::BasicSequenceInterface< Id, priorityStrategy > &sequence)
Attaches the expectation onto a sequence.
Definition Sequence.hpp:513
expectation::Owner ScopedExpectation
Takes the ownership of an expectation and checks whether it's satisfied during destruction.
Definition Fwd.hpp:480
constexpr std::optional< LexerTokenClass > expect(TokenStream &stream, LexerTokenClass const &expected)
Definition Parser.hpp:210