Sequoia
Loading...
Searching...
No Matches
MoveOnlyCheckers.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2020. //
3// Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. //
4// (See accompanying file LICENSE.md or copy at //
5// https://www.gnu.org/licenses/gpl-3.0.en.html) //
7
8#pragma once
9
40
41namespace sequoia::testing
42{
48 template<test_mode Mode, moveonly T, class U, class V>
49 requires checkable_against_for_semantics<Mode, T, U> && checkable_against_for_semantics<Mode, T, V>
50 bool check_semantics(std::string description,
51 test_logger<Mode>& logger,
52 T&& x,
53 T&& y,
54 const U& xEquivalent,
55 const U& yEquivalent,
56 optional_ref<const V> movedFromPostConstruction,
57 optional_ref<const V> movedFromPostAssignment)
58 {
59 sentinel<Mode> sentry{logger, add_type_info<T>(std::move(description)).append("\n")};
60
61 if constexpr(equivalence_checkable_for_semantics<Mode, T, U>)
62 {
63 impl::check_best_equivalence(logger, x, y, xEquivalent, yEquivalent);
64 }
65
66 return impl::check_semantics(
67 logger,
69 std::forward<T>(x),
70 std::forward<T>(y),
71 xEquivalent,
72 yEquivalent,
73 movedFromPostConstruction,
74 movedFromPostAssignment,
76 );
77 }
78
84 template<test_mode Mode, moveonly T, class U, class V>
85 requires std::totally_ordered<T> && checkable_against_for_semantics<Mode, T, U> && checkable_against_for_semantics<Mode, T, V>
86 bool check_semantics(std::string description,
87 test_logger<Mode>& logger,
88 T&& x,
89 T&& y,
90 const U& xEquivalent,
91 const U& yEquivalent,
92 optional_ref<const V> movedFromPostConstruction,
93 optional_ref<const V> movedFromPostAssignment,
94 std::weak_ordering order)
95 {
96 sentinel<Mode> sentry{logger, add_type_info<T>(std::move(description)).append("\n")};
97
98 if constexpr(equivalence_checkable_for_semantics<Mode, T, U>)
99 {
100 impl::check_best_equivalence(logger, x, y, xEquivalent, yEquivalent);
101 }
102
103 return impl::check_semantics(
104 logger,
106 std::forward<T>(x),
107 std::forward<T>(y),
108 xEquivalent,
109 yEquivalent,
110 movedFromPostConstruction,
111 movedFromPostAssignment,
113 );
114 }
115}
Free functions for performing checks, together with the 'checker' class template which wraps them.
Implementation details for checking move-only semantics.
Definition: TestLogger.hpp:277
Definition: TestLogger.hpp:183
Definition: SemanticsCheckersDetails.hpp:150
Definition: SemanticsCheckersDetails.hpp:116