mimic++ v1
Loading...
Searching...
No Matches
ExpectationPolicies.hpp
Go to the documentation of this file.
1// // Copyright Dominic (DNKpp) Koepke 2024 - 2024.
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_POLICIES_HPP
7#define MIMICPP_EXPECTATION_POLICIES_HPP
8
9#pragma once
10
12#include "mimic++/Matcher.hpp"
13#include "mimic++/Printer.hpp"
14#include "mimic++/Utility.hpp"
15
16#include <cassert>
17#include <functional>
18
19namespace mimicpp::expectation_policies::detail
20{
21 [[nodiscard]]
22 inline StringT describe_times_state(const std::size_t current, const std::size_t min, const std::size_t max)
23 {
24 const auto verbalizeValue = [](const std::size_t value)-> StringT
25 {
26 switch (value)
27 {
28 case 0:
29 return "never";
30 case 1:
31 return "once";
32 case 2:
33 return "twice";
34 default:
35 return format::format("{} times", value);
36 }
37 };
38
39 if (current == max)
40 {
41 return format::format(
42 "inapplicable: already saturated (matched {})",
43 verbalizeValue(current));
44 }
45
46 if (min <= current)
47 {
48 return format::format(
49 "applicable: accepts further matches (matched {} out of {} times)",
50 current,
51 max);
52 }
53
54 const auto verbalizeInterval = [verbalizeValue](const std::size_t start, const std::size_t end)
55 {
56 if (start < end)
57 {
58 return format::format(
59 "between {} and {} times",
60 start,
61 end);
62 }
63
64 return format::format(
65 "exactly {}",
66 verbalizeValue(end));
67 };
68
69 return format::format(
70 "unsatisfied: matched {} - {} is expected",
71 verbalizeValue(current),
72 verbalizeInterval(min, max));
73 }
74}
75
77{
79 {
80 public:
81 template <typename Return, typename... Args>
82 static constexpr void finalize_call(const call::Info<Return, Args...>&) noexcept
83 {
84 }
85 };
86
87 class Times
88 {
89 public:
90 [[nodiscard]]
91 constexpr explicit Times(const std::size_t min, const std::size_t max)
92 : m_Min{min},
93 m_Max{max}
94 {
95 if (m_Max < m_Min)
96 {
97 throw std::invalid_argument{"min must be less or equal to max."};
98 }
99 }
100
101 [[nodiscard]]
102 constexpr bool is_satisfied() const noexcept
103 {
104 return m_Min <= m_Count
105 && m_Count <= m_Max;
106 }
107
108 [[nodiscard]]
109 constexpr bool is_applicable() const noexcept
110 {
111 return m_Count < m_Max;
112 }
113
114 [[nodiscard]]
116 {
117 return detail::describe_times_state(
118 m_Count,
119 m_Min,
120 m_Max);
121 }
122
123 constexpr void consume() noexcept
124 {
125 ++m_Count;
126 }
127
128 private:
129 std::size_t m_Min;
130 std::size_t m_Max;
131 std::size_t m_Count{};
132 };
133
135 : public Times
136 {
137 public:
138 [[nodiscard]]
139 consteval InitTimes() noexcept
140 : Times{1u, 1u}
141 {
142 }
143 };
144
145 template <ValueCategory expected>
147 {
148 public:
149 static constexpr bool is_satisfied() noexcept
150 {
151 return true;
152 }
153
154 template <typename Return, typename... Args>
155 static constexpr bool matches(const call::Info<Return, Args...>& info) noexcept
156 {
157 return mimicpp::is_matching(info.fromCategory, expected);
158 }
159
160 template <typename Return, typename... Args>
161 static constexpr void consume(const call::Info<Return, Args...>& info) noexcept
162 {
163 assert(mimicpp::is_matching(info.fromCategory, expected) && "Call does not match.");
164 }
165
166 [[nodiscard]]
168 {
169 return format::format(
170 "expect: from {} category overload",
171 expected);
172 }
173 };
174
175 template <Constness constness>
177 {
178 public:
179 static constexpr bool is_satisfied() noexcept
180 {
181 return true;
182 }
183
184 template <typename Return, typename... Args>
185 static constexpr bool matches(const call::Info<Return, Args...>& info) noexcept
186 {
187 return mimicpp::is_matching(info.fromConstness, constness);
188 }
189
190 template <typename Return, typename... Args>
191 static constexpr void consume(const call::Info<Return, Args...>& info) noexcept
192 {
193 assert(mimicpp::is_matching(info.fromConstness, constness) && "Call does not match.");
194 }
195
196 [[nodiscard]]
198 {
199 return format::format(
200 "expect: from {} qualified overload",
201 constness);
202 }
203 };
204
205 template <typename Action>
206 requires std::same_as<Action, std::remove_cvref_t<Action>>
207 && std::is_move_constructible_v<Action>
209 {
210 public:
211 [[nodiscard]]
212 explicit constexpr ReturnsResultOf(
213 Action&& action
214 ) noexcept(std::is_nothrow_move_constructible_v<Action>)
215 : m_Action{std::move(action)}
216 {
217 }
218
219 template <typename Return, typename... Args>
220 requires std::invocable<Action&, const call::Info<Return, Args...>&>
222 std::invoke_result_t<Action&, const call::Info<Return, Args...>&>,
223 Return>
224 [[nodiscard]]
225 constexpr Return finalize_call(
226 [[maybe_unused]] const call::Info<Return, Args...>& call
227 ) noexcept(
228 std::is_nothrow_invocable_v<Action&, const call::Info<Return, Args...>&>
230 std::invoke_result_t<Action&, const call::Info<Return, Args...>&>,
231 Return>)
232 {
233 return static_cast<Return>(
234 std::invoke(m_Action, call));
235 }
236
237 private:
238 Action m_Action;
239 };
240
241 template <typename Exception>
242 requires (!std::is_reference_v<Exception>)
243 && std::copyable<Exception>
244 class Throws
245 {
246 public:
247 [[nodiscard]]
248 explicit constexpr Throws(Exception exception) noexcept(std::is_nothrow_move_constructible_v<Exception>)
249 : m_Exception{std::move(exception)}
250 {
251 }
252
253 template <typename Return, typename... Args>
254 constexpr Return finalize_call(
255 [[maybe_unused]] const call::Info<Return, Args...>& call
256 )
257 {
258 throw m_Exception; // NOLINT(hicpp-exception-baseclass)
259 }
260
261 private:
262 Exception m_Exception;
263 };
264
265 template <typename Matcher, typename Projection, typename Describer>
266 requires std::same_as<Matcher, std::remove_cvref_t<Matcher>>
267 && std::same_as<Projection, std::remove_cvref_t<Projection>>
268 && std::same_as<Describer, std::remove_cvref_t<Describer>>
269 && std::is_move_constructible_v<Matcher>
270 && std::is_move_constructible_v<Projection>
271 && std::is_move_constructible_v<Describer>
273 {
274 public:
275 [[nodiscard]]
276 explicit constexpr Requirement(
277 Matcher matcher,
278 Projection projection = Projection{},
279 Describer describer = Describer{}
280 ) noexcept(
281 std::is_nothrow_move_constructible_v<Matcher>
282 && std::is_nothrow_move_constructible_v<Projection>
283 && std::is_nothrow_move_constructible_v<Describer>)
284 : m_Matcher{std::move(matcher)},
285 m_Projection{std::move(projection)},
286 m_Describer{std::move(describer)}
287 {
288 }
289
290 static constexpr bool is_satisfied() noexcept
291 {
292 return true;
293 }
294
295 template <typename Return, typename... Args>
296 requires std::invocable<const Projection&, const call::Info<Return, Args...>&>
297 && matcher_for<
298 Matcher,
299 std::invoke_result_t<const Projection&, const call::Info<Return, Args...>&>>
300 [[nodiscard]]
301 constexpr bool matches(const call::Info<Return, Args...>& info) const
302 {
303 return m_Matcher.matches(
304 std::invoke(m_Projection, info));
305 }
306
307 template <typename Return, typename... Args>
308 static constexpr void consume([[maybe_unused]] const call::Info<Return, Args...>& info) noexcept
309 {
310 }
311
312 [[nodiscard]]
313 std::optional<StringT> describe() const
314 {
315 if (const std::optional<StringT> description = m_Matcher.describe())
316 {
317 return std::invoke(
318 m_Describer,
319 *description);
320 }
321
322 return std::nullopt;
323 }
324
325 private:
326 [[no_unique_address]] Matcher m_Matcher;
327 [[no_unique_address]] Projection m_Projection;
328 [[no_unique_address]] Describer m_Describer;
329 };
330
331 template <typename Action>
333 {
334 public:
335 ~SideEffectAction() = default;
336
337 [[nodiscard]]
338 explicit constexpr SideEffectAction(
339 Action&& action
340 ) noexcept(std::is_nothrow_move_constructible_v<Action>)
341 : m_Action{std::move(action)}
342 {
343 }
344
347
348 [[nodiscard]]
351
352 static constexpr bool is_satisfied() noexcept
353 {
354 return true;
355 }
356
357 template <typename Return, typename... Args>
358 [[nodiscard]]
359 static constexpr bool matches(const call::Info<Return, Args...>&) noexcept
360 {
361 return true;
362 }
363
364 [[nodiscard]]
365 static std::nullopt_t describe() noexcept
366 {
367 return std::nullopt;
368 }
369
370 template <typename Return, typename... Args>
371 requires std::invocable<Action&, const call::Info<Return, Args...>&>
372 constexpr void consume(
374 ) noexcept(std::is_nothrow_invocable_v<Action&, const call::Info<Return, Args...>&>)
375 {
376 std::invoke(m_Action, info);
377 }
378
379 private:
380 Action m_Action;
381 };
382
383 template <typename Action, template <typename> typename Projection>
384 requires std::same_as<Action, std::remove_cvref_t<Action>>
386 {
387 public:
388 [[nodiscard]]
389 explicit constexpr ApplyAllArgsAction(
390 Action action = Action{}
391 ) noexcept(std::is_nothrow_move_constructible_v<Action>)
392 : m_Action{std::move(action)}
393 {
394 }
395
396 template <typename Arg>
397 using ProjectedArgT = Projection<Arg>;
398
399 template <typename Return, typename... Args>
400 requires std::invocable<
401 const Action&,
403 constexpr decltype(auto) operator ()(
404 const call::Info<Return, Args...>& callInfo
405 ) const noexcept(
406 std::is_nothrow_invocable_v<
407 const Action&,
409 {
410 static_assert(
412 "Projection can not be applied.");
413
414 return std::apply(
415 [this](auto&... args) -> decltype(auto)
416 {
417 return std::invoke(
418 m_Action,
419 static_cast<ProjectedArgT<Args>>(
420 args.get())...);
421 },
422 callInfo.args);
423 }
424
425 private:
426 Action m_Action;
427 };
428
429 template <typename Action, template <typename> typename Projection, std::size_t... indices>
430 requires std::same_as<Action, std::remove_cvref_t<Action>>
432 {
433 public:
434 [[nodiscard]]
435 explicit constexpr ApplyArgsAction(
436 Action action = Action{}
437 ) noexcept(std::is_nothrow_move_constructible_v<Action>)
438 : m_Action{std::move(action)}
439 {
440 }
441
442 template <std::size_t index, typename... Args>
443 using ArgListElementT = std::tuple_element_t<index, std::tuple<Args...>>;
444
445 template <std::size_t index, typename... Args>
446 using ProjectedArgListElementT = Projection<ArgListElementT<index, Args...>>;
447
448 template <typename Return, typename... Args>
449 requires (... && (indices < sizeof...(Args)))
450 && std::invocable<
451 const Action&,
453 constexpr decltype(auto) operator ()(
454 const call::Info<Return, Args...>& callInfo
455 ) const noexcept(
456 std::is_nothrow_invocable_v<
457 const Action&,
458 ProjectedArgListElementT<indices, Args...>...>)
459 {
460 static_assert(
462 ArgListElementT<indices, Args...>&,
463 ProjectedArgListElementT<indices, Args...>>
464 && ...),
465 "Projection can not be applied.");
466
467 return std::invoke(
468 m_Action,
469 static_cast<ProjectedArgListElementT<indices, Args...>>(
470 std::get<indices>(callInfo.args).get())...);
471 }
472
473 private:
474 Action m_Action;
475 };
476}
477
478namespace mimicpp::expectation_policies::detail
479{
480 struct forward_fn
481 {
482 template <typename T>
483 [[nodiscard]]
484 constexpr T&& operator ()(T&& obj) const noexcept
485 {
486 return std::forward<T>(obj);
487 }
488 };
489}
490
492{
515 template <std::size_t min, std::size_t max = min>
516 requires (min <= max)
517 [[nodiscard]]
518 consteval auto times() noexcept
519 {
521 min,
522 max
523 };
524 }
525
534 [[nodiscard]]
535 constexpr auto times(const std::size_t min, const std::size_t max)
536 {
537 return expectation_policies::Times{min, max};
538 }
539
547 [[nodiscard]]
548 constexpr auto times(const std::size_t exactly) noexcept
549 {
550 return times(exactly, exactly);
551 }
552
560 template <std::size_t min>
561 [[nodiscard]]
562 consteval auto at_least() noexcept
563 {
565 min,
566 std::numeric_limits<std::size_t>::max()
567 };
568 }
569
577 [[nodiscard]]
578 constexpr auto at_least(const std::size_t min) noexcept
579 {
580 return expectation_policies::Times{min, std::numeric_limits<std::size_t>::max()};
581 }
582
589 template <std::size_t max>
590 [[nodiscard]]
591 consteval auto at_most() noexcept
592 {
594 0u,
595 max
596 };
597 }
598
605 [[nodiscard]]
606 constexpr auto at_most(const std::size_t max) noexcept
607 {
608 return expectation_policies::Times{0u, max};
609 }
610
617 [[nodiscard]]
618 consteval auto once() noexcept
619 {
621 1u,
622 1u
623 };
624 }
625
632 [[nodiscard]]
633 consteval auto twice() noexcept
634 {
636 2u,
637 2u
638 };
639 }
640
645 namespace detail
646 {
647 template <std::size_t index>
648 struct arg_requirement_describer
649 {
650 [[nodiscard]]
651 constexpr StringT operator ()(
652 const StringViewT matcherDescription
653 ) const
654 {
655 return format::format(
656 "expect: arg[{}] {}",
657 index,
658 matcherDescription);
659 }
660 };
661 }
662
689 template <std::size_t index, typename Matcher>
690 [[nodiscard]]
691 constexpr auto arg(
692 Matcher&& matcher
693 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Matcher>, Matcher&&>)
694 {
696 std::remove_cvref_t<Matcher>,
698 expectation_policies::detail::forward_fn,
699 std::add_lvalue_reference_t,
700 index>,
701 detail::arg_requirement_describer<index>>{
702 std::forward<Matcher>(matcher),
703 };
704 }
705
709}
710
712{
713 // ReSharper disable CppDoxygenUnresolvedReference
714
744 template <typename Fun>
745 requires std::invocable<std::remove_cvref_t<Fun>&>
746 && (!std::is_void_v<std::invoke_result_t<std::remove_cvref_t<Fun>&>>)
747 [[nodiscard]]
748 constexpr auto returns_result_of(
749 Fun&& fun // NOLINT(cppcoreguidelines-missing-std-forward)
750 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Fun>, Fun>)
751 {
753 [
754 fun = std::forward<Fun>(fun)
755 ]([[maybe_unused]] const auto& call) mutable noexcept(std::is_nothrow_invocable_v<decltype(fun)>) -> decltype(auto)
756 {
757 return std::invoke(fun);
758 }
759 };
760 }
761
779 template <typename T>
780 requires std::copyable<std::remove_cvref_t<T>>
781 [[nodiscard]]
782 constexpr auto returns(
783 T&& value // NOLINT(cppcoreguidelines-missing-std-forward)
784 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<T>, T>)
785 {
787 [v = std::forward<T>(value)]([[maybe_unused]] const auto& call) mutable noexcept -> auto& {
788 return static_cast<std::unwrap_reference_t<decltype(v)>&>(v);
789 }
790 };
791 }
792
805 template <std::size_t index, std::size_t... otherIndices, typename Action>
806 [[nodiscard]]
808 Action&& action
809 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
810 {
813 std::remove_cvref_t<Action>,
814 std::add_lvalue_reference_t,
815 index,
816 otherIndices...>{
817 std::forward<Action>(action)
818 }
819 };
820 }
821
832 template <typename Action>
833 [[nodiscard]]
835 Action&& action
836 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
837 {
840 std::remove_cvref_t<Action>,
841 std::add_lvalue_reference_t>{
842 std::forward<Action>(action)
843 }
844 };
845 }
846
854 template <std::size_t index>
855 [[nodiscard]]
856 constexpr auto returns_arg() noexcept
857 {
860 expectation_policies::detail::forward_fn,
861 std::add_rvalue_reference_t,
862 index>{
863 expectation_policies::detail::forward_fn{}
864 }
865 };
866 }
867
877 template <typename T>
878 requires std::copyable<std::remove_cvref_t<T>>
879 [[nodiscard]]
881 T&& exception
882 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<T>, T>)
883 {
885 std::forward<T>(exception)
886 };
887 }
888
893 // ReSharper restore CppDoxygenUnresolvedReference
894}
895
897{
926 template <std::size_t index, typename Action>
927 [[nodiscard]]
928 constexpr auto apply_arg(
929 Action&& action
930 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
931 {
934 std::remove_cvref_t<Action>,
935 std::add_lvalue_reference_t,
936 index>{
937 std::forward<Action>(action)
938 }
939 };
940 }
941
952 template <std::size_t index, std::size_t... additionalIndices, typename Action>
953 [[nodiscard]]
954 constexpr auto apply_args(
955 Action&& action
956 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
957 {
960 std::remove_cvref_t<Action>,
961 std::add_lvalue_reference_t,
962 index,
963 additionalIndices...>{
964 std::forward<Action>(action)
965 }
966 };
967 }
968
975 template <typename Action>
976 [[nodiscard]]
977 constexpr auto apply_all(
978 Action&& action
979 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
980 {
983 std::remove_cvref_t<Action>,
984 std::add_lvalue_reference_t>{
985 std::forward<Action>(action)
986 }
987 };
988 }
989
996 template <std::invocable Action>
997 [[nodiscard]]
998 constexpr auto invoke(
999 Action&& action // NOLINT(cppcoreguidelines-missing-std-forward)
1000 ) noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
1001 {
1003 [
1004 action = std::forward<Action>(action)
1005 ]([[maybe_unused]] const auto& call) mutable noexcept(std::is_nothrow_invocable_v<Action&>)
1006 {
1007 std::invoke(action);
1008 }
1009 };
1010 }
1011
1015}
1016
1017#endif
Definition Fwd.hpp:16
Definition ExpectationPolicies.hpp:386
constexpr ApplyAllArgsAction(Action action=Action{}) noexcept(std::is_nothrow_move_constructible_v< Action >)
Definition ExpectationPolicies.hpp:389
Projection< Arg > ProjectedArgT
Definition ExpectationPolicies.hpp:397
Definition ExpectationPolicies.hpp:432
constexpr decltype(auto) operator()(const call::Info< Return, Args... > &callInfo) const noexcept(std::is_nothrow_invocable_v< const Action &, ProjectedArgListElementT< indices, Args... >... >)
Definition ExpectationPolicies.hpp:453
constexpr ApplyArgsAction(Action action=Action{}) noexcept(std::is_nothrow_move_constructible_v< Action >)
Definition ExpectationPolicies.hpp:435
std::tuple_element_t< index, std::tuple< Args... > > ArgListElementT
Definition ExpectationPolicies.hpp:443
Projection< ArgListElementT< index, Args... > > ProjectedArgListElementT
Definition ExpectationPolicies.hpp:446
Definition ExpectationPolicies.hpp:147
static constexpr bool is_satisfied() noexcept
Definition ExpectationPolicies.hpp:149
static constexpr void consume(const call::Info< Return, Args... > &info) noexcept
Definition ExpectationPolicies.hpp:161
static StringT describe()
Definition ExpectationPolicies.hpp:167
static constexpr bool matches(const call::Info< Return, Args... > &info) noexcept
Definition ExpectationPolicies.hpp:155
Definition ExpectationPolicies.hpp:177
static constexpr bool is_satisfied() noexcept
Definition ExpectationPolicies.hpp:179
static constexpr void consume(const call::Info< Return, Args... > &info) noexcept
Definition ExpectationPolicies.hpp:191
static constexpr bool matches(const call::Info< Return, Args... > &info) noexcept
Definition ExpectationPolicies.hpp:185
static StringT describe()
Definition ExpectationPolicies.hpp:197
Definition ExpectationPolicies.hpp:79
static constexpr void finalize_call(const call::Info< Return, Args... > &) noexcept
Definition ExpectationPolicies.hpp:82
Definition ExpectationPolicies.hpp:136
consteval InitTimes() noexcept
Definition ExpectationPolicies.hpp:139
Definition ExpectationPolicies.hpp:273
static constexpr void consume(const call::Info< Return, Args... > &info) noexcept
Definition ExpectationPolicies.hpp:308
static constexpr bool is_satisfied() noexcept
Definition ExpectationPolicies.hpp:290
constexpr bool matches(const call::Info< Return, Args... > &info) const
Definition ExpectationPolicies.hpp:301
constexpr Requirement(Matcher matcher, Projection projection=Projection{}, Describer describer=Describer{}) noexcept(std::is_nothrow_move_constructible_v< Matcher > &&std::is_nothrow_move_constructible_v< Projection > &&std::is_nothrow_move_constructible_v< Describer >)
Definition ExpectationPolicies.hpp:276
std::optional< StringT > describe() const
Definition ExpectationPolicies.hpp:313
Definition ExpectationPolicies.hpp:209
constexpr Return finalize_call(const call::Info< Return, Args... > &call) noexcept(std::is_nothrow_invocable_v< Action &, const call::Info< Return, Args... > & > &&nothrow_explicitly_convertible_to< std::invoke_result_t< Action &, const call::Info< Return, Args... > & >, Return >)
Definition ExpectationPolicies.hpp:225
constexpr ReturnsResultOf(Action &&action) noexcept(std::is_nothrow_move_constructible_v< Action >)
Definition ExpectationPolicies.hpp:212
Definition ExpectationPolicies.hpp:333
static constexpr bool matches(const call::Info< Return, Args... > &) noexcept
Definition ExpectationPolicies.hpp:359
static std::nullopt_t describe() noexcept
Definition ExpectationPolicies.hpp:365
constexpr void consume(const call::Info< Return, Args... > &info) noexcept(std::is_nothrow_invocable_v< Action &, const call::Info< Return, Args... > & >)
Definition ExpectationPolicies.hpp:372
SideEffectAction & operator=(const SideEffectAction &)=delete
static constexpr bool is_satisfied() noexcept
Definition ExpectationPolicies.hpp:352
SideEffectAction(SideEffectAction &&)=default
constexpr SideEffectAction(Action &&action) noexcept(std::is_nothrow_move_constructible_v< Action >)
Definition ExpectationPolicies.hpp:338
SideEffectAction(const SideEffectAction &)=delete
Definition ExpectationPolicies.hpp:245
constexpr Return finalize_call(const call::Info< Return, Args... > &call)
Definition ExpectationPolicies.hpp:254
constexpr Throws(Exception exception) noexcept(std::is_nothrow_move_constructible_v< Exception >)
Definition ExpectationPolicies.hpp:248
Definition ExpectationPolicies.hpp:88
StringT describe_state() const
Definition ExpectationPolicies.hpp:115
constexpr bool is_satisfied() const noexcept
Definition ExpectationPolicies.hpp:102
constexpr Times(const std::size_t min, const std::size_t max)
Definition ExpectationPolicies.hpp:91
constexpr void consume() noexcept
Definition ExpectationPolicies.hpp:123
constexpr bool is_applicable() const noexcept
Definition ExpectationPolicies.hpp:109
Definition Utility.hpp:128
Definition Matcher.hpp:25
constexpr auto returns_apply_all_result_of(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
During the finalization step, all call arguments are applied on the given action.
Definition ExpectationPolicies.hpp:834
constexpr auto returns_apply_result_of(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
During the finalization step, the selected call arguments are applied on the given action.
Definition ExpectationPolicies.hpp:807
constexpr auto returns(T &&value) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< T >, T >)
During the finalization step, the stored value is returned.
Definition ExpectationPolicies.hpp:782
constexpr auto returns_arg() noexcept
During the finalization step, the selected call argument is returned.
Definition ExpectationPolicies.hpp:856
constexpr auto returns_result_of(Fun &&fun) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Fun >, Fun >)
During the finalization step, the invocation result of the given function is returned.
Definition ExpectationPolicies.hpp:748
constexpr auto arg(Matcher &&matcher) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Matcher >, Matcher && >)
Checks, whether the selected argument matches the given matcher.
Definition ExpectationPolicies.hpp:691
constexpr auto apply_all(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
Applies all arguments on the given action.
Definition ExpectationPolicies.hpp:977
constexpr auto apply_arg(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
Applies the argument at the specified index on the given action.
Definition ExpectationPolicies.hpp:928
constexpr auto invoke(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
Invokes the given function.
Definition ExpectationPolicies.hpp:998
constexpr auto apply_args(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
Applies the arguments at the specified index and in that order on the given action.
Definition ExpectationPolicies.hpp:954
consteval auto at_least() noexcept
Specifies a times policy with just a lower limit.
Definition ExpectationPolicies.hpp:562
consteval auto twice() noexcept
Specifies a times policy with both limits set to 2.
Definition ExpectationPolicies.hpp:633
consteval auto once() noexcept
Specifies a times policy with both limits set to 1.
Definition ExpectationPolicies.hpp:618
consteval auto times() noexcept
Specifies arbitrary limits with compile time arguments.
Definition ExpectationPolicies.hpp:518
consteval auto at_most() noexcept
Specifies a times policy with just an upper limit.
Definition ExpectationPolicies.hpp:591
Definition ExpectationPolicies.hpp:492
Definition ExpectationPolicies.hpp:20
Definition ExpectationPolicies.hpp:712
Definition ExpectationPolicies.hpp:897
constexpr bool is_matching(const Constness lhs, const Constness rhs) noexcept
Definition Utility.hpp:28
std::basic_string_view< CharT, CharTraitsT > StringViewT
Definition Printer.hpp:23
std::basic_string< CharT, CharTraitsT > StringT
Definition Fwd.hpp:37