summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2009-08-06 15:09:22 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2009-08-06 15:09:22 +0000
commit739a4448dbde7d54caf36920eb6fdd56b1ff3e88 (patch)
tree3fefadbe1ca969510983dd439eee8fb289872a7a
parent157cd2d7c7e40541be48a5392fb1da3e961fa3d7 (diff)
First space stream seperator test.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11498 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/testsuite.h1
-rw-r--r--src/testsuite.cpp43
2 files changed, 43 insertions, 1 deletions
diff --git a/include/testsuite.h b/include/testsuite.h
index a3b4f1f24..384f1b438 100644
--- a/include/testsuite.h
+++ b/include/testsuite.h
@@ -27,6 +27,7 @@ class TestSuite : public Extensible
bool DoThreadTests();
bool DoWildTests();
bool DoCommaSepStreamTests();
+ bool DoSpaceSepStreamTests();
};
#endif
diff --git a/src/testsuite.cpp b/src/testsuite.cpp
index ff83b2fa8..d9921a7b8 100644
--- a/src/testsuite.cpp
+++ b/src/testsuite.cpp
@@ -56,6 +56,7 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance)
cout << "(4) Threading tests\n";
cout << "(5) Wildcard and CIDR tests\n";
cout << "(6) Comma sepstream tests\n";
+ cout << "(7) Space sepstream tests\n";
cout << endl << "(X) Exit test suite\n";
@@ -89,6 +90,9 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance)
case '6':
cout << (DoCommaSepStreamTests() ? "\nSUCCESS!\n" : "\nFAILURE\n");
break;
+ case '7':
+ cout << (DoSpaceSepStreamTests() ? "\nSUCCESS!\n" : "\nFAILURE\n");
+ break;
case 'X':
return;
break;
@@ -183,7 +187,7 @@ bool TestSuite::DoWildTests()
}
-#define STREQUALTEST(x, y) cout << "commasepstreamtoken(\"" << x << ",\"" << y "\") " << ((passed = (x == y)) ? "SUCCESS\n" : "FAILURE\n")
+#define STREQUALTEST(x, y) cout << "==(\"" << x << ",\"" << y "\") " << ((passed = (x == y)) ? "SUCCESS\n" : "FAILURE\n")
bool TestSuite::DoCommaSepStreamTests()
{
@@ -222,6 +226,43 @@ bool TestSuite::DoCommaSepStreamTests()
return true;
}
+bool TestSuite::DoSpaceSepStreamTests()
+{
+ bool passed = false;
+
+ irc::spacesepstream list("this is a space stream");
+ std::string item;
+ int idx = 0;
+
+ while (list.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, "space");
+ break;
+ case 5:
+ STREQUALTEST(item, "stream");
+ break;
+ default:
+ cout << "SPACESEPSTREAM: FAILURE: Got an index too many! " << idx << " items\n";
+ break;
+ }
+ }
+ return true;
+}
+
bool TestSuite::DoThreadTests()
{
std::string anything;