Collects scoped expectations and verifies them during destruction.
More...
#include <Collector.hpp>
Collects scoped expectations and verifies them during destruction.
A Collector owns the attached expectations and keeps them alive until it is destroyed. When destruction happens, all owned expectations are checked in order of construction.
{
collector += outer.expect_call();
{
collector += inner.expect_call();
inner();
}
outer();
}
◆ Collector() [1/3]
| mimicpp::expectation::Collector::Collector |
( |
Collector const & | | ) |
|
|
delete |
Deleted copy-constructor.
◆ ~Collector()
| mimicpp::expectation::Collector::~Collector |
( |
| ) |
|
|
inline |
Possibly throwing destructor, checking the owned expectations in order of construction.
◆ Collector() [2/3]
| mimicpp::expectation::Collector::Collector |
( |
| ) |
|
|
nodiscarddefault |
Defaulted default-constructor.
◆ Collector() [3/3]
| mimicpp::expectation::Collector::Collector |
( |
Collector && | | ) |
|
|
nodiscarddefault |
Defaulted move-constructor.
◆ attach()
Attaches a newly constructed expectation.
- Parameters
-
| builder | The expectation-builder that will be finalized. |
- Returns
- A mutable reference to the current instance.
This collector becomes the owner of the created expectation and attaches it to the internal expectation-collection. Even though this function formally requires a ScopedExpectation as an argument, it's expected that users pass an expectation-builder. Doing so will then correctly deduce the source-location.
◆ expectations()
| std::deque< ScopedExpectation > const & mimicpp::expectation::Collector::expectations |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Retrieves the collection of explicitly owned expectations.
- Returns
- A constant reference to the collection of attached expectations.
◆ operator+=()
Attaches a newly constructed expectation.
- Parameters
-
| builder | The expectation-builder that will be finalized. |
- Returns
- A mutable reference to the current instance.
This collector becomes the owner of the created expectation and attaches it to the internal expectation-collection. Even though this function formally requires a ScopedExpectation as an argument, it's expected that users pass an expectation-builder. Doing so will then correctly deduce the source-location.
- Note
- In CLion, expressions with this operator may incorrectly report that the variable is never used after being assigned. This is a known bug that unfortunately cannot be worked around on the framework level. If you find yourself stuck to the Resharper DFA, you can use Collector::attach instead.
- See also
- https://youtrack.jetbrains.com/issue/CPP-49527/
-
https://youtrack.jetbrains.com/issue/CPP-38216
◆ operator=() [1/2]
Defaulted move-assignment operator.
- Returns
- A mutable reference to the current instance.
◆ operator=() [2/2]
Deleted copy-assignment operator.
The documentation for this class was generated from the following file: