|
From: <bo...@us...> - 2008-07-01 06:12:36
|
Revision: 235
http://gearbox.svn.sourceforge.net/gearbox/?rev=235&view=rev
Author: borax00
Date: 2008-06-30 23:12:43 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
added test.
Modified Paths:
--------------
gearbox/trunk/src/gbxutilacfr/test/CMakeLists.txt
Added Paths:
-----------
gearbox/trunk/src/gbxutilacfr/test/tokenisetest.cpp
Modified: gearbox/trunk/src/gbxutilacfr/test/CMakeLists.txt
===================================================================
--- gearbox/trunk/src/gbxutilacfr/test/CMakeLists.txt 2008-07-01 05:38:58 UTC (rev 234)
+++ gearbox/trunk/src/gbxutilacfr/test/CMakeLists.txt 2008-07-01 06:12:43 UTC (rev 235)
@@ -4,3 +4,6 @@
ADD_EXECUTABLE( mathtest mathtest.cpp )
GBX_ADD_TEST( GbxUtilAcfrMathTest mathtest )
+
+ADD_EXECUTABLE( tokenisetest tokenisetest.cpp )
+GBX_ADD_TEST( GbxUtilAcfrTokeniseTest tokenisetest )
Added: gearbox/trunk/src/gbxutilacfr/test/tokenisetest.cpp
===================================================================
--- gearbox/trunk/src/gbxutilacfr/test/tokenisetest.cpp (rev 0)
+++ gearbox/trunk/src/gbxutilacfr/test/tokenisetest.cpp 2008-07-01 06:12:43 UTC (rev 235)
@@ -0,0 +1,60 @@
+#include <gbxutilacfr/tokenise.h>
+#include <iostream>
+#include <assert.h>
+#include <cstdlib>
+
+// Make sure assertions are on
+#undef NDEBUG
+
+using namespace std;
+using namespace gbxutilacfr;
+
+int main()
+{
+ {
+ string str = "asdf,hjkl";
+ vector<string> tokens = tokenise(str,",");
+ assert( tokens[0] == "asdf" );
+ assert( tokens[1] == "hjkl" );
+ cout<<"TRACE(tokenisetest.cpp): str: " << str << endl;
+ cout<<"TRACE(tokenisetest.cpp): tokens: " << endl;
+ for ( size_t i=0; i < tokens.size(); i++)
+ {
+ cout << " " << i << ": " << tokens[i] << endl;
+ }
+ }
+
+ {
+ string str = ",asdf,hjkl,";
+ vector<string> tokens = tokenise(str,",");
+ assert( tokens[0] == "" );
+ assert( tokens[1] == "asdf" );
+ assert( tokens[2] == "hjkl" );
+ assert( tokens[3] == "" );
+ cout<<"TRACE(tokenisetest.cpp): str: " << str << endl;
+ cout<<"TRACE(tokenisetest.cpp): tokens: " << endl;
+ for ( size_t i=0; i < tokens.size(); i++)
+ {
+ cout << " " << i << ": " << tokens[i] << endl;
+ }
+ }
+
+ {
+ string str = ",asdf,,hjkl,";
+ vector<string> tokens = tokenise(str,",");
+ assert( tokens[0] == "" );
+ assert( tokens[1] == "asdf" );
+ assert( tokens[2] == "" );
+ assert( tokens[3] == "hjkl" );
+ assert( tokens[4] == "" );
+ cout<<"TRACE(tokenisetest.cpp): str: " << str << endl;
+ cout<<"TRACE(tokenisetest.cpp): tokens: " << endl;
+ for ( size_t i=0; i < tokens.size(); i++)
+ {
+ cout << " " << i << ": " << tokens[i] << endl;
+ }
+ }
+
+ cout<<"TRACE(tokenisetest.cpp): test PASSED" << endl;
+ exit(0);
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|