summaryrefslogtreecommitdiffstats
path: root/juniper/src/test/matchobjectTestApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'juniper/src/test/matchobjectTestApp.cpp')
-rw-r--r--juniper/src/test/matchobjectTestApp.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/juniper/src/test/matchobjectTestApp.cpp b/juniper/src/test/matchobjectTestApp.cpp
index 7fae5b4c0de..525f7b9446a 100644
--- a/juniper/src/test/matchobjectTestApp.cpp
+++ b/juniper/src/test/matchobjectTestApp.cpp
@@ -3,8 +3,37 @@
#include "matchobjectTest.h"
#include "testenv.h"
#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/juniper/wildcard_match.h>
+#include <iostream>
+
+namespace {
+void test(const char * word, const char * pattern, bool expect) {
+ EXPECT_EQUAL(expect, fast::util::wildcard_match(word, pattern));
+}
+}
+
+void
+test_wildcard()
+{
+ test("a", "b", false);
+ test("b", "b", true);
+ test("abc", "def", false);
+ test("def", "def", true);
+ test("def", "d?f", true);
+ test("def", "d?d", false);
+ test("def", "??d", false);
+ test("def", "d??", true);
+ test("abcdef", "a*e", false);
+ test("abcdef", "a*f", true);
+ test("abcdef", "a?c*f", true);
+ test("abcdef", "a?b*f", false);
+ test("abcdef", "a*b*f", true);
+ test("abcdef", "abc*", true);
+ test("abcdef", "*def", true);
+}
int main(int argc, char **argv) {
+ test_wildcard();
juniper::TestEnv te(argc, argv, TEST_PATH("../rpclient/testclient.rc").c_str());
MatchObjectTest test;
test.SetStream(&std::cout);