]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/testsuite.cpp
Add interesting test case
[user/henk/code/inspircd.git] / src / testsuite.cpp
index cff6d9b93d480c05538f763a430c569283fb3adc..71ace375e295a7ebe60513051a9b5202695322a3 100644 (file)
@@ -56,6 +56,7 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance)
                cout << "(3) Unload a module\n";
                cout << "(4) Threading tests\n";
                cout << "(5) Wildcard and CIDR tests\n";
+               cout << "(6) irc::string -> std::string dynamic cast\n";
 
                cout << endl << "(X) Exit test suite\n";
 
@@ -86,6 +87,14 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance)
                        case '5':
                                cout << (DoWildTests() ? "\nSUCCESS!\n" : "\nFAILURE\n");
                        break;
+                       case '6':
+                               {
+                                       std::string* a = new std::string("test");
+                                       irc::string* b = (irc::string)a;
+                                       cout << "std::string value: '" << *a << "' irc::string value: '" << *b << "'" << endl;
+                                       delete a;
+                               }
+                       break;
                        case 'X':
                                return;
                        break;
@@ -98,14 +107,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()
 {
@@ -127,15 +136,19 @@ bool TestSuite::DoWildTests()
        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()