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"
20 #include "util/convert.hpp"
22 #include "mul_array_extents.hpp"
23 #include "Packer_Unpacker/has_max_prop.hpp"
48 static constexpr
bool stag_mask[] = {
true,
false,
true};
69 static const std::string
name[2];
82 BOOST_AUTO_TEST_SUITE( util_test )
84 BOOST_AUTO_TEST_CASE( object_s_di_test )
98 boost::fusion::at_c<0>(src.data) = 1.0;
99 boost::fusion::at_c<1>(src.data) = 2.0;
101 for (
size_t i = 0 ; i < 3 ; i++)
102 boost::fusion::at_c<2>(src.data)[i] = i + 5.0;
108 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::x>(dst.data),1.0);
109 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::y>(dst.data),2.0);
111 for (
size_t i = 0 ; i < 3 ; i++)
112 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::v>(dst.data)[i],i + 5.0);
125 v_point_red.resize(2);
127 v_point_red.template get<0>(0) = 11.0;
128 v_point_red.template get<1>(0) = 12.0;
130 for (
size_t i = 0 ; i < 3 ; i++)
131 v_point_red.template get<2>(0)[i] = i + 15.0;
133 auto dst_e = v_point.get(0);
134 auto src_e = v_point_red.get(0);
138 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::x>(),11.0);
139 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::y>(),12.0);
141 for (
size_t i = 0 ; i < 3 ; i++)
142 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::v>()[i],i + 15.0);
147 BOOST_AUTO_TEST_CASE( object_s_di_op_test )
154 typedef object_creator<Point_test<float>::type,0,1,4>::type vboost_red;
161 boost::fusion::at_c<0>(src.data) = 1.0;
162 boost::fusion::at_c<1>(src.data) = 2.0;
164 for (
size_t i = 0 ; i < 3 ; i++)
165 boost::fusion::at_c<2>(src.data)[i] = i + 5.0;
167 boost::fusion::at_c<0>(dst.data) = 2.0;
168 boost::fusion::at_c<1>(dst.data) = 3.0;
170 for (
size_t i = 0 ; i < 3 ; i++)
171 boost::fusion::at_c<4>(dst.data)[i] = i + 7.0;
177 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::x>(dst.data),3.0);
178 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::y>(dst.data),5.0);
180 for (
size_t i = 0 ; i < 3 ; i++)
181 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::v>(dst.data)[i],2*i + 12.0);
194 v_point_red.resize(2);
196 v_point_red.template get<0>(0) = 11.0;
197 v_point_red.template get<1>(0) = 12.0;
199 v_point.template get<0>(0) = 10.0;
200 v_point.template get<1>(0) = 9.0;
202 for (
size_t i = 0 ; i < 3 ; i++)
203 v_point_red.template get<2>(0)[i] = i + 8.0;
205 for (
size_t i = 0 ; i < 3 ; i++)
206 v_point.template get<4>(0)[i] = i + 3.0;
208 auto dst_e = v_point.get(0);
209 auto src_e = v_point_red.get(0);
213 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::x>(),21.0);
214 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::y>(),21.0);
216 for (
size_t i = 0 ; i < 3 ; i++)
217 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::v>()[i],2*i + 11.0);
222 BOOST_AUTO_TEST_CASE( object_prop_copy )
228 typedef object_creator<Point_test<float>::type,0,1,4>::type vboost_red;
235 boost::fusion::at_c<p::x>(src.data) = 1.0;
236 boost::fusion::at_c<p::y>(src.data) = 2.0;
238 for (
size_t i = 0 ; i < 3 ; i++)
239 boost::fusion::at_c<p::v>(src.data)[i] = i + 5.0;
245 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<0>(dst.data),1.0);
246 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<1>(dst.data),2.0);
248 for (
size_t i = 0 ; i < 3 ; i++)
249 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<2>(dst.data)[i],i + 5.0);
262 v_point_red.resize(2);
264 v_point.template get<p::x>(0) = 1.0;
265 v_point.template get<p::y>(0) = 2.0;
267 for (
size_t i = 0 ; i < 3 ; i++)
268 v_point.template get<p::v>(0)[i] = i + 5.0;
270 auto src_e = v_point.get(0);
271 auto dst_e = v_point_red.get(0);
275 BOOST_REQUIRE_EQUAL(v_point_red.get(0).template get<0>(),1.0);
276 BOOST_REQUIRE_EQUAL(v_point_red.get(0).template get<1>(),2.0);
278 for (
size_t i = 0 ; i < 3 ; i++)
279 BOOST_REQUIRE_EQUAL(v_point_red.get(0).template get<2>()[i],i + 5.0);
287 struct no_method_pointer
298 static bool noPointers() {
return true;}
306 static bool noPointers() {
return false;}
309 typedef boost::fusion::vector<int,float,double,no_method_pointer,no_pointer,with_pointer,no_method_pointer> v;
311 int val = boost::mpl::size< noPointers_sequence<v,0,2>::type >::value;
312 BOOST_REQUIRE_EQUAL(val,0);
314 val = boost::mpl::size< noPointers_sequence<v,0,2,4,5>::type >::value;
315 BOOST_REQUIRE_EQUAL(val,0);
317 val = boost::mpl::size< noPointers_sequence<v,0,1,2,3,4,5,6>::type >::value;
318 BOOST_REQUIRE_EQUAL(val,2);
320 typedef boost::fusion::vector<int *,float &,double *,no_method_pointer *,no_pointer &,with_pointer *,no_method_pointer &> vp;
322 val = boost::mpl::size< noPointers_sequence<vp,0,1,2,3,4,5,6>::type >::value;
323 BOOST_REQUIRE_EQUAL(val,2);
331 struct no_method_pointer
342 static bool noPointers() {
return true;}
350 static bool noPointers() {
return false;}
353 typedef boost::fusion::vector<int,float,double> v;
355 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
357 typedef boost::fusion::vector<int,float,double,no_pointer> va;
359 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
361 typedef boost::fusion::vector<int,float,double,no_pointer,with_pointer> vb;
363 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
365 typedef boost::fusion::vector<int,float,double,no_pointer,double *> vc;
367 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
369 typedef boost::fusion::vector<int,float,double,no_pointer,double &> vd;
371 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
373 typedef boost::fusion::vector<int,float,double,no_pointer,double[3]> ve;
375 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
377 typedef boost::fusion::vector<int,float,double,no_pointer,no_pointer *> vf;
379 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
381 typedef boost::fusion::vector<int,float,double,no_pointer,no_pointer &> vg;
383 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
385 typedef boost::fusion::vector<int,float,double,no_pointer,no_pointer[3]> vh;
387 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
396 const size_t count = 5;
397 typedef typename ::generate_array<size_t,count, MetaFunc>::result ct_test;
401 for (
size_t i = 0 ; i < count; ++i)
403 const size_t ct_val = ct_test::data[i];
404 BOOST_REQUIRE_EQUAL(ct_val,count+i);
415 const size_t count = 5;
416 typedef typename ::generate_array_constexpr<size_t,count, MetaFunc>::result ct_test_ce;
421 BOOST_REQUIRE_EQUAL(ct_calc,11ul);
430 const size_t count = 5;
431 typedef typename ::generate_indexes<size_t,count, MetaFuncOrd>::result ct_test_ce;
433 bool check = std::is_same<ct_test_ce,index_tuple<0,1,2,3,4>>::value;
434 BOOST_REQUIRE_EQUAL(check,
true);
439 BOOST_AUTO_TEST_CASE( check_templates_util_function )
448 static bool pack() {
return true;}
451 struct test_unknown_pack
460 struct test_packRequest
462 static bool packRequest() {
return false;}
465 struct test_unknown_packRequest
476 static bool packMem() {
return true;}
479 struct test_unknown_packMem
491 static bool noPointers() {
return true;}
496 static bool noPointers() {
return false;}
515 BOOST_REQUIRE_EQUAL(val,
true);
517 BOOST_REQUIRE_EQUAL(val,
false);
525 struct test_typedef_same_data
527 typedef boost::fusion::vector<float,double,float[3]> type;
532 struct test_typedef_not_same_data
534 typedef boost::fusion::vector<float,double,float[3]> type;
536 boost::fusion::vector<float,double> data;
540 BOOST_REQUIRE_EQUAL(val,
true);
542 BOOST_REQUIRE_EQUAL(val,
false);
555 struct test_no_has_data
560 BOOST_REQUIRE_EQUAL(val,
true);
562 BOOST_REQUIRE_EQUAL(val,
false);
571 BOOST_REQUIRE_EQUAL(val,
true);
573 BOOST_REQUIRE_EQUAL(val,
false);
577 BOOST_REQUIRE_EQUAL(val,
true);
580 BOOST_REQUIRE_EQUAL(val, 3);
589 struct test_has_value_type
591 typedef int value_type;
594 struct test_has_no_value_type
600 BOOST_REQUIRE_EQUAL(val,
true);
602 BOOST_REQUIRE_EQUAL(val,
false);
612 BOOST_REQUIRE_EQUAL(val,
true);
614 BOOST_REQUIRE_EQUAL(val,
false);
622 struct test_has_typedef
627 struct test_no_has_data
632 BOOST_REQUIRE_EQUAL(val,
true);
634 BOOST_REQUIRE_EQUAL(val,
false);
643 BOOST_REQUIRE_EQUAL(val,
true);
645 BOOST_REQUIRE_EQUAL(val,
false);
653 static bool noPointers() {
return PNP::NO_POINTERS;}
658 static bool noPointers() {
return PNP::POINTERS;}
666 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
668 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
670 BOOST_REQUIRE_EQUAL(val,PNP::UNKNOWN);
684 BOOST_REQUIRE_EQUAL( val ,
true);
686 BOOST_REQUIRE_EQUAL( val ,
true);
688 BOOST_REQUIRE_EQUAL( val ,
true);
691 BOOST_REQUIRE_EQUAL(val ,
true);
693 BOOST_REQUIRE_EQUAL(val,
true);
695 BOOST_REQUIRE_EQUAL(val,
true);
698 BOOST_REQUIRE_EQUAL( val,
false);
700 BOOST_REQUIRE_EQUAL( val,
false);
715 BOOST_REQUIRE_EQUAL( val ,
true);
717 BOOST_REQUIRE_EQUAL( val ,
true);
719 BOOST_REQUIRE_EQUAL( val ,
true);
722 BOOST_REQUIRE_EQUAL(val ,
true);
724 BOOST_REQUIRE_EQUAL(val,
true);
726 BOOST_REQUIRE_EQUAL(val,
true);
729 BOOST_REQUIRE_EQUAL( val,
false);
731 BOOST_REQUIRE_EQUAL( val,
false);
746 BOOST_REQUIRE_EQUAL( val ,
true);
748 BOOST_REQUIRE_EQUAL( val ,
true);
750 BOOST_REQUIRE_EQUAL( val ,
true);
753 BOOST_REQUIRE_EQUAL( val ,
true);
755 BOOST_REQUIRE_EQUAL( val ,
true);
757 BOOST_REQUIRE_EQUAL( val ,
true);
760 BOOST_REQUIRE_EQUAL( val,
false);
762 BOOST_REQUIRE_EQUAL( val,
false);
771 BOOST_REQUIRE_EQUAL(mul,1ul);
773 BOOST_REQUIRE_EQUAL(mul,3ul);
775 BOOST_REQUIRE_EQUAL(mul,3ul*2ul);
777 BOOST_REQUIRE_EQUAL(mul,3ul*2ul*5ul);
786 BOOST_REQUIRE_EQUAL(val,
true);
788 BOOST_REQUIRE_EQUAL(val,
false);
791 BOOST_REQUIRE_EQUAL(val,
false);
793 BOOST_REQUIRE_EQUAL(val,
true);
804 BOOST_REQUIRE_EQUAL(val,
true);
810 BOOST_REQUIRE_EQUAL(val,
false);
818 BOOST_AUTO_TEST_CASE( check_convert_function )
829 BOOST_REQUIRE_EQUAL(p.
get(0),1ul);
830 BOOST_REQUIRE_EQUAL(p.
get(1),(size_t)-1);
845 BOOST_REQUIRE_EQUAL(p.
get(0),1);
846 BOOST_REQUIRE_EQUAL(p.
get(1),-1);
847 BOOST_REQUIRE_EQUAL(p.
get(2),0);
854 BOOST_AUTO_TEST_CASE( is_contiguos_test)
859 BOOST_REQUIRE_EQUAL(test,
true);
863 BOOST_REQUIRE_EQUAL(test,
false);
867 BOOST_REQUIRE_EQUAL(test,
true);
871 BOOST_REQUIRE_EQUAL(test,
false);
875 BOOST_REQUIRE_EQUAL(test,
false);
879 BOOST_REQUIRE_EQUAL(test,
false);
884 BOOST_AUTO_TEST_SUITE_END()
It copy the properties from one object to another.
Transform the boost::fusion::vector into memory specification (memory_traits)
boost::fusion::vector< T, T, T, T, T[3], T[3][3]> type
declaration of what the Point_test store
Position of the element of dimension d in the hyper-cube of dimension dim.
has_Pack check if a type has defined a method called Pack
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.
has_packRequest check if a type has defined a method called packRequest
This class implement the point shape in an N-dimensional space.
This is a container to create a general object.
static const unsigned int max_prop
define that the type has 6 properties
Transform the boost::fusion::vector into memory specification (memory_traits)
This class check if the type T has pointers inside.
is_openfpm_native check if a type is an openfpm native structure type
static const std::string name[2]
This test structure has 2 attribute names.
static constexpr bool stag_mask[]
staggered mask
It model an expression expr1 * expr2.
test type for has_max_prop
It copy the properties from one object to another applying an operation.
const T & get(size_t i) const
Get coordinate.
test type for has_max_prop
return if true the aggregate type T has a property that has a complex packing(serialization) method ...
[Check has_posMask struct definition]
Struct that give functionalities on array extensions.
has_calculateMem check if a type has defined a method called calculateMem
[Check has_posMask struct definition]
It create a boost::fusion vector with the selected properties.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Test structure used for several test.
Implementation of 1-D std::vector like structure.
test type for has_posMask
static size_t value()
Return true if the structure T has a pointer.
char c[dim]
Array that store the combination.
It copy the properties from one object to another.