From c7d3de03a8000797b97cc049394f3a6ee78376a7 Mon Sep 17 00:00:00 2001 From: Lukas Cejka <lukas.ostatek@gmail.com> Date: Sun, 4 Nov 2018 15:37:14 +0100 Subject: [PATCH] Added test for setDimensions function. This test is correct assuming that getRows() and getColumns() work correctly and don't need to be tested. --- src/UnitTests/Matrices/SparseMatrixTest.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/UnitTests/Matrices/SparseMatrixTest.h b/src/UnitTests/Matrices/SparseMatrixTest.h index dbc98da90e..f1f4bad246 100644 --- a/src/UnitTests/Matrices/SparseMatrixTest.h +++ b/src/UnitTests/Matrices/SparseMatrixTest.h @@ -48,6 +48,16 @@ void cuda_testGetType() EXPECT_EQ( mtrxCudaInt.getType(), TNL::String( "Matrices::CSR< int, Cuda >" ) ); } +template< typename Matrix > +void testSetDimensions() +{ + Matrix m; + m.setDimensions( 9, 8 ); + + EXPECT_EQ( m.getRows(), 9); + EXPECT_EQ( m.getColumns(), 8); +} + TEST( SparseMatrixTest, CSR_GetTypeTest_Host ) { host_testGetType< CSR_host_float, CSR_host_int >(); @@ -60,6 +70,18 @@ TEST( SparseMatrixTest, CSR_GetTypeTest_Cuda ) } #endif +TEST( SparseMatrixTest, CSR_testSetDimensions_Host ) +{ + testSetDimensions< CSR_host_int >(); +} + +#ifdef HAVE_CUDA +TEST( SparseMatrixTest, CSR_SetDimensionsTest_Cuda ) +{ + testSetDimensions< CSR_cuda_int >(); +} +#endif + #endif #include "../GtestMissingError.h" -- GitLab