mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-12 01:36:29 +00:00
Add test cases for utils::wildcard_string_match()
This commit is contained in:
parent
f5aa542671
commit
f09fd42645
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user