+/* Test that x matches y with match() */
+#define WCTEST(x, y) cout << "match(\"" << x << "\",\"" << y "\") " << ((passed = (match(x, y))) ? " SUCCESS!\n" : " FAILURE\n")
+/* Test that x does not match y with match() */
+#define WCTESTNOT(x, y) cout << "!match(\"" << x << "\",\"" << y "\") " << ((passed = ((!match(x, y)))) ? " SUCCESS!\n" : " FAILURE\n")
+
+/* Test that x matches y with match() and cidr enabled */
+#define CIDRTEST(x, y) cout << "match(\"" << x << "\",\"" << y "\", true) " << ((passed = (match(x, y, true))) ? " SUCCESS!\n" : " FAILURE\n")
+/* Test that x does not match y with match() and cidr enabled */
+#define CIDRTESTNOT(x, y) cout << "!match(\"" << x << "\",\"" << y "\", true) " << ((passed = ((!match(x, y, true)))) ? " SUCCESS!\n" : " FAILURE\n")
+
+bool TestSuite::DoWildTests()
+{
+ cout << "\n\nWildcard and CIDR tests\n\n";
+ bool passed = false;
+
+ WCTEST("foobar", "*");
+ WCTEST("foobar", "foo*");
+ WCTEST("foobar", "*bar");
+ WCTEST("foobar", "foo??r");
+ WCTEST("foobar.test", "fo?bar.*t");
+ WCTEST("foobar", "foobar");
+ WCTEST("foobar", "foo***bar");
+
+ WCTESTNOT("foobar", "bazqux");
+ WCTESTNOT("foobar", "*qux");
+ WCTESTNOT("foobar", "foo*x");
+ WCTESTNOT("foobar", "baz*");
+ WCTESTNOT("foobar", "foo???r");
+ WCTESTNOT("foobar", "");
+ WCTESTNOT("", "foobar");
+ WCTESTNOT("OperServ", "O");
+ WCTESTNOT("O", "OperServ");
+ WCTESTNOT("foobar.tst", "fo?bar.*g");
+
+ CIDRTEST("brain@1.2.3.4", "*@1.2.0.0/16");
+ CIDRTEST("brain@1.2.3.4", "*@1.2.3.0/24");
+
+ CIDRTEST("192.168.3.97", "192.168.3.0/24");
+
+ CIDRTESTNOT("brain@1.2.3.4", "x*@1.2.0.0/16");
+ CIDRTESTNOT("brain@1.2.3.4", "*@1.3.4.0/24");
+
+ CIDRTESTNOT("1.2.3.4", "1.2.4.0/24");
+
+ CIDRTESTNOT("brain@1.2.3.4", "*@/24");
+ CIDRTESTNOT("brain@1.2.3.4", "@1.2.3.4/9");
+ CIDRTESTNOT("brain@1.2.3.4", "@");
+ CIDRTESTNOT("brain@1.2.3.4", "");
+
+ return true;
+}
+