Skip to content
Snippets Groups Projects
Commit d79dead1 authored by Lukas Cejka's avatar Lukas Cejka Committed by Tomáš Oberhuber
Browse files

Added test for setCompressedRowLengths function. This test is correct

assuming that getRowLength() works correctly and doesn't need to be
tested.
parent ce4f70ff
No related branches found
No related tags found
1 merge request!16Matrices
......@@ -58,6 +58,36 @@ void testSetDimensions()
EXPECT_EQ( m.getColumns(), 8);
}
template< typename Matrix >
void testSetCompressedRowLengths()
{
Matrix m;
const int rows = 10;
const int cols = 11;
m.reset();
m.setDimensions( rows, cols );
typename Matrix::CompressedRowLengthsVector rowLengths;
rowLengths.setSize( rows );
rowLengths.setValue( 3 );
int value = 1;
for (int i = 2; i < rows; i++)
rowLengths.setElement( i, value++ );
m.setCompressedRowLengths( rowLengths );
EXPECT_EQ( m.getRowLength( 0), 3 );
EXPECT_EQ( m.getRowLength( 1), 3 );
EXPECT_EQ( m.getRowLength( 2), 1 );
EXPECT_EQ( m.getRowLength( 3), 2 );
EXPECT_EQ( m.getRowLength( 4), 3 );
EXPECT_EQ( m.getRowLength( 5), 4 );
EXPECT_EQ( m.getRowLength( 6), 5 );
EXPECT_EQ( m.getRowLength( 7), 6 );
EXPECT_EQ( m.getRowLength( 8), 7 );
EXPECT_EQ( m.getRowLength( 9), 8 );
}
TEST( SparseMatrixTest, CSR_GetTypeTest_Host )
{
host_testGetType< CSR_host_float, CSR_host_int >();
......@@ -70,7 +100,7 @@ TEST( SparseMatrixTest, CSR_GetTypeTest_Cuda )
}
#endif
TEST( SparseMatrixTest, CSR_testSetDimensions_Host )
TEST( SparseMatrixTest, CSR_SetDimensionsTest_Host )
{
testSetDimensions< CSR_host_int >();
}
......@@ -82,6 +112,18 @@ TEST( SparseMatrixTest, CSR_SetDimensionsTest_Cuda )
}
#endif
TEST( SparseMatrixTest, CSR_setCompressedRowLengthsTest_Host )
{
testSetCompressedRowLengths< CSR_host_int >();
}
#ifdef HAVE_CUDA
TEST( SparseMatrixTest, CSR_setCompressedRowLengthsTest_Cuda )
{
testSetCompressedRowLengths< CSR_cuda_int >();
}
#endif
#endif
#include "../GtestMissingError.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment