MultiArray - Function that returns total values count

This commit is contained in:
Emmanuel BENOîT 2018-05-07 12:57:26 +02:00
parent d2122aff38
commit 8f939b6a32
3 changed files with 67 additions and 47 deletions

View file

@ -142,6 +142,7 @@ void ArraysMultiTest::testInitialSize( )
{
T_Test empty;
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , empty.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , empty.values( ) );
}
/*----------------------------------------------------------------------------*/
@ -153,6 +154,7 @@ void ArraysMultiTest::testNext( )
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.values( ) );
}
void ArraysMultiTest::testNextMultiple( )
@ -160,11 +162,12 @@ void ArraysMultiTest::testNextMultiple( )
T_Test test;
test.next( );
test.next( );
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.sizeOf( 1 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 1 ) );
CPPUNIT_ASSERT_EQUAL( 2u , test.size( ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.sizeOf( 1 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 1 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.values( ) );
}
/*----------------------------------------------------------------------------*/
@ -174,9 +177,10 @@ void ArraysMultiTest::testAddToEmpty( )
T_Test test;
test.next( );
test.add( 0 );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.size( ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.values( ) );
}
void ArraysMultiTest::testAdd( )
@ -185,9 +189,10 @@ void ArraysMultiTest::testAdd( )
test.next( );
test.add( 0 );
test.add( 0 );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.size( ) );
CPPUNIT_ASSERT_EQUAL( 2u , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 2u , test.values( ) );
}
void ArraysMultiTest::testAddNewToEmpty( )
@ -195,9 +200,10 @@ void ArraysMultiTest::testAddNewToEmpty( )
T_ObjTest test;
test.next( );
test.addNew( 1 , 2 );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.size( ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.values( ) );
}
void ArraysMultiTest::testAddNew( )
@ -206,9 +212,10 @@ void ArraysMultiTest::testAddNew( )
test.next( );
test.addNew( 1 , 2 );
test.addNew( 3 , 4 );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.size( ) );
CPPUNIT_ASSERT_EQUAL( 2u , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 2u , test.values( ) );
}
void ArraysMultiTest::testNextAfterAdd( )
@ -221,13 +228,14 @@ void ArraysMultiTest::testNextAfterAdd( )
test.add( 0 );
test.next( );
test.add( 0 );
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , test.sizeOf( 1 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.firstOf( 1 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.sizeOf( 2 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , test.firstOf( 2 ) );
CPPUNIT_ASSERT_EQUAL( 3u , test.size( ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 2u , test.sizeOf( 1 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.firstOf( 1 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.sizeOf( 2 ) );
CPPUNIT_ASSERT_EQUAL( 3u , test.firstOf( 2 ) );
CPPUNIT_ASSERT_EQUAL( 4u , test.values( ) );
}
/*----------------------------------------------------------------------------*/
@ -241,9 +249,10 @@ void ArraysMultiTest::testCopyFromToEmpty( )
test.next( );
test.copyFrom( values );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.size( ) );
CPPUNIT_ASSERT_EQUAL( 3u , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 3u , test.values( ) );
}
void ArraysMultiTest::testCopyFrom( )
@ -256,9 +265,10 @@ void ArraysMultiTest::testCopyFrom( )
test.add( 0 );
test.copyFrom( values );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 4 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.size( ) );
CPPUNIT_ASSERT_EQUAL( 4u , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 4u , test.values( ) );
}
void ArraysMultiTest::testCopyFromEmpty( )
@ -268,9 +278,10 @@ void ArraysMultiTest::testCopyFromEmpty( )
test.next( );
test.copyFrom( values );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.size( ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.size( ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.sizeOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.firstOf( 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.values( ) );
}
/*----------------------------------------------------------------------------*/
@ -285,10 +296,11 @@ void ArraysMultiTest::testGetRead( )
test.add( 2 );
test.next( );
test.add( 3 );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.get( 0 , 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , test.get( 1 , 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , test.get( 1 , 1 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , test.get( 2 , 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.get( 0 , 0 ) );
CPPUNIT_ASSERT_EQUAL( 1u , test.get( 1 , 0 ) );
CPPUNIT_ASSERT_EQUAL( 2u , test.get( 1 , 1 ) );
CPPUNIT_ASSERT_EQUAL( 3u , test.get( 2 , 0 ) );
CPPUNIT_ASSERT_EQUAL( 4u , test.values( ) );
}
void ArraysMultiTest::testGetWrite( )
@ -302,10 +314,10 @@ void ArraysMultiTest::testGetWrite( )
test.next( );
test.add( 3 );
test.get( 1 , 0 ) = 12;
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , test.get( 0 , 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 12 ) , test.get( 1 , 0 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , test.get( 1 , 1 ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , test.get( 2 , 0 ) );
CPPUNIT_ASSERT_EQUAL( 0u , test.get( 0 , 0 ) );
CPPUNIT_ASSERT_EQUAL( 12u , test.get( 1 , 0 ) );
CPPUNIT_ASSERT_EQUAL( 2u , test.get( 1 , 1 ) );
CPPUNIT_ASSERT_EQUAL( 3u , test.get( 2 , 0 ) );
}
void ArraysMultiTest::testDirectRead( )