diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-08-06 14:45:05 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-08-06 14:45:05 +0000 |
commit | 157cd2d7c7e40541be48a5392fb1da3e961fa3d7 (patch) | |
tree | 696ad50173d598b4b3d8c61c8100fac7533d8762 /src | |
parent | 4a78c7a7867409b6d9c67d33dbeaa7c9677a6287 (diff) |
Add commasepstream test case.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11497 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/testsuite.cpp | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/src/testsuite.cpp b/src/testsuite.cpp index 8f89fd65e..ff83b2fa8 100644 --- a/src/testsuite.cpp +++ b/src/testsuite.cpp @@ -55,6 +55,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) Comma sepstream tests\n"; cout << endl << "(X) Exit test suite\n"; @@ -68,29 +69,32 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance) { case '1': FOREACH_MOD(I_OnRunTestSuite, OnRunTestSuite()); - break; + break; case '2': cout << "Enter module filename to load: "; cin >> modname; cout << (Instance->Modules->Load(modname.c_str()) ? "\nSUCCESS!\n" : "\nFAILURE\n"); - break; + break; case '3': cout << "Enter module filename to unload: "; cin >> modname; cout << (Instance->Modules->Unload(modname.c_str()) ? "\nSUCCESS!\n" : "\nFAILURE\n"); - break; + break; case '4': cout << (DoThreadTests() ? "\nSUCCESS!\n" : "\nFAILURE\n"); - break; + break; case '5': cout << (DoWildTests() ? "\nSUCCESS!\n" : "\nFAILURE\n"); - break; + break; + case '6': + cout << (DoCommaSepStreamTests() ? "\nSUCCESS!\n" : "\nFAILURE\n"); + break; case 'X': return; - break; + break; default: cout << "Invalid option\n"; - break; + break; } cout << endl; } @@ -178,6 +182,46 @@ bool TestSuite::DoWildTests() return true; } + +#define STREQUALTEST(x, y) cout << "commasepstreamtoken(\"" << x << ",\"" << y "\") " << ((passed = (x == y)) ? "SUCCESS\n" : "FAILURE\n") + +bool TestSuite::DoCommaSepStreamTests() +{ + bool passed = false; + irc::commasepstream items("this,is,a,comma,stream"); + std::string item; + int idx = 0; + + while (items.GetToken(item)) + { + idx++; + + switch (idx) + { + case 1: + STREQUALTEST(item, "this"); + break; + case 2: + STREQUALTEST(item, "is"); + break; + case 3: + STREQUALTEST(item, "a"); + break; + case 4: + STREQUALTEST(item, "comma"); + break; + case 5: + STREQUALTEST(item, "stream"); + break; + default: + cout << "COMMASEPSTREAM: FAILURE: Got an index too many! " << idx << " items\n"; + break; + } + } + + return true; +} + bool TestSuite::DoThreadTests() { std::string anything; |