9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
14 #include <type_traits>
17 namespace tt = boost::test_tools;
19 using namespace Acts::Concepts;
24 BOOST_AUTO_TEST_SUITE(Surfaces)
27 METHOD_TRAIT(foo_method_t,
foo);
28 METHOD_TRAIT(bar_method_t,
bar);
31 int bar(
const double& ) {
return 5; }
35 int bar(
const double& )
const {
return 5; }
39 int bar(
const double& ) {
return 5; }
44 static_assert(!has_method<E, int, bar_method_t>,
"failed");
46 static_assert(has_method<E, int, bar_method_t, const double&>,
"failed");
48 static_assert(!has_method<E, double, bar_method_t, const double&>,
"failed");
50 static_assert(!has_method<E, int, bar_method_t, const double>,
"failed");
52 static_assert(!has_method<E, int, bar_method_t, double&>,
"failed");
54 static_assert(!has_method<E, int, bar_method_t, double>,
"failed");
58 static_assert(!has_method<const E, int, bar_method_t, const double&>,
61 static_assert(!has_method<E, int, foo_method_t, const double&>,
"failed");
64 static_assert(!has_method<E2, int, bar_method_t>,
"failed");
68 static_assert(!has_method<E2, int, bar_method_t, const double&>,
"failed");
70 static_assert(has_method<const E2, int, bar_method_t, const double&>,
73 static_assert(!has_method<E2, int, bar_method_t, const double>,
"failed");
75 static_assert(!has_method<E2, int, bar_method_t, double&>,
"failed");
77 static_assert(!has_method<E2, int, bar_method_t, double>,
"failed");
79 static_assert(!has_method<const E2, char, bar_method_t, const double&>,
82 static_assert(!has_method<const E2, int, foo_method_t, const double&>,
86 static_assert(!has_method<E3, int, bar_method_t, const double&>,
"failed");
118 static_assert(has_member<M, member_a_t, int>,
"!");
119 static_assert(has_member<M, member_b_t, double>,
"!");
121 static_assert(!has_member<M, member_b_t, int>,
"!");
122 static_assert(!has_member<M, member_a_t, double>,
"!");
124 static_assert(has_member<M2, member_a_t, double>,
"!");
125 static_assert(!has_member<M2, member_a_t, int>,
"!");
127 static_assert(exists<member_a_t, M>,
"!");
128 static_assert(exists<member_a_t, M2>,
"!");
129 static_assert(exists<member_a_t, M3>,
"!");
130 static_assert(!exists<member_a_t, M4>,
"!");
133 static_assert(!has_member<M5, member_b_t, char>,
"!");
136 static_assert(!exists<member_b_t, M5>,
"!");
139 template <
typename T>
141 template <
typename T>
158 static_assert(exists<nested_a_t, N>,
"!");
159 static_assert(exists<nested_b_t, N>,
"!");
161 static_assert(exists<nested_a_t, N2>,
"!");
162 static_assert(!exists<nested_b_t, N2>,
"!");
164 static_assert(!exists<nested_a_t, N3>,
"!");
165 static_assert(exists<nested_b_t, N3>,
"!");
169 template <
typename T>
170 using member_t = decltype(std::declval<T>().member);
173 template <
typename T>
177 template <
typename T>
178 using meta_t =
typename T::template meta<void, void>;
181 template <
typename T>
183 require<has_method<T, double, foo_method_t, double, int>,
184 has_method<const T, bool, bar_method_t, double&&>,
185 has_member<T, member_t, bool>, exists<nested_t, T>,
193 template <
typename U,
typename V>
196 double foo(
double ,
int ) {
return 5; }
198 bool bar(
double&& )
const {
return true; }
206 template <
typename U>
209 double foo(
double ,
int ) {
return 5; }
211 bool bar(
double&& )
const {
return true; }
217 int foo(
double ) {
return 5; }
221 double foo(
int ) {
return 5; }
225 double bar(
double ) {
return 5; }
229 static_assert(SomeConcept<A>,
"A does not fulfill \"SomeConcept\"");
230 static_assert(!SomeConcept<A2>,
"A2 does not fulfill \"SomeConcept\"");
231 static_assert(!SomeConcept<B>,
"B does fulfill \"SomeConcept\"");
232 static_assert(!SomeConcept<C>,
"C does fulfill \"SomeConcept\"");
233 static_assert(!SomeConcept<D>,
"D does fulfill \"SomeConcept\"");
236 BOOST_AUTO_TEST_SUITE_END()