12 #include "util/object_util.hpp" 13 #include "Point_test.hpp" 14 #include "util/ct_array.hpp" 15 #include "Vector/map_vector.hpp" 16 #include "util/common.hpp" 17 #include "util/check_no_pointers.hpp" 18 #include "Grid/util.hpp" 20 #include "util/convert.hpp" 22 #include "util/mul_array_extents.hpp" 23 #include "Packer_Unpacker/has_max_prop.hpp" 24 #include "SparseGrid/SparseGrid.hpp" 49 static constexpr
bool stag_mask[] = {
true,
false,
true};
70 static const std::string
name[2];
83 BOOST_AUTO_TEST_SUITE( util_test )
85 BOOST_AUTO_TEST_CASE( object_s_di_test )
99 boost::fusion::at_c<0>(src.data) = 1.0;
100 boost::fusion::at_c<1>(src.data) = 2.0;
102 for (
size_t i = 0 ; i < 3 ; i++)
103 boost::fusion::at_c<2>(src.data)[i] = i + 5.0;
109 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::x>(dst.data),1.0);
110 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::y>(dst.data),2.0);
112 for (
size_t i = 0 ; i < 3 ; i++)
113 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::v>(dst.data)[i],i + 5.0);
126 v_point_red.resize(2);
128 v_point_red.template get<0>(0) = 11.0;
129 v_point_red.template get<1>(0) = 12.0;
131 for (
size_t i = 0 ; i < 3 ; i++)
132 v_point_red.template get<2>(0)[i] = i + 15.0;
134 auto dst_e = v_point.get(0);
135 auto src_e = v_point_red.get(0);
139 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::x>(),11.0);
140 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::y>(),12.0);
142 for (
size_t i = 0 ; i < 3 ; i++)
143 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::v>()[i],i + 15.0);
148 BOOST_AUTO_TEST_CASE( object_s_di_op_test )
162 boost::fusion::at_c<0>(src.data) = 1.0;
163 boost::fusion::at_c<1>(src.data) = 2.0;
165 for (
size_t i = 0 ; i < 3 ; i++)
166 boost::fusion::at_c<2>(src.data)[i] = i + 5.0;
168 boost::fusion::at_c<0>(dst.data) = 2.0;
169 boost::fusion::at_c<1>(dst.data) = 3.0;
171 for (
size_t i = 0 ; i < 3 ; i++)
172 boost::fusion::at_c<4>(dst.data)[i] = i + 7.0;
178 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::x>(dst.data),3.0);
179 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::y>(dst.data),5.0);
181 for (
size_t i = 0 ; i < 3 ; i++)
182 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::v>(dst.data)[i],2*i + 12.0);
195 v_point_red.resize(2);
197 v_point_red.template get<0>(0) = 11.0;
198 v_point_red.template get<1>(0) = 12.0;
200 v_point.template get<0>(0) = 10.0;
201 v_point.template get<1>(0) = 9.0;
203 for (
size_t i = 0 ; i < 3 ; i++)
204 v_point_red.template get<2>(0)[i] = i + 8.0;
206 for (
size_t i = 0 ; i < 3 ; i++)
207 v_point.template get<4>(0)[i] = i + 3.0;
209 auto dst_e = v_point.get(0);
210 auto src_e = v_point_red.get(0);
214 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::x>(),21.0);
215 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::y>(),21.0);
217 for (
size_t i = 0 ; i < 3 ; i++)
218 BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::v>()[i],2*i + 11.0);
223 BOOST_AUTO_TEST_CASE( object_prop_copy )
236 boost::fusion::at_c<p::x>(src.data) = 1.0;
237 boost::fusion::at_c<p::y>(src.data) = 2.0;
239 for (
size_t i = 0 ; i < 3 ; i++)
240 boost::fusion::at_c<p::v>(src.data)[i] = i + 5.0;
246 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<0>(dst.data),1.0);
247 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<1>(dst.data),2.0);
249 for (
size_t i = 0 ; i < 3 ; i++)
250 BOOST_REQUIRE_EQUAL(boost::fusion::at_c<2>(dst.data)[i],i + 5.0);
263 v_point_red.resize(2);
265 v_point.template get<p::x>(0) = 1.0;
266 v_point.template get<p::y>(0) = 2.0;
268 for (
size_t i = 0 ; i < 3 ; i++)
269 v_point.template get<p::v>(0)[i] = i + 5.0;
271 auto src_e = v_point.get(0);
272 auto dst_e = v_point_red.get(0);
276 BOOST_REQUIRE_EQUAL(v_point_red.get(0).template get<0>(),1.0);
277 BOOST_REQUIRE_EQUAL(v_point_red.get(0).template get<1>(),2.0);
279 for (
size_t i = 0 ; i < 3 ; i++)
280 BOOST_REQUIRE_EQUAL(v_point_red.get(0).template get<2>()[i],i + 5.0);
288 struct no_method_pointer
299 static bool noPointers() {
return true;}
307 static bool noPointers() {
return false;}
310 typedef boost::fusion::vector<int,float,double,no_method_pointer,no_pointer,with_pointer,no_method_pointer> v;
312 int val = boost::mpl::size< noPointers_sequence<v,0,2>::type >::value;
313 BOOST_REQUIRE_EQUAL(val,0);
315 val = boost::mpl::size< noPointers_sequence<v,0,2,4,5>::type >::value;
316 BOOST_REQUIRE_EQUAL(val,0);
318 val = boost::mpl::size< noPointers_sequence<v,0,1,2,3,4,5,6>::type >::value;
319 BOOST_REQUIRE_EQUAL(val,2);
321 typedef boost::fusion::vector<int *,float &,double *,no_method_pointer *,no_pointer &,with_pointer *,no_method_pointer &> vp;
323 val = boost::mpl::size< noPointers_sequence<vp,0,1,2,3,4,5,6>::type >::value;
324 BOOST_REQUIRE_EQUAL(val,2);
332 struct no_method_pointer
343 static bool noPointers() {
return true;}
351 static bool noPointers() {
return false;}
354 typedef boost::fusion::vector<int,float,double> v;
356 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
358 typedef boost::fusion::vector<int,float,double,no_pointer> va;
360 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
362 typedef boost::fusion::vector<int,float,double,no_pointer,with_pointer> vb;
364 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
366 typedef boost::fusion::vector<int,float,double,no_pointer,double *> vc;
368 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
370 typedef boost::fusion::vector<int,float,double,no_pointer,double &> vd;
372 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
374 typedef boost::fusion::vector<int,float,double,no_pointer,double[3]> ve;
376 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
378 typedef boost::fusion::vector<int,float,double,no_pointer,no_pointer *> vf;
380 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
382 typedef boost::fusion::vector<int,float,double,no_pointer,no_pointer &> vg;
384 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
386 typedef boost::fusion::vector<int,float,double,no_pointer,no_pointer[3]> vh;
388 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
397 const size_t count = 5;
398 typedef typename ::generate_array<size_t,count, MetaFunc>::result ct_test;
402 for (
size_t i = 0 ; i < count; ++i)
404 const size_t ct_val = ct_test::data[i];
405 BOOST_REQUIRE_EQUAL(ct_val,count+i);
413 #if __CUDACC_VER_MAJOR__ >= 9 416 const size_t count = 5;
417 typedef typename ::generate_array_constexpr<size_t,count, MetaFunc>::result ct_test_ce;
422 BOOST_REQUIRE_EQUAL(ct_calc,11ul);
432 const size_t count = 5;
433 typedef typename ::generate_indexes<size_t,count, MetaFuncOrd>::result ct_test_ce;
435 bool check = std::is_same<ct_test_ce,index_tuple<0,1,2,3,4>>::value;
436 BOOST_REQUIRE_EQUAL(check,
true);
441 BOOST_AUTO_TEST_CASE( check_templates_util_function )
450 static bool pack() {
return true;}
453 struct test_unknown_pack
462 struct test_packRequest
464 static bool packRequest() {
return false;}
467 struct test_unknown_packRequest
478 static bool packMem() {
return true;}
481 struct test_unknown_packMem
493 static bool noPointers() {
return true;}
498 static bool noPointers() {
return false;}
517 BOOST_REQUIRE_EQUAL(val,
true);
519 BOOST_REQUIRE_EQUAL(val,
false);
527 struct test_typedef_same_data
529 typedef boost::fusion::vector<float,double,float[3]> type;
534 struct test_typedef_not_same_data
536 typedef boost::fusion::vector<float,double,float[3]> type;
538 boost::fusion::vector<float,double> data;
542 BOOST_REQUIRE_EQUAL(val,
true);
544 BOOST_REQUIRE_EQUAL(val,
false);
557 struct test_no_has_data
562 BOOST_REQUIRE_EQUAL(val,
true);
564 BOOST_REQUIRE_EQUAL(val,
false);
573 BOOST_REQUIRE_EQUAL(val,
true);
575 BOOST_REQUIRE_EQUAL(val,
false);
579 BOOST_REQUIRE_EQUAL(val,
true);
582 BOOST_REQUIRE_EQUAL(val, 3);
591 struct test_has_value_type_ofp
593 typedef int value_type;
596 struct test_has_no_value_type
602 BOOST_REQUIRE_EQUAL(val,
true);
604 BOOST_REQUIRE_EQUAL(val,
false);
614 BOOST_REQUIRE_EQUAL(val,
true);
616 BOOST_REQUIRE_EQUAL(val,
false);
624 struct test_has_typedef
629 struct test_no_has_data
634 BOOST_REQUIRE_EQUAL(val,
true);
636 BOOST_REQUIRE_EQUAL(val,
false);
645 BOOST_REQUIRE_EQUAL(val,
true);
647 BOOST_REQUIRE_EQUAL(val,
false);
655 static bool noPointers() {
return PNP::NO_POINTERS;}
660 static bool noPointers() {
return PNP::POINTERS;}
668 BOOST_REQUIRE_EQUAL(val,PNP::NO_POINTERS);
670 BOOST_REQUIRE_EQUAL(val,PNP::POINTERS);
672 BOOST_REQUIRE_EQUAL(val,PNP::UNKNOWN);
686 BOOST_REQUIRE_EQUAL( val ,
true);
688 BOOST_REQUIRE_EQUAL( val ,
true);
690 BOOST_REQUIRE_EQUAL( val ,
true);
693 BOOST_REQUIRE_EQUAL(val ,
true);
695 BOOST_REQUIRE_EQUAL(val,
true);
697 BOOST_REQUIRE_EQUAL(val,
true);
700 BOOST_REQUIRE_EQUAL( val,
false);
702 BOOST_REQUIRE_EQUAL( val,
false);
717 BOOST_REQUIRE_EQUAL( val ,
true);
719 BOOST_REQUIRE_EQUAL( val ,
true);
721 BOOST_REQUIRE_EQUAL( val ,
true);
724 BOOST_REQUIRE_EQUAL(val ,
true);
726 BOOST_REQUIRE_EQUAL(val,
true);
728 BOOST_REQUIRE_EQUAL(val,
true);
731 BOOST_REQUIRE_EQUAL( val,
false);
733 BOOST_REQUIRE_EQUAL( val,
false);
748 BOOST_REQUIRE_EQUAL( val ,
true);
750 BOOST_REQUIRE_EQUAL( val ,
true);
752 BOOST_REQUIRE_EQUAL( val ,
true);
755 BOOST_REQUIRE_EQUAL( val ,
true);
757 BOOST_REQUIRE_EQUAL( val ,
true);
759 BOOST_REQUIRE_EQUAL( val ,
true);
762 BOOST_REQUIRE_EQUAL( val,
false);
764 BOOST_REQUIRE_EQUAL( val,
false);
773 BOOST_REQUIRE_EQUAL(
mul,1ul);
775 BOOST_REQUIRE_EQUAL(
mul,3ul);
777 BOOST_REQUIRE_EQUAL(
mul,3ul*2ul);
779 BOOST_REQUIRE_EQUAL(
mul,3ul*2ul*5ul);
788 BOOST_REQUIRE_EQUAL(val,
true);
790 BOOST_REQUIRE_EQUAL(val,
false);
793 BOOST_REQUIRE_EQUAL(val,
false);
795 BOOST_REQUIRE_EQUAL(val,
true);
806 BOOST_REQUIRE_EQUAL(val,
true);
812 BOOST_REQUIRE_EQUAL(val,
false);
818 BOOST_REQUIRE_EQUAL(val,
true);
826 BOOST_AUTO_TEST_CASE( check_convert_function )
837 BOOST_REQUIRE_EQUAL(p.
get(0),1ul);
838 BOOST_REQUIRE_EQUAL(p.
get(1),(size_t)-1);
853 BOOST_REQUIRE_EQUAL(p.
get(0),1);
854 BOOST_REQUIRE_EQUAL(p.
get(1),-1);
855 BOOST_REQUIRE_EQUAL(p.
get(2),0);
862 BOOST_AUTO_TEST_CASE( is_contiguos_test)
867 BOOST_REQUIRE_EQUAL(test,
true);
871 BOOST_REQUIRE_EQUAL(test,
false);
875 BOOST_REQUIRE_EQUAL(test,
true);
879 BOOST_REQUIRE_EQUAL(test,
false);
883 BOOST_REQUIRE_EQUAL(test,
false);
887 BOOST_REQUIRE_EQUAL(test,
false);
891 BOOST_AUTO_TEST_CASE( dyn_struct_check )
897 BOOST_REQUIRE_EQUAL(test,
false);
903 BOOST_REQUIRE_EQUAL(test,
false);
909 BOOST_REQUIRE_EQUAL(test,
true);
915 BOOST_REQUIRE_EQUAL(test,
false);
918 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 class allocate, and destroy CPU memory.
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.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
test type for has_max_prop
It copy the properties from one object to another applying an operation.
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.