7#include <source_location>
12#include "runnable.hpp"
19template <Util::is_functional T>
32class ItBase :
public Runnable {
34 std::string description;
35 std::list<Result> results;
44 explicit ItBase(std::source_location location) noexcept : Runnable(location) {}
51 explicit ItBase(std::source_location location,
const char* description) noexcept
52 : Runnable(location), description(description) {}
64 [[nodiscard]] std::string
get_description() const noexcept {
return description; }
71 this->description = description;
91 template <Util::is_not_functional T>
103 template <Util::is_functional T>
115 template <
typename T>
117 std::source_location location = std::source_location::current());
128 template <
typename T>
131 void add_result(
const Result& result) { results.push_back(result); }
132 std::list<Result>& get_results() noexcept {
return results; }
133 [[nodiscard]]
const std::list<Result>& get_results() const noexcept {
return results; }
134 void clear_results() noexcept { results.clear(); }
136 [[nodiscard]] Result get_result()
const override {
137 auto default_result = Result::success(this->get_location());
138 if (results.empty()) {
139 return default_result;
142 return std::accumulate(results.begin(), results.end(), default_result, &Result::reduce);
Definition expectation.hpp:479
Definition expectation.hpp:438
bool needs_description() noexcept
Get whether the object needs a description string.
Definition it_base.hpp:58
ItBase & set_description(std::string_view description) noexcept
Set the description string.
Definition it_base.hpp:70
std::string get_description() const noexcept
Get the description string for the it statement.
Definition it_base.hpp:64
ExpectationValue< T > expect(T value, std::source_location location=std::source_location::current())
The expect object generator for objects and LiteralTypes.
Definition it.hpp:129
ItBase(std::source_location location, const char *description) noexcept
Create an BaseIt with an explicit description.
Definition it_base.hpp:51
ItBase(std::source_location location) noexcept
Create an BaseIt without an explicit description.
Definition it_base.hpp:44
Utility functions and classes.