Add test cases for utils::wildcard_string_match()

This commit is contained in:
Ignacio R. Morelle 2014-06-04 14:13:21 -04:00
parent f5aa542671
commit f09fd42645

View File

@ -83,4 +83,30 @@ BOOST_AUTO_TEST_CASE( test_lowercase )
BOOST_CHECK_EQUAL ( utf8::lowercase("fO0") , "fo0" );
}
BOOST_AUTO_TEST_CASE( test_wildcard_string_match )
{
const std::string str = "foo bar baz";
BOOST_CHECK(utils::wildcard_string_match(str, "*bar*"));
BOOST_CHECK(!utils::wildcard_string_match(str, "*BAR*"));
BOOST_CHECK(!utils::wildcard_string_match(str, "bar"));
BOOST_CHECK(utils::wildcard_string_match(str, "*ba? b*"));
BOOST_CHECK(utils::wildcard_string_match(str, "*?a?*"));
BOOST_CHECK(!utils::wildcard_string_match(str, "foo? "));
BOOST_CHECK(!utils::wildcard_string_match(str, "?foo"));
std::string superfluous_mask;
superfluous_mask = std::string(str.length(), '?');
BOOST_CHECK(utils::wildcard_string_match(str, superfluous_mask));
BOOST_CHECK(utils::wildcard_string_match(str, superfluous_mask + '?'));
superfluous_mask = std::string(str.length(), '*');
BOOST_CHECK(utils::wildcard_string_match(str, superfluous_mask));
BOOST_CHECK(utils::wildcard_string_match(str, superfluous_mask + '*'));
}
BOOST_AUTO_TEST_SUITE_END()