rvalue_return_test.cpp
Go to the documentation of this file.
1 #include <typeinfo>
2 #include <boost/type_traits/is_same.hpp>
4 #include <gtest/gtest.h>
5 
15 
16 typedef std::vector<double> doubles;
17 typedef std::vector<doubles> doubless;
18 
19 typedef Eigen::MatrixXd mat;
20 typedef std::vector<mat> mats;
21 typedef std::vector<mats> matss;
22 
23 typedef Eigen::VectorXd vec;
24 typedef std::vector<vec> vecs;
25 typedef std::vector<vecs> vecss;
26 
27 typedef Eigen::RowVectorXd rowvec;
28 typedef std::vector<rowvec> rowvecs;
29 typedef std::vector<rowvecs> rowvecss;
30 
33 
38 
47 
48 template <typename T, typename C, typename I>
49 void expect_same() {
50  EXPECT_TRUE(( boost::is_same<T,
51  typename rvalue_return<C, I>::type>::value ))
52  << "type(T)=" << typeid(T).name() << std::endl
53  << "type(C)=" << typeid(C).name() << std::endl
54  << "type(I)=" << typeid(I).name() << std::endl
55  << "rvalue_return=" << typeid(typename rvalue_return<C, I>::type).name()
56  << std::endl
57  << std::endl;
58 }
59 
60 // EXHAUSTIVE TESTS OF ALL INDEXING UP TO 2nd ORDER
61 
62 TEST(modelIndexing,rvalueReturnNil) {
63  expect_same<double,
64  double, nil_index_list>();
70  mat, nil_index_list>();
72  mats, nil_index_list>();
76  vec, nil_index_list>();
78  vecs, nil_index_list>();
87 }
88 
89 TEST(modelIndex, rvalueReturnUni) {
90  expect_same<double,
91  doubles, uni>();
93  doubless, uni>();
94  expect_same<double,
95  vec, uni>();
97  vecs, uni>();
99  vecss, uni>();
100  expect_same<double,
101  rowvec, uni>();
103  rowvecs, uni>();
105  rowvecss, uni>();
107  mat, uni>();
109  mats, uni>();
111  matss, uni>();
112 }
113 
114 TEST(modelIndex, rvalueReturnMulti) {
116  doubles, multi>();
118  doubless, multi>();
120  mats, multi>();
122  matss, multi>();
124  vecs, multi>();
126  vecss, multi>();
128  rowvecs, multi>();
130  rowvecss, multi>();
131 }
132 
133 TEST(modelIndex, rvalueReturnUniUni) {
134  expect_same<double,
135  doubless, uni_uni>();
136  expect_same<double,
137  vecs, uni_uni>();
139  vecss, uni_uni>();
140  expect_same<double,
141  rowvecs, uni_uni>();
143  rowvecss, uni_uni>();
144  expect_same<double,
145  mat, uni_uni>();
147  mats, uni_uni>();
149  matss, uni_uni>();
150 }
151 
152 TEST(modelIndex, rvalueReturnUniMulti) {
154  doubless, uni_multi>();
156  vecs, uni_multi>();
158  vecss, uni_multi>();
160  rowvecs, uni_multi>();
162  rowvecss, uni_multi>();
164  mat, uni_multi>();
166  mats, uni_multi>();
168  matss, uni_multi>();
169 }
170 
171 TEST(modelIndex, rvalueReturnMultiUni) {
173  doubless, multi_uni>();
175  vecs, multi_uni>();
177  vecss, multi_uni>();
179  rowvecs, multi_uni>();
181  rowvecss, multi_uni>();
183  mat, multi_uni>();
185  mats, multi_uni>();
187  matss, multi_uni>();
188 }
189 
190 TEST(modelIndex, rvalueReturnMultiMulti) {
192  doubless, multi_multi>();
194  vecs, multi_multi>();
196  vecss, multi_multi>();
198  rowvecs, multi_multi>();
200  rowvecss, multi_multi>();
202  mat, multi_multi>();
204  mats, multi_multi>();
206  matss, multi_multi>();
207 }
const XML_Char * name
Definition: expat.h:151
cons_index_list< index_multi, nil_index_list > multi
cons_index_list< index_uni, multi > uni_multi
std::vector< mats > matss
cons_index_list< index_uni, uni_multi > uni_uni_multi
cons_index_list< index_multi, multi > multi_multi
Eigen::RowVectorXd rowvec
cons_index_list< index_multi, multi_uni > multi_multi_uni
std::vector< doubles > doubless
const double C
std::vector< mat > mats
cons_index_list< index_uni, uni > uni_uni
cons_index_list< index_uni, multi_uni > uni_multi_uni
const XML_Char int const XML_Char * value
Definition: expat.h:331
cons_index_list< index_uni, multi_multi > uni_multi_multi
Eigen::VectorXd vec
std::vector< rowvecs > rowvecss
cons_index_list< index_multi, uni_multi > multi_uni_multi
cons_index_list< index_multi, multi_multi > multi_multi_multi
TEST(modelIndexing, rvalueReturnNil)
cons_index_list< index_uni, uni_uni > uni_uni_uni
std::vector< vecs > vecss
std::vector< rowvec > rowvecs
cons_index_list< index_multi, uni > multi_uni
std::vector< vec > vecs
double T
Definition: Xdiff_gwt.C:5
cons_index_list< index_uni, nil_index_list > uni
cons_index_list< index_multi, uni_uni > multi_uni_uni
Eigen::MatrixXd mat
void expect_same()
std::vector< double > doubles