Skip to content

Commit

Permalink
add Map class tests
Browse files Browse the repository at this point in the history
issue #27
  • Loading branch information
Valentin Noel committed Jul 17, 2013
1 parent bed57a9 commit 5ea9030
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
65 changes: 65 additions & 0 deletions libraries/basicElement/tests/tools/mapTests.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

BOOST_AUTO_TEST_SUITE( basic_element_test_map )

BOOST_AUTO_TEST_CASE( basic_element_map )
{
LOG_INFO( "\n>>> basic_element_map <<<" );
{
std::map< int, std::string > map;
map.insert( std::pair< int, std::string >( 1, "First number" ) );
map.insert( std::pair< int, std::string >( 2, "Second number" ) );
map.insert( std::pair< int, std::string >( 3, "Third number" ) );

be::Map< int > mapObj( map );

BOOST_CHECK_EQUAL( mapObj.getLabel( 0 ), "" );
BOOST_CHECK_EQUAL( mapObj.getLabel( 1 ), "First number" );
BOOST_CHECK_EQUAL( mapObj.getLabel( 2 ), "Second number" );
BOOST_CHECK_EQUAL( mapObj.getLabel( 3 ), "Third number" );

BOOST_CHECK_EQUAL( mapObj.getSize(), 3 );
}
{
std::map< char, std::string > map;
map.insert( std::pair< char, std::string >( '1', "First number" ) );
map.insert( std::pair< char, std::string >( '2', "Second number" ) );
map.insert( std::pair< char, std::string >( '3', "Third number" ) );

be::Map< char > mapObj;
mapObj.setMap( map );

BOOST_CHECK_EQUAL( mapObj.getLabel( '0' ), "" );
BOOST_CHECK_EQUAL( mapObj.getLabel( '1' ), "First number" );
BOOST_CHECK_EQUAL( mapObj.getLabel( '2' ), "Second number" );
BOOST_CHECK_EQUAL( mapObj.getLabel( '3' ), "Third number" );

BOOST_CHECK_EQUAL( mapObj.getSize(), 3 );
}
{
std::map< int, std::string > map;
std::pair< int, std::string > pair1( 1, "First number" );
std::pair< int, std::string > pair2( 2, "Second number" );
std::pair< int, std::string > pair3( 3, "Third number" );

be::Map< int > mapObj;
mapObj.setMap( map );

mapObj.insertPair( pair1 );
BOOST_CHECK_EQUAL( mapObj.getLabel( 1 ), "First number" );
BOOST_CHECK_EQUAL( mapObj.getSize(), 1 );

mapObj.insertPair( pair3 );
BOOST_CHECK_EQUAL( mapObj.getLabel( 3 ), "Third number" );
BOOST_CHECK_EQUAL( mapObj.getSize(), 2 );

mapObj.insertPair( pair2 );
BOOST_CHECK_EQUAL( mapObj.getLabel( 2 ), "Second number" );
BOOST_CHECK_EQUAL( mapObj.getSize(), 3 );

mapObj.addPair( 10, "Tenth number" );
BOOST_CHECK_EQUAL( mapObj.getLabel( 10 ), "Tenth number" );
BOOST_CHECK_EQUAL( mapObj.getSize(), 4 );
}
}

BOOST_AUTO_TEST_SUITE_END()
2 changes: 1 addition & 1 deletion libraries/basicElement/tests/tools/toolsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ BOOST_AUTO_TEST_CASE( basic_element_init )
BOOST_AUTO_TEST_SUITE_END()

#include "translatorTests.hpp"
// #include "mapTests.hpp"
#include "mapTests.hpp"
// #include "rangeTests.hpp"

0 comments on commit 5ea9030

Please sign in to comment.