Commit dea03a45 authored by Lukas Cejka's avatar Lukas Cejka Committed by Tomáš Oberhuber
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 5ebd69f2
Loading
Loading
Loading
Loading
+41 −19
Original line number Diff line number Diff line
@@ -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 >();
}
}

#ifdef HAVE_CUDA
TEST( SparseMatrixTest, CSR_resetTest_Cuda )
{
    {
        SCOPED_TRACE( "CSR_resetTest_Cuda_Float" );
        test_Reset< CSR_cuda_float >();
    test_Reset< CSR_cuda_int >();
}
#endif

TEST( SparseMatrixTest, CSR_setElementTest_Host )
{
        SCOPED_TRACE( "CSR_resetTest_Cuda_Int" );
        test_Reset< CSR_cuda_int >();
    test_SetElement< CSR_host_int >();
}

#ifdef HAVE_CUDA
TEST( SparseMatrixTest, CSR_setElementTest_Cuda )
{
    test_SetElement< CSR_cuda_int >();
}
#endif