12 #include "object_util.hpp"
13 #include "Point_test.hpp"
14 #include "util/ct_array.hpp"
15 #include "Vector/map_vector.hpp"
17 #include "check_no_pointers.hpp"
18 #include "Grid/util.hpp"
19 #include "data_type/scalar.hpp"
20 #include "util/convert.hpp"
22 #include "mul_array_extents.hpp"
30 static constexpr
bool stag_mask[] = {
true,
false,
true};
46 static const std::string name[2];
50 const std::string test_has_attributes::attributes::name[]={
"attributes1",
"attributes2"};
58 BOOST_AUTO_TEST_SUITE( util_test )
60 BOOST_AUTO_TEST_CASE( object_prop_copy )
65 typedef Point_test<float>::type vboost;
73 boost::fusion::at_c<p::x>(src.data) = 1.0;
74 boost::fusion::at_c<p::y>(src.data) = 2.0;
76 for (
size_t i = 0 ; i < 3 ; i++)
77 boost::fusion::at_c<p::v>(src.data)[i] = i + 5.0;
83 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<0>(dst.data),1.0);
84 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<1>(dst.data),2.0);
86 for (
size_t i = 0 ; i < 3 ; i++)
87 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<2>(dst.data)[i],i + 5.0);
100 v_point_red.resize(2);
102 v_point.template get<p::x>(0) = 1.0;
103 v_point.template get<p::y>(0) = 2.0;
105 for (
size_t i = 0 ; i < 3 ; i++)
106 v_point.template get<p::v>(0)[i] = i + 5.0;
108 auto src_e = v_point.get(0);
109 auto dst_e = v_point_red.get(0);
113 BOOST_REQUIRE_EQUAL(v_point_red.get(0).template get<0>(),1.0);
114 BOOST_REQUIRE_EQUAL(v_point_red.get(0).template get<1>(),2.0);
116 for (
size_t i = 0 ; i < 3 ; i++)
117 BOOST_REQUIRE_EQUAL(v_point_red.get(0).template get<2>()[i],i + 5.0);
127 typedef Point_test<float>::type vboost;
128 typedef object_creator<Point_test<float>::type,0,1,4>::type vboost_red;
131 object<vboost_red> src;
135 boost::fusion::at_c<0>(src.data) = 1.0;
136 boost::fusion::at_c<1>(src.data) = 2.0;
138 for (
size_t i = 0 ; i < 3 ; i++)
139 boost::fusion::at_c<2>(src.data)[i] = i + 5.0;
145 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::x>(dst.data),1.0);
146 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::y>(dst.data),2.0);
148 for (
size_t i = 0 ; i < 3 ; i++)
149 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::v>(dst.data)[i],i + 5.0);
162 v_point_red.resize(2);
164 v_point_red.template get<0>(0) = 11.0;
165 v_point_red.template get<1>(0) = 12.0;
167 for (
size_t i = 0 ; i < 3 ; i++)
168 v_point_red.template get<2>(0)[i] = i + 15.0;
170 auto dst_e = v_point.get(0);
171 auto src_e = v_point_red.get(0);
175 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::x>(),11.0);
176 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::y>(),12.0);
178 for (
size_t i = 0 ; i < 3 ; i++)
179 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::v>()[i],i + 15.0);
186 struct no_method_pointer
197 static bool noPointers() {
return true;}
205 static bool noPointers() {
return false;}
208 typedef boost::fusion::vector<int,float,double,no_method_pointer,no_pointer,with_pointer,no_method_pointer> v;
210 int val = boost::mpl::size< noPointers_sequence<v,0,2>::type >::value;
211 BOOST_REQUIRE_EQUAL(val,0);
213 val = boost::mpl::size< noPointers_sequence<v,0,2,4,5>::type >::value;
214 BOOST_REQUIRE_EQUAL(val,0);
216 val = boost::mpl::size< noPointers_sequence<v,0,1,2,3,4,5,6>::type >::value;
217 BOOST_REQUIRE_EQUAL(val,2);
219 typedef boost::fusion::vector<int *,float &,double *,no_method_pointer *,no_pointer &,with_pointer *,no_method_pointer &> vp;
221 val = boost::mpl::size< noPointers_sequence<vp,0,1,2,3,4,5,6>::type >::value;
222 BOOST_REQUIRE_EQUAL(val,2);
230 struct no_method_pointer
241 static bool noPointers() {
return true;}
249 static bool noPointers() {
return false;}
252 typedef boost::fusion::vector<int,float,double> v;
254 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
256 typedef boost::fusion::vector<int,float,double,no_pointer> va;
258 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
260 typedef boost::fusion::vector<int,float,double,no_pointer,with_pointer> vb;
262 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
264 typedef boost::fusion::vector<int,float,double,no_pointer,double *> vc;
266 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
268 typedef boost::fusion::vector<int,float,double,no_pointer,double &> vd;
270 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
272 typedef boost::fusion::vector<int,float,double,no_pointer,double[3]> ve;
274 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
276 typedef boost::fusion::vector<int,float,double,no_pointer,no_pointer *> vf;
278 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
280 typedef boost::fusion::vector<int,float,double,no_pointer,no_pointer &> vg;
282 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
284 typedef boost::fusion::vector<int,float,double,no_pointer,no_pointer[3]> vh;
286 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
293 enum { value = index + N };
302 const size_t count = 5;
303 typedef typename ::generate_array<size_t,count, MetaFunc>::result ct_test;
307 for (
size_t i = 0 ; i < count; ++i)
309 const size_t ct_val = ct_test::data[i];
310 BOOST_REQUIRE_EQUAL(ct_val,count+i);
321 const size_t count = 5;
322 typedef typename ::generate_array_constexpr<size_t,count, MetaFunc>::result ct_test_ce;
327 BOOST_REQUIRE_EQUAL(ct_calc,11ul);
334 BOOST_AUTO_TEST_CASE( check_templates_util_function )
342 static bool noPointers() {
return true;}
347 static bool noPointers() {
return false;}
366 BOOST_REQUIRE_EQUAL(val,
true);
368 BOOST_REQUIRE_EQUAL(val,
false);
376 struct test_typedef_same_data
378 typedef boost::fusion::vector<float,double,float[3]> type;
383 struct test_typedef_not_same_data
385 typedef boost::fusion::vector<float,double,float[3]> type;
387 boost::fusion::vector<float,double> data;
391 BOOST_REQUIRE_EQUAL(val,
true);
393 BOOST_REQUIRE_EQUAL(val,
false);
406 struct test_no_has_data
411 BOOST_REQUIRE_EQUAL(val,
true);
413 BOOST_REQUIRE_EQUAL(val,
false);
422 BOOST_REQUIRE_EQUAL(val,
true);
424 BOOST_REQUIRE_EQUAL(val,
false);
432 struct test_has_typedef
437 struct test_no_has_data
442 BOOST_REQUIRE_EQUAL(val,
true);
444 BOOST_REQUIRE_EQUAL(val,
false);
453 BOOST_REQUIRE_EQUAL(val,
true);
455 BOOST_REQUIRE_EQUAL(val,
false);
463 static bool noPointers() {
return PNP::NO_POINTERS;}
468 static bool noPointers() {
return PNP::POINTERS;}
476 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
478 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
480 BOOST_REQUIRE_EQUAL(val,PNP::UNKNOWN);
494 BOOST_REQUIRE_EQUAL( val ,
true);
496 BOOST_REQUIRE_EQUAL( val ,
true);
498 BOOST_REQUIRE_EQUAL( val ,
true);
501 BOOST_REQUIRE_EQUAL(val ,
true);
503 BOOST_REQUIRE_EQUAL(val,
true);
505 BOOST_REQUIRE_EQUAL(val,
true);
508 BOOST_REQUIRE_EQUAL( val,
false);
510 BOOST_REQUIRE_EQUAL( val,
false);
525 BOOST_REQUIRE_EQUAL( val ,
true);
527 BOOST_REQUIRE_EQUAL( val ,
true);
529 BOOST_REQUIRE_EQUAL( val ,
true);
532 BOOST_REQUIRE_EQUAL(val ,
true);
534 BOOST_REQUIRE_EQUAL(val,
true);
536 BOOST_REQUIRE_EQUAL(val,
true);
539 BOOST_REQUIRE_EQUAL( val,
false);
541 BOOST_REQUIRE_EQUAL( val,
false);
556 BOOST_REQUIRE_EQUAL( val ,
true);
558 BOOST_REQUIRE_EQUAL( val ,
true);
560 BOOST_REQUIRE_EQUAL( val ,
true);
563 BOOST_REQUIRE_EQUAL( val ,
true);
565 BOOST_REQUIRE_EQUAL( val ,
true);
567 BOOST_REQUIRE_EQUAL( val ,
true);
570 BOOST_REQUIRE_EQUAL( val,
false);
572 BOOST_REQUIRE_EQUAL( val,
false);
581 BOOST_REQUIRE_EQUAL(mul,1ul);
583 BOOST_REQUIRE_EQUAL(mul,3ul);
585 BOOST_REQUIRE_EQUAL(mul,3ul*2ul);
587 BOOST_REQUIRE_EQUAL(mul,3ul*2ul*5ul);
594 BOOST_AUTO_TEST_CASE( check_convert_function )
605 BOOST_REQUIRE_EQUAL(p.
get(0),1ul);
606 BOOST_REQUIRE_EQUAL(p.
get(1),(size_t)-1);
621 BOOST_REQUIRE_EQUAL(p.
get(0),1);
622 BOOST_REQUIRE_EQUAL(p.
get(1),-1);
623 BOOST_REQUIRE_EQUAL(p.
get(2),0);
629 BOOST_AUTO_TEST_SUITE_END()
It copy the properties from one object to another.
Transform the boost::fusion::vector into memory specification (memory_traits)
Position of the element of dimension d in the hyper-cube of dimension dim.
Main class to generate compile-time array.
check if T::type and T.data has the same type
static Point< dim, St > convert(const comb< dim > &c)
Return the combination converted to point.
This class implement the point shape in an N-dimensional space.
This is a container to create a general object.
This class check if the type T has pointers inside.
is_openfpm_native check if a type is an openfpm native structure type
T get(int i) const
Get coordinate.
this structure encapsulate an object of the grid
[Check has_posMask struct definition]
Struct that give functionalities on array extensions.
[Check has_posMask struct definition]
It create a boost::fusion vector with the selected properties.
Test structure used for several test.
Implementation of 1-D std::vector like structure.
char c[dim]
Array that store the combination.
It copy the properties from one object to another.