X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Ftestsuite.cpp;h=1cee7500c830b25ebaf792d61057b3582f900533;hb=e3e748b78683ac005b4c85360806ea6ec27d40c9;hp=a4d8c871c29f507cb6a5412307e24640c85a3d92;hpb=03ef675c0dd4742464d8ad93888e98721a044108;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/testsuite.cpp b/src/testsuite.cpp index a4d8c871c..1cee7500c 100644 --- a/src/testsuite.cpp +++ b/src/testsuite.cpp @@ -98,14 +98,14 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance) } /* Test that x matches y with match() */ -#define WCTEST(x, y) cout << "match(\"" << x << "\",\"" << y "\") " << ((passed = (match(x, y) || passed)) ? " SUCCESS!\n" : " FAILURE\n") +#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)) || passed)) ? " SUCCESS!\n" : " FAILURE\n") +#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) || passed)) ? " SUCCESS!\n" : " FAILURE\n") +#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)) || passed)) ? " SUCCESS!\n" : " FAILURE\n") +#define CIDRTESTNOT(x, y) cout << "!match(\"" << x << "\",\"" << y "\", true) " << ((passed = ((!match(x, y, true)))) ? " SUCCESS!\n" : " FAILURE\n") bool TestSuite::DoWildTests() { @@ -121,14 +121,25 @@ bool TestSuite::DoWildTests() WCTESTNOT("foobar", "*qux"); WCTESTNOT("foobar", "foo*x"); WCTESTNOT("foobar", "baz*"); + WCTESTNOT("foobar", "foo???r"); + WCTESTNOT("foobar", ""); 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"); - return passed; + 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; } bool TestSuite::DoThreadTests()