Add to_bool(string) function
This commit is contained in:
@@ -722,3 +722,23 @@ BOOST_AUTO_TEST_CASE(DeckItemEqual) {
|
||||
BOOST_CHECK( item3.equal( item5 , false, true ));
|
||||
BOOST_CHECK( !item3.equal( item5 , false, false ));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(STRING_TO_BOOL) {
|
||||
BOOST_CHECK( DeckItem::to_bool("TRUE") );
|
||||
BOOST_CHECK( DeckItem::to_bool("T") );
|
||||
BOOST_CHECK( DeckItem::to_bool("YES") );
|
||||
BOOST_CHECK( DeckItem::to_bool("yEs") );
|
||||
BOOST_CHECK( DeckItem::to_bool("Y") );
|
||||
BOOST_CHECK( DeckItem::to_bool("1") );
|
||||
//
|
||||
BOOST_CHECK( !DeckItem::to_bool("falsE") );
|
||||
BOOST_CHECK( !DeckItem::to_bool("f") );
|
||||
BOOST_CHECK( !DeckItem::to_bool("NO") );
|
||||
BOOST_CHECK( !DeckItem::to_bool("N"));
|
||||
BOOST_CHECK( !DeckItem::to_bool("0") );
|
||||
//
|
||||
BOOST_CHECK_THROW(DeckItem::to_bool("NO - not valid"), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(DeckItem::to_bool("YE"), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(DeckItem::to_bool("YE"), std::invalid_argument);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user