Sequoia
Loading...
Searching...
No Matches
RegularAllocationTestCore.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
18
19namespace sequoia::testing
20{
26 template<test_mode Mode>
28 {
29 public:
30 constexpr static test_mode mode{Mode};
31
33
34 template<class Self, pseudoregular T, std::invocable<T&> Mutator, alloc_getter<T>... Getters>
35 requires (!std::totally_ordered<T> && (sizeof...(Getters) > 0))
36 void check_semantics(this Self& self, const reporter& description, const T& x, const T& y, Mutator m, allocation_info<T, Getters>... info)
37 {
38 testing::check_semantics(append_lines(self.report(description), emphasise("Regular Semantics")), self.m_Logger, x, y, m, info...);
39 }
40
41 template
42 <
43 class Self,
45 invocable_r<T> xMaker,
46 invocable_r<T> yMaker,
47 std::invocable<T&> Mutator,
48 alloc_getter<T>... Getters
49 >
50 requires (!std::totally_ordered<T> && (sizeof...(Getters) > 0))
51 std::pair<T, T> check_semantics(this Self& self, const reporter& description, xMaker xFn, yMaker yFn, Mutator m, allocation_info<T, Getters>... info)
52 {
53 return testing::check_semantics(append_lines(self.report(description), emphasise("Regular Semantics")), self.m_Logger, std::move(xFn), std::move(yFn), m, info...);
54 }
55
56 template<class Self, pseudoregular T, std::invocable<T&> Mutator, alloc_getter<T>... Getters>
57 requires (std::totally_ordered<T> && (sizeof...(Getters) > 0))
58 void check_semantics(this Self& self, const reporter& description, const T& x, const T& y, std::weak_ordering order, Mutator m, allocation_info<T, Getters>... info)
59 {
60 testing::check_semantics(append_lines(self.report(description), emphasise("Ordered Semantics")), self.m_Logger, x, y, order, m, info...);
61 }
62
63 template
64 <
65 class Self,
67 invocable_r<T> xMaker,
68 invocable_r<T> yMaker,
69 std::invocable<T&> Mutator,
70 alloc_getter<T>... Getters
71 >
72 requires (std::totally_ordered<T> && (sizeof...(Getters) > 0))
73 std::pair<T, T> check_semantics(this Self& self, const reporter& description, xMaker xFn, yMaker yFn, std::weak_ordering order, Mutator m, allocation_info<T, Getters>... info)
74 {
75 return testing::check_semantics(append_lines(self.report(description), emphasise("Ordered Semantics")), self.m_Logger, std::move(xFn), std::move(yFn), order, m, info...);
76 }
77 protected:
79
81 regular_allocation_extender& operator=(regular_allocation_extender&&) noexcept = default;
82 };
83
102 template<test_mode Mode>
103 class basic_regular_allocation_test : public basic_test<Mode, regular_allocation_extender<Mode>>
104 {
105 public:
106 using basic_test<Mode, regular_allocation_extender<Mode>>::basic_test;
107
108 protected:
110
112 basic_regular_allocation_test& operator=(basic_regular_allocation_test&&) noexcept = default;
113
114 template<class Self>
115 void do_allocation_tests(this Self& self)
116 {
117 self.template test_allocation<false, false, false>();
118 self.template test_allocation<false, false, true>();
119 self.template test_allocation<false, true, false>();
120 self.template test_allocation<false, true, true>();
121 self.template test_allocation<true, false, false>();
122 self.template test_allocation<true, false, true>();
123 self.template test_allocation<true, true, false>();
124 self.template test_allocation<true, true, true>();
125 }
126 };
127
132}
Utilities for allocation testing.
Utilities for performing allocation checks for regular types, see here.
Utilities for checking regular semantics.
Class for use with a container possessing a (shared counting) allocator.
Definition: AllocationCheckers.hpp:425
Templated on the test_mode, this forms the basis of all allocation tests for regular types.
Definition: RegularAllocationTestCore.hpp:104
class template from which all concrete tests should derive.
Definition: FreeTestCore.hpp:144
class template for plugging into the checker class template to provide allocation checks for regular ...
Definition: RegularAllocationTestCore.hpp:28
Definition: Output.hpp:186
Supplements std::invocable.
Definition: Concepts.hpp:24
Similar to std::regular but relaxes the requirement of default initializability.
Definition: Concepts.hpp:39
Definition: AllocationCheckersTraits.hpp:24