Skip to content

Commit

Permalink
Add test cases for utils::wildcard_string_match()
Browse files Browse the repository at this point in the history
  • Loading branch information
irydacea committed Jun 4, 2014
1 parent f5aa542 commit f09fd42
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/tests/test_serialization.cpp
Expand Up @@ -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()

0 comments on commit f09fd42

Please sign in to comment.