Skip to content
Snippets Groups Projects
Commit 156e89ec authored by Lukas Cejka's avatar Lukas Cejka
Browse files

Added format dependent test for the setElement function. This is format...

Added format dependent test for the setElement function. This is format dependent, because setElement won't work without setting rowLengths.
parent 28381856
No related branches found
No related tags found
1 merge request!16Matrices
......@@ -71,7 +71,7 @@ void test_SetCompressedRowLengths()
rowLengths.setSize( rows );
rowLengths.setValue( 3 );
int value = 1;
for (int i = 2; i < rows; i++)
for( int i = 2; i < rows; i++ )
rowLengths.setElement( i, value++ );
m.setCompressedRowLengths( rowLengths );
......@@ -123,6 +123,32 @@ void test_Reset()
EXPECT_EQ( m.getColumns(), 0 );
}
template< typename Matrix >
void test_SetElement()
{
const int rows = 5;
const int cols = 5;
Matrix m;
m.reset();
m.setDimensions( rows, cols );
typename Matrix::CompressedRowLengthsVector rowLengths;
rowLengths.setSize( rows );
rowLengths.setValue( 1 );
m.setCompressedRowLengths( rowLengths );
int value = 1;
for( int i = 0; i < rows; i++ )
m.setElement( i, i, value++ );
EXPECT_EQ( m.getElement( 0, 0 ), 1 );
EXPECT_EQ( m.getElement( 1, 1 ), 2 );
EXPECT_EQ( m.getElement( 2, 2 ), 3 );
EXPECT_EQ( m.getElement( 3, 3 ), 4 );
EXPECT_EQ( m.getElement( 4, 4 ), 5 );
}
TEST( SparseMatrixTest, CSR_GetTypeTest_Host )
{
host_test_GetType< CSR_host_float, CSR_host_int >();
......@@ -173,29 +199,25 @@ TEST( SparseMatrixTest, CSR_setLikeTest_Cuda )
TEST( SparseMatrixTest, CSR_resetTest_Host )
{
{
SCOPED_TRACE( "CSR_resetTest_Host_Float" );
test_Reset< CSR_host_float >();
}
{
SCOPED_TRACE( "CSR_resetTest_Host_Int" );
test_Reset< CSR_host_int >();
}
test_Reset< CSR_host_int >();
}
#ifdef HAVE_CUDA
TEST( SparseMatrixTest, CSR_resetTest_Cuda )
{
{
SCOPED_TRACE( "CSR_resetTest_Cuda_Float" );
test_Reset< CSR_cuda_float >();
}
{
SCOPED_TRACE( "CSR_resetTest_Cuda_Int" );
test_Reset< CSR_cuda_int >();
}
test_Reset< CSR_cuda_int >();
}
#endif
TEST( SparseMatrixTest, CSR_setElementTest_Host )
{
test_SetElement< CSR_host_int >();
}
#ifdef HAVE_CUDA
TEST( SparseMatrixTest, CSR_setElementTest_Cuda )
{
test_SetElement< CSR_cuda_int >();
}
#endif
......
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