mimic++
v10.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
Collector.hpp
Go to the documentation of this file.
1
// Copyright Dominic (DNKpp) Koepke 2026.
2
// Distributed under the Boost Software License, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at
4
// https://www.boost.org/LICENSE_1_0.txt)
5
6
#ifndef MIMICPP_EXPECTATION_COLLECTOR_HPP
7
#define MIMICPP_EXPECTATION_COLLECTOR_HPP
8
9
#pragma once
10
11
#include "
mimic++/Fwd.hpp
"
12
#include "
mimic++/config/Config.hpp
"
13
#include "
mimic++/expectation/Owner.hpp
"
14
15
#ifndef MIMICPP_DETAIL_IS_MODULE
16
#include <deque>
17
#include <utility>
18
#endif
19
20
MIMICPP_DETAIL_MODULE_EXPORT
namespace
mimicpp::expectation
21
{
31
class
Collector
32
{
33
public
:
37
Collector
(
Collector
const
&) =
delete
;
38
42
Collector
&
operator=
(
Collector
const
&) =
delete
;
43
47
~Collector
() noexcept(false)
48
{
49
auto
expectations
= std::exchange(m_Expectations, {});
50
while
(!
expectations
.empty())
51
{
52
// Prevent the `pop_front() noexcept` from raising an exception and thus terminating.
53
auto
const
expectation
= std::move(
expectations
.front());
54
expectations
.pop_front();
55
}
56
}
57
61
[[nodiscard]]
62
Collector
() =
default
;
63
67
[[nodiscard]]
68
Collector
(
Collector
&&) =
default
;
69
74
Collector
&
operator=
(
Collector
&&) =
default
;
75
84
Collector
&
attach
(
ScopedExpectation
&& builder) &
85
{
86
m_Expectations.emplace_back(std::move(builder));
87
88
return
*
this
;
89
}
90
100
Collector
&
operator+=
(
ScopedExpectation
&& builder) &
101
{
102
return
attach
(std::move(builder));
103
}
104
109
[[nodiscard]]
110
constexpr
std::deque<ScopedExpectation>
const
&
expectations
() const noexcept
111
{
112
return
m_Expectations;
113
}
114
115
private
:
116
std::deque<ScopedExpectation> m_Expectations{};
117
};
118
}
119
120
#endif
Config.hpp
MIMICPP_DETAIL_MODULE_EXPORT
#define MIMICPP_DETAIL_MODULE_EXPORT
Definition
Config.hpp:19
Fwd.hpp
Owner.hpp
mimicpp::expectation::Collector::operator+=
Collector & operator+=(ScopedExpectation &&builder) &
Attaches a newly constructed expectation.
Definition
Collector.hpp:100
mimicpp::expectation::Collector::~Collector
~Collector() noexcept(false)
Possibly throwing destructor, checking the owned expectations in order of construction.
Definition
Collector.hpp:47
mimicpp::expectation::Collector::attach
Collector & attach(ScopedExpectation &&builder) &
Attaches a newly constructed expectation.
Definition
Collector.hpp:84
mimicpp::expectation::Collector::Collector
Collector(Collector const &)=delete
Deleted copy-constructor.
mimicpp::expectation::Collector::expectations
constexpr std::deque< ScopedExpectation > const & expectations() const noexcept
Retrieves the collection of explicitly owned expectations.
Definition
Collector.hpp:110
mimicpp::expectation::Collector::operator=
Collector & operator=(Collector &&)=default
Defaulted move-assignment operator.
mimicpp::expectation::Collector::Collector
Collector(Collector &&)=default
Defaulted move-constructor.
mimicpp::expectation::Collector::Collector
Collector()=default
Defaulted default-constructor.
mimicpp::expectation::Collector::operator=
Collector & operator=(Collector const &)=delete
Deleted copy-assignment operator.
mimicpp::ScopedExpectation
expectation::Owner ScopedExpectation
Takes the ownership of an expectation and checks whether it's satisfied during destruction.
Definition
Fwd.hpp:480
mimicpp::expectation
Definition
Builder.hpp:33
mimic++
expectation
Collector.hpp
Generated on
for mimic++ by
1.18.0