From 7cb2f2d4f1321c96439265699c44d91ae2bb1981 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com>
Date: Fri, 3 Jan 2020 21:51:52 +0100
Subject: [PATCH] Restoring setCompressedRowLengthsTest unit test for sparse
 matrices.

---
 src/UnitTests/Matrices/SparseMatrixTest.hpp   | 15 ++++-----------
 .../Matrices/SparseMatrixTest_CSR_segments.h  | 19 ++++++-------------
 .../SparseMatrixTest_SlicedEllpack_segments.h | 19 ++++++-------------
 3 files changed, 16 insertions(+), 37 deletions(-)

diff --git a/src/UnitTests/Matrices/SparseMatrixTest.hpp b/src/UnitTests/Matrices/SparseMatrixTest.hpp
index df06d28fc9..bf261aa846 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest.hpp
+++ b/src/UnitTests/Matrices/SparseMatrixTest.hpp
@@ -113,17 +113,10 @@ void test_SetCompressedRowLengths()
     for( IndexType i = 0; i < 8; i++ )      // 9th row
         m.setElement( 9, i, value++ );
 
-
-    EXPECT_EQ( m.getNonZeroRowLength( 0 ), 3 );
-    EXPECT_EQ( m.getNonZeroRowLength( 1 ), 3 );
-    EXPECT_EQ( m.getNonZeroRowLength( 2 ), 1 );
-    EXPECT_EQ( m.getNonZeroRowLength( 3 ), 2 );
-    EXPECT_EQ( m.getNonZeroRowLength( 4 ), 3 );
-    EXPECT_EQ( m.getNonZeroRowLength( 5 ), 4 );
-    EXPECT_EQ( m.getNonZeroRowLength( 6 ), 5 );
-    EXPECT_EQ( m.getNonZeroRowLength( 7 ), 6 );
-    EXPECT_EQ( m.getNonZeroRowLength( 8 ), 7 );
-    EXPECT_EQ( m.getNonZeroRowLength( 9 ), 8 );
+   rowLengths = 0;
+   m.getCompressedRowLengths( rowLengths );
+   typename Matrix::CompressedRowLengthsVector correctRowLengths{ 3, 3, 1, 2, 3, 4, 5, 6, 7, 8 };
+   EXPECT_EQ( rowLengths, correctRowLengths );
 }
 
 template< typename Matrix1, typename Matrix2 >
diff --git a/src/UnitTests/Matrices/SparseMatrixTest_CSR_segments.h b/src/UnitTests/Matrices/SparseMatrixTest_CSR_segments.h
index 34f7b4f704..5ac3dde267 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest_CSR_segments.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest_CSR_segments.h
@@ -66,19 +66,12 @@ TYPED_TEST( CSRMatrixTest, setDimensionsTest )
     test_SetDimensions< CSRMatrixType >();
 }
 
-//TYPED_TEST( CSRMatrixTest, setCompressedRowLengthsTest )
-//{
-////    using CSRMatrixType = typename TestFixture::CSRMatrixType;
-//
-////    test_SetCompressedRowLengths< CSRMatrixType >();
-//
-//    bool testRan = false;
-//    EXPECT_TRUE( testRan );
-//    std::cout << "\nTEST DID NOT RUN. NOT WORKING.\n\n";
-//    std::cout << "      This test is dependent on the input format. \n";
-//    std::cout << "      Almost every format allocates elements per row differently.\n\n";
-//    std::cout << "\n    TODO: Finish implementation of getNonZeroRowLength (Only non-zero elements, not the number of allocated elements.)\n\n";
-//}
+TYPED_TEST( CSRMatrixTest, setCompressedRowLengthsTest )
+{
+    using CSRMatrixType = typename TestFixture::CSRMatrixType;
+
+    test_SetCompressedRowLengths< CSRMatrixType >();
+}
 
 TYPED_TEST( CSRMatrixTest, setLikeTest )
 {
diff --git a/src/UnitTests/Matrices/SparseMatrixTest_SlicedEllpack_segments.h b/src/UnitTests/Matrices/SparseMatrixTest_SlicedEllpack_segments.h
index 8eba34a2bd..de5356f3a7 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest_SlicedEllpack_segments.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest_SlicedEllpack_segments.h
@@ -78,19 +78,12 @@ TYPED_TEST( SlicedEllpackMatrixTest, setDimensionsTest )
     test_SetDimensions< SlicedEllpackMatrixType >();
 }
 
-//TYPED_TEST( SlicedEllpackMatrixTest, setCompressedRowLengthsTest )
-//{
-////    using SlicedEllpackMatrixType = typename TestFixture::SlicedEllpackMatrixType;
-//
-////    test_SetCompressedRowLengths< SlicedEllpackMatrixType >();
-//
-//    bool testRan = false;
-//    EXPECT_TRUE( testRan );
-//    std::cout << "\nTEST DID NOT RUN. NOT WORKING.\n\n";
-//    std::cout << "      This test is dependent on the input format. \n";
-//    std::cout << "      Almost every format allocates elements per row differently.\n\n";
-//    std::cout << "\n    TODO: Finish implementation of getNonZeroRowLength (Only non-zero elements, not the number of allocated elements.)\n\n";
-//}
+TYPED_TEST( SlicedEllpackMatrixTest, setCompressedRowLengthsTest )
+{
+   using SlicedEllpackMatrixType = typename TestFixture::SlicedEllpackMatrixType;
+
+   test_SetCompressedRowLengths< SlicedEllpackMatrixType >();
+}
 
 TYPED_TEST( SlicedEllpackMatrixTest, setLikeTest )
 {
-- 
GitLab