Skip to content

Commit

Permalink
add only min and only max unit test to Range
Browse files Browse the repository at this point in the history
issue #27
  • Loading branch information
Valentin Noel committed Jul 18, 2013
1 parent 75367f4 commit b74c1c0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions libraries/basicElement/tests/tools/rangeTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ BOOST_AUTO_TEST_CASE( basic_element_range )
be::Range< int > rangeObj;
BOOST_CHECK_THROW( rangeObj.isInRange( 10 ), std::range_error );
}
{
be::Range< int > rangeObj;
rangeObj.setMinimum( 0 );
BOOST_CHECK_EQUAL( rangeObj.isSet(), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( -1 ), false );
BOOST_CHECK_EQUAL( rangeObj.isInRange( 0 ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( 5 ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( 10 ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( 1110 ), true );
}
{
be::Range< int > rangeObj;
rangeObj.setMaximum( 0 );
BOOST_CHECK_EQUAL( rangeObj.isSet(), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( -1 ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( 0 ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( 5 ), false );
BOOST_CHECK_EQUAL( rangeObj.isInRange( 10 ), false );
BOOST_CHECK_EQUAL( rangeObj.isInRange( 1110 ), false );
}

{
be::Range< float > rangeObj;
Expand Down Expand Up @@ -59,6 +79,24 @@ BOOST_AUTO_TEST_CASE( basic_element_range )
BOOST_CHECK_EQUAL( rangeObj.isInRange( "0" ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( "1" ), false );
}
{
be::Range< std::string > rangeObj;
rangeObj.setMinimum( "10" );
BOOST_CHECK_EQUAL( rangeObj.isSet(), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( "0" ), false );
BOOST_CHECK_EQUAL( rangeObj.isInRange( "5" ), false );
BOOST_CHECK_EQUAL( rangeObj.isInRange( "10" ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( "1110" ), true );
}
{
be::Range< std::string > rangeObj;
rangeObj.setMaximum( "10" );
BOOST_CHECK_EQUAL( rangeObj.isSet(), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( "0" ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( "5" ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( "10" ), true );
BOOST_CHECK_EQUAL( rangeObj.isInRange( "1110" ), false );
}
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit b74c1c0

Please sign in to comment.