From 26a2d4449ea28ae533ba225ce23ecc638b20fbd2 Mon Sep 17 00:00:00 2001
From: Lukas Cejka <lukas.ostatek@gmail.com>
Date: Sun, 4 Nov 2018 17:55:45 +0100
Subject: [PATCH] Added test for setLike function, but only for Dimension
 comparison. 	Added TODOs to implement rowPointer test for
 setCompressedRowLengths and setDimensions test functions.

---
 src/UnitTests/Matrices/SparseMatrixTest.h | 39 +++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/UnitTests/Matrices/SparseMatrixTest.h b/src/UnitTests/Matrices/SparseMatrixTest.h
index 3104b51782..50e010d92a 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest.h
@@ -56,6 +56,8 @@ void test_SetDimensions()
     
     EXPECT_EQ( m.getRows(), 9);
     EXPECT_EQ( m.getColumns(), 8);
+    
+    // TODO: Implement rowPointers test.
 }
 
 template< typename Matrix >
@@ -86,6 +88,31 @@ void test_SetCompressedRowLengths()
     EXPECT_EQ( m.getRowLength( 7), 6 );
     EXPECT_EQ( m.getRowLength( 8), 7 );
     EXPECT_EQ( m.getRowLength( 9), 8 );
+    
+    // TOOD: Implement rowPointers test.
+}
+
+template< typename Matrix1, typename Matrix2 >
+void test_SetLike()
+{
+    const int rows = 8;
+    const int cols = 7;
+    
+    Matrix1 m1;
+    m1.reset();
+    m1.setDimensions( rows + 1, cols + 2 );
+    
+    Matrix2 m2;
+    m2.reset();
+    m2.setDimensions( rows, cols );
+    
+    m1.setLike( m2 );
+    
+    EXPECT_EQ( m1.getRows(), m2.getRows() );
+    EXPECT_EQ( m1.getColumns(), m2.getColumns() );
+    
+    // TODO: Implement number of matrix elements test.
+    // TOOD: Implement rowPointers test.
 }
 
 TEST( SparseMatrixTest, CSR_GetTypeTest_Host )
@@ -124,6 +151,18 @@ TEST( SparseMatrixTest, CSR_setCompressedRowLengthsTest_Cuda )
 }
 #endif
 
+TEST( SparseMatrixTest, CSR_setLikeTest_Host )
+{
+   test_SetLike< CSR_host_int, CSR_host_float >();
+}
+
+#ifdef HAVE_CUDA
+TEST( SparseMatrixTest, CSR_setLikeTest_Cuda )
+{
+   test_SetLike< CSR_cuda_int, CSR_cuda_float >();
+}
+#endif
+
 #endif
 
 #include "../GtestMissingError.h"
-- 
GitLab