1 /* Copyright 2016 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/poly_collection for library home page.
9 #include "test_comparison.hpp"
11 #include <boost/core/lightweight_test.hpp>
12 #include "any_types.hpp"
13 #include "base_types.hpp"
14 #include "function_types.hpp"
15 #include "test_utilities.hpp"
17 using namespace test_utilities
;
19 template<typename PolyCollection
,typename ValueFactory
,typename
... Types
>
20 void test_comparison()
24 const PolyCollection
& cp1
=p1
;
25 const PolyCollection
& cp2
=p2
;
28 BOOST_TEST(!(cp1
!=cp1
));
30 BOOST_TEST(!(cp1
!=cp2
));
34 const PolyCollection
& cp1
=p1
;
35 const PolyCollection
& cp2
=p2
;
39 constraints
<is_not_equality_comparable
>,
43 BOOST_TEST(!(cp1
==cp2
));
48 const PolyCollection
& cp1
=p1
;
49 const PolyCollection
& cp2
=p2
;
52 p1
.template register_types
<Types
...>();
54 constraints
<is_not_equality_comparable
>,
58 BOOST_TEST(!(cp1
==cp2
));
63 const PolyCollection
& cp1
=p1
;
64 const PolyCollection
& cp2
=p2
;
68 constraints
<is_not_equality_comparable
>,
72 constraints
<is_not_equality_comparable
>,
76 BOOST_TEST(!(cp1
==cp2
));
80 using not_equality_comparable
=
81 boost::poly_collection::not_equality_comparable
;
84 const PolyCollection
& cp1
=p1
;
85 const PolyCollection
& cp2
=p2
;
89 constraints
<is_not_equality_comparable
>,
93 constraints
<is_not_equality_comparable
>,
97 check_throw
<not_equality_comparable
>(
98 [&]{(void)(cp1
==cp2
);},
99 [&]{(void)(cp1
!=cp2
);});
102 PolyCollection p1
,p2
;
103 const PolyCollection
& cp1
=p1
;
104 const PolyCollection
& cp2
=p2
;
108 constraints
<is_not_equality_comparable
>,
112 constraints
<is_equality_comparable
,is_copy_constructible
>,
115 p1
.insert(p2
.begin(),p2
.end());
117 BOOST_TEST(!(cp1
==cp2
));
118 BOOST_TEST(cp1
!=cp2
);
121 PolyCollection p1
,p2
;
122 const PolyCollection
& cp1
=p1
;
123 const PolyCollection
& cp2
=p2
;
126 p1
.template register_types
<Types
...>();
128 constraints
<is_equality_comparable
,is_copy_constructible
>,
131 p1
.insert(p2
.begin(),p2
.end());
133 BOOST_TEST(cp1
==cp2
);
134 BOOST_TEST(!(cp1
!=cp2
));
136 p1
.erase(p1
.begin());
137 BOOST_TEST(!(cp1
==cp2
));
138 BOOST_TEST(cp1
!=cp2
);
142 void test_comparison()
145 any_types::collection
,auto_increment
,
146 any_types::t1
,any_types::t2
,any_types::t3
,
147 any_types::t4
,any_types::t5
>();
149 base_types::collection
,auto_increment
,
150 base_types::t1
,base_types::t2
,base_types::t3
,
151 base_types::t4
,base_types::t5
>();
153 function_types::collection
,auto_increment
,
154 function_types::t1
,function_types::t2
,function_types::t3
,
155 function_types::t4
,function_types::t5
>();