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 6, 2014
1 parent fc1da06 commit fd143aa
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/tests/test_serialization.cpp
Expand Up @@ -43,3 +43,28 @@ BOOST_AUTO_TEST_CASE( utils_join_test )
BOOST_CHECK( utils::u8truncate(unicode,3) == "\xC3\xBCni"); // "üni"
}

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 + '*'));
}

0 comments on commit fd143aa

Please sign in to comment.