From 8a1e98240e6ac9f3456953b9e0b220c803acf9ed Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 3 Oct 2018 11:56:27 +0200 Subject: add unit tests --- test/stl_iterators.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/stl_iterators.cpp') 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 VectorType; + typedef Matrix RowVectorType; typedef Matrix ColMatrixType; typedef Matrix 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().begin()) ); + VERIFY( is_PointerBasedStlIterator(B.template reshaped().end()) ); + VERIFY( is_DenseStlIterator(A.template reshaped().begin()) ); VERIFY( is_DenseStlIterator(A.template reshaped().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 } -- cgit v1.2.3