X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Ftestsuite.cpp;h=9ab30ff2d2b1a2c7805f74392593e8326ee421a9;hb=cc3503abc4e465c6d5c57a6e60716dafe0703aa5;hp=cff6d9b93d480c05538f763a430c569283fb3adc;hpb=8888d8ef07529fcff1913a89be7dea72d731530b;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/testsuite.cpp b/src/testsuite.cpp index cff6d9b93..9ab30ff2d 100644 --- a/src/testsuite.cpp +++ b/src/testsuite.cpp @@ -11,7 +11,7 @@ * --------------------------------------------------- */ -/* $Core: libIRCDtestsuite */ +/* $Core */ #include "inspircd.h" #include "testsuite.h" @@ -59,7 +59,7 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance) cout << endl << "(X) Exit test suite\n"; - cout << "\nChoice: "; + cout << "\nChoices (Enter one or more options as a list then press enter, e.g. 15X): "; cin >> choice; if (!choice) @@ -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() { @@ -116,6 +116,9 @@ bool TestSuite::DoWildTests() 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"); @@ -123,19 +126,27 @@ bool TestSuite::DoWildTests() 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 passed; + return true; } bool TestSuite::DoThreadTests()