diff options
author | Andrew Stitcher <astitcher@apache.org> | 2013-03-14 17:24:28 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2013-03-14 17:24:28 +0000 |
commit | 125e49d4df65142a89b69e7d367b34f01ea354a1 (patch) | |
tree | 7b29e09d3a47570897109ef4f8195e1e852ce672 /qpid/cpp/src/tests/Selector.cpp | |
parent | 7bddceb25095cd8002e03cbc2ffd312922ed1c53 (diff) | |
download | qpid-python-125e49d4df65142a89b69e7d367b34f01ea354a1.tar.gz |
QPID-4622: Implement 'LIKE' string matching operations in selector
- This implements <expression> [NOT] LIKE <string> [ESCAPE <character>]
- The implementation uses the posix regex library (in BRE mode) on
Unix systems
- It uses std::tr1::regex on Visual Studio (in std::tr1::regex::basic mode)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1456561 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/Selector.cpp')
-rw-r--r-- | qpid/cpp/src/tests/Selector.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/qpid/cpp/src/tests/Selector.cpp b/qpid/cpp/src/tests/Selector.cpp index ba99c9e3f0..7208f80e85 100644 --- a/qpid/cpp/src/tests/Selector.cpp +++ b/qpid/cpp/src/tests/Selector.cpp @@ -182,6 +182,10 @@ QPID_AUTO_TEST_CASE(parseStringFail) BOOST_CHECK_THROW(qb::Selector e("A is null and 'hello out there'"), std::range_error); BOOST_CHECK_THROW(qb::Selector e("A is null and (B='hello out there'"), std::range_error); BOOST_CHECK_THROW(qb::Selector e("in='hello kitty'"), std::range_error); + BOOST_CHECK_THROW(qb::Selector e("A like 234"), std::range_error); + BOOST_CHECK_THROW(qb::Selector e("A not 234 escape"), std::range_error); + BOOST_CHECK_THROW(qb::Selector e("A not like 'eclecti_' escape 'happy'"), std::range_error); + BOOST_CHECK_THROW(qb::Selector e("A not like 'eclecti_' escape happy"), std::range_error); } class TestSelectorEnv : public qpid::broker::SelectorEnv { @@ -233,6 +237,9 @@ QPID_AUTO_TEST_CASE(parseString) BOOST_CHECK_NO_THROW(qb::Selector e("Not A='' or B=z")); BOOST_CHECK_NO_THROW(qb::Selector e("Not A=17 or B=5.6")); BOOST_CHECK_NO_THROW(qb::Selector e("A<>17 and B=5.6e17")); + BOOST_CHECK_NO_THROW(qb::Selector e("A LIKE 'excep%ional'")); + BOOST_CHECK_NO_THROW(qb::Selector e("B NOT LIKE 'excep%ional'")); + BOOST_CHECK_NO_THROW(qb::Selector e("A LIKE 'excep%ional' EScape '\'")); } QPID_AUTO_TEST_CASE(simpleEval) @@ -267,6 +274,10 @@ QPID_AUTO_TEST_CASE(simpleEval) BOOST_CHECK(!qb::Selector("C=D").eval(env)); BOOST_CHECK(qb::Selector("13 is not null").eval(env)); BOOST_CHECK(!qb::Selector("'boo!' is null").eval(env)); + BOOST_CHECK(qb::Selector("A LIKE '%cru_l%'").eval(env)); + BOOST_CHECK(qb::Selector("'_%%_hello.th_re%' LIKE 'z_%.%z_%z%' escape 'z'").eval(env)); + BOOST_CHECK(qb::Selector("A NOT LIKE 'z_%.%z_%z%' escape 'z'").eval(env)); + BOOST_CHECK(qb::Selector("'{}[]<>,.!\"$%^&*()_-+=?/|\\' LIKE '{}[]<>,.!\"$z%^&*()z_-+=?/|\\' escape 'z'").eval(env)); } QPID_AUTO_TEST_CASE(numericEval) |