aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/stl_iterators.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2018-10-03 11:56:27 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2018-10-03 11:56:27 +0200
commit8a1e98240e6ac9f3456953b9e0b220c803acf9ed (patch)
tree4d702ac17633befb15efc8917650095d8102645f /test/stl_iterators.cpp
parent5f26f57598b4f795cdaf5797fdb33f0e948cc81c (diff)
add unit tests
Diffstat (limited to 'test/stl_iterators.cpp')
-rw-r--r--test/stl_iterators.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/stl_iterators.cpp b/test/stl_iterators.cpp
index 4e04d28b7..5d501dcd6 100644
--- a/test/stl_iterators.cpp
+++ b/test/stl_iterators.cpp
@@ -30,6 +30,7 @@ void test_range_for_loop(int rows=Rows, int cols=Cols)
using std::end;
typedef Matrix<Scalar,Rows,1> VectorType;
+ typedef Matrix<Scalar,1,Cols> RowVectorType;
typedef Matrix<Scalar,Rows,Cols,ColMajor> ColMatrixType;
typedef Matrix<Scalar,Rows,Cols,RowMajor> RowMatrixType;
VectorType v = VectorType::Random(rows);
@@ -62,6 +63,9 @@ void test_range_for_loop(int rows=Rows, int cols=Cols)
VERIFY( is_PointerBasedStlIterator(cA.reshaped().begin()) );
VERIFY( is_PointerBasedStlIterator(cA.reshaped().end()) );
+ VERIFY( is_PointerBasedStlIterator(B.template reshaped<AutoOrder>().begin()) );
+ VERIFY( is_PointerBasedStlIterator(B.template reshaped<AutoOrder>().end()) );
+
VERIFY( is_DenseStlIterator(A.template reshaped<RowMajor>().begin()) );
VERIFY( is_DenseStlIterator(A.template reshaped<RowMajor>().end()) );
@@ -252,6 +256,17 @@ void test_range_for_loop(int rows=Rows, int cols=Cols)
i = 0;
for(auto r : B.allRows()) { VERIFY_IS_APPROX(r.sum(), B.row(i).sum()); ++i; }
+
+ {
+ RowVectorType row = RowVectorType::Random(cols);
+ A.rowwise() = row;
+ VERIFY( std::all_of(A.allRows().begin(), A.allRows().end(), [&row](typename ColMatrixType::RowXpr x) { return internal::isApprox(x.norm(),row.norm()); }) );
+
+ VectorType col = VectorType::Random(rows);
+ A.colwise() = col;
+ VERIFY( std::all_of(A.allCols().begin(), A.allCols().end(), [&col](typename ColMatrixType::ColXpr x) { return internal::isApprox(x.norm(),col.norm()); }) );
+ }
+
#endif
}