OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
variadic_to_vmpl_unit_test.hpp
1/*
2 * variadic_to_vmpl_unit_test.hpp
3 *
4 * Created on: Aug 19, 2015
5 * Author: i-bird
6 */
7
8#ifndef SRC_UTIL_VARIADIC_TO_VMPL_UNIT_TEST_HPP_
9#define SRC_UTIL_VARIADIC_TO_VMPL_UNIT_TEST_HPP_
10
11#include "util/variadic_to_vmpl.hpp"
12#include "util/util_debug.hpp"
13#include <typeinfo>
14
16template <typename T>
17struct F
18{
21};
23
25template <typename arg0, typename T>
26struct Ftwo
27{
30};
32
33BOOST_AUTO_TEST_CASE( variadic_to_vmpl_test)
34{
35 {
37
38 typedef boost::mpl::vector<float,float,float[3]> bfv;
39
40 // tbvf is boost::fusion::vector<scalar<float>,scalar<float>,scalar<float[3]>>
41 typedef v_transform<F,bfv>::type tbfv;
42
43 bool val = std::is_same<boost::mpl::at<tbfv,boost::mpl::int_<0>>::type,aggregate<float>>::value;
44 BOOST_REQUIRE_EQUAL(val,true);
45
46 val = std::is_same<boost::mpl::at<tbfv,boost::mpl::int_<1>>::type,aggregate<float>>::value;
47 BOOST_REQUIRE_EQUAL(val,true);
48
49 val = std::is_same<boost::mpl::at<tbfv,boost::mpl::int_<2>>::type,aggregate<float[3]>>::value;
50 BOOST_REQUIRE_EQUAL(val,true);
51
53 }
54
55 {
57
58 typedef boost::mpl::vector<float,float,float[3]> bfv;
59
60 // tbvf is boost::fusion::vector<scalar<float>,scalar<float>,scalar<float[3]>>
62
63 bool val = std::is_same<boost::mpl::at<tbfv,boost::mpl::int_<0>>::type,aggregate<float>>::value;
64 BOOST_REQUIRE_EQUAL(val,true);
65
66 val = std::is_same<boost::mpl::at<tbfv,boost::mpl::int_<1>>::type,aggregate<float>>::value;
67 BOOST_REQUIRE_EQUAL(val,true);
68
69 val = std::is_same<boost::mpl::at<tbfv,boost::mpl::int_<2>>::type,aggregate<float[3]>>::value;
70 BOOST_REQUIRE_EQUAL(val,true);
71
73 }
74
75 {
77
79
80 bool val = std::is_same<boost::mpl::at<bfv,boost::mpl::int_<0>>::type,boost::mpl::int_<1>>::value;
81 BOOST_REQUIRE_EQUAL(val,true);
82
83 val = std::is_same<boost::mpl::at<bfv,boost::mpl::int_<1>>::type,boost::mpl::int_<4>>::value;
84 BOOST_REQUIRE_EQUAL(val,true);
85
86 val = std::is_same<boost::mpl::at<bfv,boost::mpl::int_<2>>::type,boost::mpl::int_<5>>::value;
87 BOOST_REQUIRE_EQUAL(val,true);
88
89 val = std::is_same<boost::mpl::at<bfv,boost::mpl::int_<3>>::type,boost::mpl::int_<9>>::value;
90 BOOST_REQUIRE_EQUAL(val,true);
91
93 }
94
95 {
97
99
100 typedef vmpl_sum_constant<5,bfv>::type vsc;
101
102 BOOST_REQUIRE_EQUAL(boost::mpl::size<vsc>::type::value,4);
103
104 bool val = std::is_same<boost::mpl::at<vsc,boost::mpl::int_<0>>::type,boost::mpl::int_<6>>::value;
105 BOOST_REQUIRE_EQUAL(val,true);
106
107 val = std::is_same<boost::mpl::at<vsc,boost::mpl::int_<1>>::type,boost::mpl::int_<9>>::value;
108 BOOST_REQUIRE_EQUAL(val,true);
109
110 val = std::is_same<boost::mpl::at<vsc,boost::mpl::int_<2>>::type,boost::mpl::int_<10>>::value;
111 BOOST_REQUIRE_EQUAL(val,true);
112
113 val = std::is_same<boost::mpl::at<vsc,boost::mpl::int_<3>>::type,boost::mpl::int_<14>>::value;
114 BOOST_REQUIRE_EQUAL(val,true);
115
117 }
118}
119
120BOOST_AUTO_TEST_CASE( lin_vmpl_test )
121{
122 typedef boost::mpl::vector<boost::mpl::int_<16>,boost::mpl::int_<17>,boost::mpl::int_<18>> vector;
123
124 typedef boost::mpl::vector<boost::mpl::int_<1>,boost::mpl::int_<2>,boost::mpl::int_<3>> offset;
125
126 int lino = Lin_vmpl_off<vector,offset>(0,0,0);
127 int lin = Lin_vmpl<vector>(0,0,0);
128
129 BOOST_REQUIRE_EQUAL(lino,1+2*16+3*16*17);
130 BOOST_REQUIRE_EQUAL(lin,0);
131
132 lino = Lin_vmpl_off<vector,offset>(0,1,0);
133 lin = Lin_vmpl<vector>(0,1,0);
134
135 BOOST_REQUIRE_EQUAL(lino,1+3*16+3*16*17);
136 BOOST_REQUIRE_EQUAL(lin,16);
137
138 lino = Lin_vmpl_off<vector,offset>(0,0,1);
139 lin = Lin_vmpl<vector>(0,0,1);
140
141 BOOST_REQUIRE_EQUAL(lino,1+2*16+4*16*17);
142 BOOST_REQUIRE_EQUAL(lin,16*17);
143}
144
145#endif /* SRC_UTIL_VARIADIC_TO_VMPL_UNIT_TEST_HPP_ */
[v_transform metafunction]
aggregate< T > type
meta-function implementation
[v_transform metafunction]
aggregate< T > type
meta-function implementation
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
boost::mpl::vector< boost::mpl::int_< id >... > type
construct an mpl vector from the variadic
v_transform_two_impl< H, arg0, first, last, exit_::value >::type type
generate the boost::fusion::vector apply H on each term
v_transform_impl< H, first, last, exit_::value >::type type
generate the boost::fusion::vector apply H on each term