From a77e41eee42b99282c05d268479ba5ebb11dc095 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 11 Oct 2006 15:54:09 +0000 Subject: Rearranged the tests, now it's like the old style, which I like more for some reason. --- src/tests/clistress.cpp | 20 ++++++ src/tests/clistress/main.cpp | 20 ------ src/tests/connect.cpp | 38 +++++++++++ src/tests/connect/main.cpp | 38 ----------- src/tests/exception.cpp | 16 +++++ src/tests/exception/exception.cpp | 16 ----- src/tests/hash.cpp | 10 +++ src/tests/hash/main.cpp | 10 --- src/tests/hashtest.cpp | 107 ++++++++++++++++++++++++++++++ src/tests/hashtest/hashtest.cpp | 107 ------------------------------ src/tests/log.cpp | 29 ++++++++ src/tests/log/log.cpp | 29 -------- src/tests/md5test.cpp | 19 ++++++ src/tests/md5test/md5test.cpp | 19 ------ src/tests/param.cpp | 46 +++++++++++++ src/tests/param.h | 21 ++++++ src/tests/param/param.cpp | 46 ------------- src/tests/param/param.h | 21 ------ src/tests/serialize.cpp | 30 +++++++++ src/tests/serialize/serialize.cpp | 30 --------- src/tests/serializetext.cpp | 28 ++++++++ src/tests/serializetext/serializetext.cpp | 28 -------- src/tests/srvstress.cpp | 90 +++++++++++++++++++++++++ src/tests/srvstress/main.cpp | 90 ------------------------- src/tests/strhash.cpp | 12 ++++ src/tests/strhash/main.cpp | 12 ---- src/tests/xmlreadtest.cpp | 29 ++++++++ src/tests/xmlreadtest/xmlreadtest.cpp | 29 -------- src/tests/xmlrepltest.cpp | 31 +++++++++ src/tests/xmlrepltest/xmlrepltest.cpp | 31 --------- 30 files changed, 526 insertions(+), 526 deletions(-) create mode 100644 src/tests/clistress.cpp delete mode 100644 src/tests/clistress/main.cpp create mode 100644 src/tests/connect.cpp delete mode 100644 src/tests/connect/main.cpp create mode 100644 src/tests/exception.cpp delete mode 100644 src/tests/exception/exception.cpp create mode 100644 src/tests/hash.cpp delete mode 100644 src/tests/hash/main.cpp create mode 100644 src/tests/hashtest.cpp delete mode 100644 src/tests/hashtest/hashtest.cpp create mode 100644 src/tests/log.cpp delete mode 100644 src/tests/log/log.cpp create mode 100644 src/tests/md5test.cpp delete mode 100644 src/tests/md5test/md5test.cpp create mode 100644 src/tests/param.cpp create mode 100644 src/tests/param.h delete mode 100644 src/tests/param/param.cpp delete mode 100644 src/tests/param/param.h create mode 100644 src/tests/serialize.cpp delete mode 100644 src/tests/serialize/serialize.cpp create mode 100644 src/tests/serializetext.cpp delete mode 100644 src/tests/serializetext/serializetext.cpp create mode 100644 src/tests/srvstress.cpp delete mode 100644 src/tests/srvstress/main.cpp create mode 100644 src/tests/strhash.cpp delete mode 100644 src/tests/strhash/main.cpp create mode 100644 src/tests/xmlreadtest.cpp delete mode 100644 src/tests/xmlreadtest/xmlreadtest.cpp create mode 100644 src/tests/xmlrepltest.cpp delete mode 100644 src/tests/xmlrepltest/xmlrepltest.cpp diff --git a/src/tests/clistress.cpp b/src/tests/clistress.cpp new file mode 100644 index 0000000..6b0ac66 --- /dev/null +++ b/src/tests/clistress.cpp @@ -0,0 +1,20 @@ +#include "connection.h" + +int main() +{ + Connection c; + + c.open("localhost", 4001 ); + + c.appendOutput("w"); + c.writeOutput(); + + c.waitForInput( 6, 5, 0 ); + + printf("read: %s\n", c.getInput() ); + + c.close(); + + return 0; +} + diff --git a/src/tests/clistress/main.cpp b/src/tests/clistress/main.cpp deleted file mode 100644 index 6b0ac66..0000000 --- a/src/tests/clistress/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "connection.h" - -int main() -{ - Connection c; - - c.open("localhost", 4001 ); - - c.appendOutput("w"); - c.writeOutput(); - - c.waitForInput( 6, 5, 0 ); - - printf("read: %s\n", c.getInput() ); - - c.close(); - - return 0; -} - diff --git a/src/tests/connect.cpp b/src/tests/connect.cpp new file mode 100644 index 0000000..a9fca64 --- /dev/null +++ b/src/tests/connect.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include "connection.h" + +int main() +{ + Connection c; + c.open("127.0.0.1", 12457 ); + + { + int newSocket = c.getSocket(); + int flags; + + flags = fcntl(newSocket, F_GETFL, 0); + flags |= O_NONBLOCK; + if (fcntl(newSocket, F_SETFL, flags) < 0) + { + return false; + } + } + + for( int i = 0; i < 50; i++ ) + { + usleep( 100000 ); + int nbytes = c.readInput(); + if( nbytes == 0 ) + printf("0 bytes, EOF?\n"); + else + printf("Got %d bytes, whacky...\n", nbytes ); + } + + c.close(); + + return 0; +} + diff --git a/src/tests/connect/main.cpp b/src/tests/connect/main.cpp deleted file mode 100644 index a9fca64..0000000 --- a/src/tests/connect/main.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include -#include -#include "connection.h" - -int main() -{ - Connection c; - c.open("127.0.0.1", 12457 ); - - { - int newSocket = c.getSocket(); - int flags; - - flags = fcntl(newSocket, F_GETFL, 0); - flags |= O_NONBLOCK; - if (fcntl(newSocket, F_SETFL, flags) < 0) - { - return false; - } - } - - for( int i = 0; i < 50; i++ ) - { - usleep( 100000 ); - int nbytes = c.readInput(); - if( nbytes == 0 ) - printf("0 bytes, EOF?\n"); - else - printf("Got %d bytes, whacky...\n", nbytes ); - } - - c.close(); - - return 0; -} - diff --git a/src/tests/exception.cpp b/src/tests/exception.cpp new file mode 100644 index 0000000..6417692 --- /dev/null +++ b/src/tests/exception.cpp @@ -0,0 +1,16 @@ +#include +#include "exceptions.h" + +int main() +{ + try + { + throw ExceptionBase( 42, "There was an error on line: %d", __LINE__ ); + } + catch( ExceptionBase &e ) + { + std::cout << "Error "<< e.getErrorCode() << ": " << e.what() << "\n"; + } + + throw ExceptionBase( 112, "This exception wasn't caught!"); +} diff --git a/src/tests/exception/exception.cpp b/src/tests/exception/exception.cpp deleted file mode 100644 index 6417692..0000000 --- a/src/tests/exception/exception.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include "exceptions.h" - -int main() -{ - try - { - throw ExceptionBase( 42, "There was an error on line: %d", __LINE__ ); - } - catch( ExceptionBase &e ) - { - std::cout << "Error "<< e.getErrorCode() << ": " << e.what() << "\n"; - } - - throw ExceptionBase( 112, "This exception wasn't caught!"); -} diff --git a/src/tests/hash.cpp b/src/tests/hash.cpp new file mode 100644 index 0000000..d0f5fa6 --- /dev/null +++ b/src/tests/hash.cpp @@ -0,0 +1,10 @@ +#include "hash.h" +#include "staticstring.h" + +int main() +{ + //Hash sTest; + + //sTest.hasKey("hello"); +} + diff --git a/src/tests/hash/main.cpp b/src/tests/hash/main.cpp deleted file mode 100644 index d0f5fa6..0000000 --- a/src/tests/hash/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "hash.h" -#include "staticstring.h" - -int main() -{ - //Hash sTest; - - //sTest.hasKey("hello"); -} - diff --git a/src/tests/hashtest.cpp b/src/tests/hashtest.cpp new file mode 100644 index 0000000..f31a3f8 --- /dev/null +++ b/src/tests/hashtest.cpp @@ -0,0 +1,107 @@ +#include +#include +#include "hashtable.h" +#include "hashfunctioncasestring.h" + +int main() +{ + const char *names[]={ + "Homer the Great", + "And Maggie Makes Three", + "Bart's Comet", + "Homie The Clown", + "Bart Vs Australia", + "Homer vs Patty and Selma", + "A star is burns", + "Lisa's Wedding", + "Two Dozen and One Greyhounds", + "The PTA Disbands", + "Round Springfield", + "The Springfield connection", + "Lemon of Troy", + "Who Shot Mr. Burns (Pt. 1)", + "Who Shot Mr. Burns (pt. 2)", + "Radioactive Man", + "Home Sweet Homediddly-dum-doodly", + "Bart Sells His Soul", + "Lisa the Vegetarian", + "Treehouse of horror VI", + "King Size Homer", + "Mother Simpson", + "Sideshow Bob's Last Gleaming", + "The Simpson's 138th Show Spectacular", + "Marge Be Not Proud", + "Team Homer", + "Two Bad Neighbors", + "Scenes From the Class Struggle in Springfield", + "Bart the Fink", + "Lisa the Iconoclast", + "Homer the Smithers", + "The Day the Violence Died", + "A Fish Called Selma", + "Bart on the road", + "22 Short Films about Springfield", + "The Curse of the Flying Hellfish", + "Much Apu about Nothing", + "Homerpalooza", + "The Summer of 4 Ft 2", + "Treehouse of Horror VII", + "You Only Move Twice", + "The Homer They Fall", + "Burns Baby Burns", + "Bart After Dark", + "A Millhouse Divided", + "Lisas Date With Destiny", + "Hurricane Neddy", + "The Mysterious Voyage of Our Homer", + "The Springfield Files", + "The Twisted World of Marge Simpson", + "Mountain of Madness", + NULL + }; + + HashTable h( new HashFunctionCaseString(), 5, false ); + + int j; + printf("Inserting...\n"); + for( j = 0; j < 10; j++ ) + { + h.insert( names[j], (void *)(j+1) ); + h.insert( names[j], (void *)(j+1) ); + printf("Capacity: %d, Size: %d, Load: %f\n", + h.getCapacity(), + h.getSize(), + h.getLoad() + ); + } + + for( j = 0; j < 10; j++ ) + { + printf("\"%s\" = %d\n", names[j], (int)h[names[j]] ); + } + + printf("\nDeleting some...\n"); + + for( int k = 0; k < 7; k++ ) + { + h.del( names[k] ); + //h.insert( names[j], (void *)(j+1) ); + printf("Capacity: %d, Size: %d, Load: %f\n", + h.getCapacity(), + h.getSize(), + h.getLoad() + ); + } + + printf("\nInserting more...\n"); + + for( ; names[j] != NULL; j++ ) + { + h.insert( names[j], (void *)(j+1) ); + printf("Capacity: %d, Size: %d, Load: %f\n", + h.getCapacity(), + h.getSize(), + h.getLoad() + ); + } +} diff --git a/src/tests/hashtest/hashtest.cpp b/src/tests/hashtest/hashtest.cpp deleted file mode 100644 index f31a3f8..0000000 --- a/src/tests/hashtest/hashtest.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include -#include "hashtable.h" -#include "hashfunctioncasestring.h" - -int main() -{ - const char *names[]={ - "Homer the Great", - "And Maggie Makes Three", - "Bart's Comet", - "Homie The Clown", - "Bart Vs Australia", - "Homer vs Patty and Selma", - "A star is burns", - "Lisa's Wedding", - "Two Dozen and One Greyhounds", - "The PTA Disbands", - "Round Springfield", - "The Springfield connection", - "Lemon of Troy", - "Who Shot Mr. Burns (Pt. 1)", - "Who Shot Mr. Burns (pt. 2)", - "Radioactive Man", - "Home Sweet Homediddly-dum-doodly", - "Bart Sells His Soul", - "Lisa the Vegetarian", - "Treehouse of horror VI", - "King Size Homer", - "Mother Simpson", - "Sideshow Bob's Last Gleaming", - "The Simpson's 138th Show Spectacular", - "Marge Be Not Proud", - "Team Homer", - "Two Bad Neighbors", - "Scenes From the Class Struggle in Springfield", - "Bart the Fink", - "Lisa the Iconoclast", - "Homer the Smithers", - "The Day the Violence Died", - "A Fish Called Selma", - "Bart on the road", - "22 Short Films about Springfield", - "The Curse of the Flying Hellfish", - "Much Apu about Nothing", - "Homerpalooza", - "The Summer of 4 Ft 2", - "Treehouse of Horror VII", - "You Only Move Twice", - "The Homer They Fall", - "Burns Baby Burns", - "Bart After Dark", - "A Millhouse Divided", - "Lisas Date With Destiny", - "Hurricane Neddy", - "The Mysterious Voyage of Our Homer", - "The Springfield Files", - "The Twisted World of Marge Simpson", - "Mountain of Madness", - NULL - }; - - HashTable h( new HashFunctionCaseString(), 5, false ); - - int j; - printf("Inserting...\n"); - for( j = 0; j < 10; j++ ) - { - h.insert( names[j], (void *)(j+1) ); - h.insert( names[j], (void *)(j+1) ); - printf("Capacity: %d, Size: %d, Load: %f\n", - h.getCapacity(), - h.getSize(), - h.getLoad() - ); - } - - for( j = 0; j < 10; j++ ) - { - printf("\"%s\" = %d\n", names[j], (int)h[names[j]] ); - } - - printf("\nDeleting some...\n"); - - for( int k = 0; k < 7; k++ ) - { - h.del( names[k] ); - //h.insert( names[j], (void *)(j+1) ); - printf("Capacity: %d, Size: %d, Load: %f\n", - h.getCapacity(), - h.getSize(), - h.getLoad() - ); - } - - printf("\nInserting more...\n"); - - for( ; names[j] != NULL; j++ ) - { - h.insert( names[j], (void *)(j+1) ); - printf("Capacity: %d, Size: %d, Load: %f\n", - h.getCapacity(), - h.getSize(), - h.getLoad() - ); - } -} diff --git a/src/tests/log.cpp b/src/tests/log.cpp new file mode 100644 index 0000000..d7cfa0b --- /dev/null +++ b/src/tests/log.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include "multilog.h" +#include "multilogtext.h" + +class Test +{ +public: + Test() + { + MultiLineLog( 4, "Test init'd\n"); + } +}; + +int main() +{ + MultiLog &xLog = MultiLog::getInstance(); + + xLog.LineLog( 2, "Hello again"); + + MultiLog::getInstance().addChannel( + new MultiLogText( STDOUT_FILENO, "%02y-%02m-%02d %02h:%02M:%02s: %t" ) + ); + + MultiLineLog( MultiLog::LError, "Hi there!"); + Test t; +} + diff --git a/src/tests/log/log.cpp b/src/tests/log/log.cpp deleted file mode 100644 index d7cfa0b..0000000 --- a/src/tests/log/log.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include "multilog.h" -#include "multilogtext.h" - -class Test -{ -public: - Test() - { - MultiLineLog( 4, "Test init'd\n"); - } -}; - -int main() -{ - MultiLog &xLog = MultiLog::getInstance(); - - xLog.LineLog( 2, "Hello again"); - - MultiLog::getInstance().addChannel( - new MultiLogText( STDOUT_FILENO, "%02y-%02m-%02d %02h:%02M:%02s: %t" ) - ); - - MultiLineLog( MultiLog::LError, "Hi there!"); - Test t; -} - diff --git a/src/tests/md5test.cpp b/src/tests/md5test.cpp new file mode 100644 index 0000000..6f832df --- /dev/null +++ b/src/tests/md5test.cpp @@ -0,0 +1,19 @@ +#include +#include +#include "md5.h" + +int main() +{ + md5 mproc; + md5sum sum; + char hexstr[33]; + + memset( hexstr, 0, 33 ); + + mproc.sumString( &sum, "qwertyuiopasdfgh" ); + mproc.sumToHex( &sum, hexstr ); + printf("sum: %s\n", hexstr ); + printf("chk: 1ebfc043d8880b758b13ddc8aa1638ef\n"); + + return 0; +} diff --git a/src/tests/md5test/md5test.cpp b/src/tests/md5test/md5test.cpp deleted file mode 100644 index 6f832df..0000000 --- a/src/tests/md5test/md5test.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include "md5.h" - -int main() -{ - md5 mproc; - md5sum sum; - char hexstr[33]; - - memset( hexstr, 0, 33 ); - - mproc.sumString( &sum, "qwertyuiopasdfgh" ); - mproc.sumToHex( &sum, hexstr ); - printf("sum: %s\n", hexstr ); - printf("chk: 1ebfc043d8880b758b13ddc8aa1638ef\n"); - - return 0; -} diff --git a/src/tests/param.cpp b/src/tests/param.cpp new file mode 100644 index 0000000..a4d2824 --- /dev/null +++ b/src/tests/param.cpp @@ -0,0 +1,46 @@ +#include "param.h" +#include + +Param::Param() +{ + addHelpBanner("param - A test of the libbu++ parameter systems\n" + "Enjoy with care and caution\n\nTest stuff:\n"); + addParam( "name", 's', mkproc( Param::printStuff ), &str, "Test a param param" ); + //addParam( "name", &str ); + addParam( "job", 'U', mkproc( Param::printStuff ), "Test a paramless param" ); + + addHelpBanner("\nInformational:\n"); + addParam( "help", mkproc( ParamProc::help ), "Help!" ); + + addHelpBanner("\nThanks for trying my test!\n\n"); +} + +Param::~Param() +{ +} + +int Param::printStuff( int argc, char *argv[] ) +{ + printf("------------%02d-------------\n", argc ); + for( int j = 0; j < argc; j++ ) + { + printf("%d: %s\n", j, argv[j] ); + } + printf("---------------------------\n" ); + printf("SETVAR===\"%s\"\n", str.c_str() ); + + return 1; +} + +int main( int argc, char *argv[] ) +{ + if( argc == 1 ) + { + printf("You have to enter some parameter, try '--help'\n\n"); + return 0; + } + + Param p; + p.process( argc, argv ); +} + diff --git a/src/tests/param.h b/src/tests/param.h new file mode 100644 index 0000000..2756b69 --- /dev/null +++ b/src/tests/param.h @@ -0,0 +1,21 @@ +#ifndef PARAM_H +#define PARAM_H + +#include + +#include "paramproc.h" + +class Param : public ParamProc +{ +public: + Param(); + virtual ~Param(); + +private: + int printStuff( int argc, char *argv[] ); + + std::string str; + uint32_t uint32; +}; + +#endif diff --git a/src/tests/param/param.cpp b/src/tests/param/param.cpp deleted file mode 100644 index a4d2824..0000000 --- a/src/tests/param/param.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "param.h" -#include - -Param::Param() -{ - addHelpBanner("param - A test of the libbu++ parameter systems\n" - "Enjoy with care and caution\n\nTest stuff:\n"); - addParam( "name", 's', mkproc( Param::printStuff ), &str, "Test a param param" ); - //addParam( "name", &str ); - addParam( "job", 'U', mkproc( Param::printStuff ), "Test a paramless param" ); - - addHelpBanner("\nInformational:\n"); - addParam( "help", mkproc( ParamProc::help ), "Help!" ); - - addHelpBanner("\nThanks for trying my test!\n\n"); -} - -Param::~Param() -{ -} - -int Param::printStuff( int argc, char *argv[] ) -{ - printf("------------%02d-------------\n", argc ); - for( int j = 0; j < argc; j++ ) - { - printf("%d: %s\n", j, argv[j] ); - } - printf("---------------------------\n" ); - printf("SETVAR===\"%s\"\n", str.c_str() ); - - return 1; -} - -int main( int argc, char *argv[] ) -{ - if( argc == 1 ) - { - printf("You have to enter some parameter, try '--help'\n\n"); - return 0; - } - - Param p; - p.process( argc, argv ); -} - diff --git a/src/tests/param/param.h b/src/tests/param/param.h deleted file mode 100644 index 2756b69..0000000 --- a/src/tests/param/param.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef PARAM_H -#define PARAM_H - -#include - -#include "paramproc.h" - -class Param : public ParamProc -{ -public: - Param(); - virtual ~Param(); - -private: - int printStuff( int argc, char *argv[] ); - - std::string str; - uint32_t uint32; -}; - -#endif diff --git a/src/tests/serialize.cpp b/src/tests/serialize.cpp new file mode 100644 index 0000000..e233704 --- /dev/null +++ b/src/tests/serialize.cpp @@ -0,0 +1,30 @@ +#include "serializerbinary.h" +#include "staticstring.h" +#include +#include + +int main() +{ + int32_t one; + double two; + bool three; + StaticString s("Test string!"); + std::string ss("Another test string"); + SerializerBinary ar("hello.dat", false); + ar << (int)85; + ar << (double)2.63434; + ar << false; + ar << ss; + ar.close(); + + one = 0; two = 0; three = true; s = "die"; + + SerializerBinary ar2("hello.dat", true); + ar2 >> one; + ar2 >> two; + ar2 >> three; + ar2 >> s; + + printf("we got %d - %f - %s - \"%s\"\n", one, two, (three ? "true":"false"), s.getString() ); + return 0; +} diff --git a/src/tests/serialize/serialize.cpp b/src/tests/serialize/serialize.cpp deleted file mode 100644 index e233704..0000000 --- a/src/tests/serialize/serialize.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "serializerbinary.h" -#include "staticstring.h" -#include -#include - -int main() -{ - int32_t one; - double two; - bool three; - StaticString s("Test string!"); - std::string ss("Another test string"); - SerializerBinary ar("hello.dat", false); - ar << (int)85; - ar << (double)2.63434; - ar << false; - ar << ss; - ar.close(); - - one = 0; two = 0; three = true; s = "die"; - - SerializerBinary ar2("hello.dat", true); - ar2 >> one; - ar2 >> two; - ar2 >> three; - ar2 >> s; - - printf("we got %d - %f - %s - \"%s\"\n", one, two, (three ? "true":"false"), s.getString() ); - return 0; -} diff --git a/src/tests/serializetext.cpp b/src/tests/serializetext.cpp new file mode 100644 index 0000000..f6be7d3 --- /dev/null +++ b/src/tests/serializetext.cpp @@ -0,0 +1,28 @@ +#include "serializertext.h" +#include "staticstring.h" +#include + +int main() +{ + StaticString s("You're a dog!!"); + SerializerText ar("hello.dat", false); + + ar << 4 << 3.993 << true << s; + + ar.close(); + + int one=0;float two=0.0;bool three=false; s = ""; + + SerializerText ar2("hello.dat", true); + + ar2 >> one; + ar2 >> two; + ar2 >> three; + ar2 >> s; + + //printf("out: %d, %f, %s, \"%s\"\n", one, two, (three ? "true" : "false"), s.getString()); + std::cout << one << ", " << two << ", " << three << ", " << s.getString() << "\n"; + + return 0; +} + diff --git a/src/tests/serializetext/serializetext.cpp b/src/tests/serializetext/serializetext.cpp deleted file mode 100644 index f6be7d3..0000000 --- a/src/tests/serializetext/serializetext.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "serializertext.h" -#include "staticstring.h" -#include - -int main() -{ - StaticString s("You're a dog!!"); - SerializerText ar("hello.dat", false); - - ar << 4 << 3.993 << true << s; - - ar.close(); - - int one=0;float two=0.0;bool three=false; s = ""; - - SerializerText ar2("hello.dat", true); - - ar2 >> one; - ar2 >> two; - ar2 >> three; - ar2 >> s; - - //printf("out: %d, %f, %s, \"%s\"\n", one, two, (three ? "true" : "false"), s.getString()); - std::cout << one << ", " << two << ", " << three << ", " << s.getString() << "\n"; - - return 0; -} - diff --git a/src/tests/srvstress.cpp b/src/tests/srvstress.cpp new file mode 100644 index 0000000..7fe7657 --- /dev/null +++ b/src/tests/srvstress.cpp @@ -0,0 +1,90 @@ +#include "connectionmanager.h" +#include "programlink.h" +#include "linkedlist.h" +#include "protocol.h" + +class StressProtocol : public Protocol +{ +public: + bool onNewData() + { + switch( getConnection()->getInput()[0] ) + { + case 'd': + throw "Hello"; + break; + + case 'w': + getConnection()->appendOutput("Hello"); + break; + }; + + return true; + } + + bool onNewConnection() + { + return true; + } +}; + +class StressMonitor : public ConnectionMonitor, public ProgramLink +{ +public: + bool init() + { + return true; + } + + bool deInit() + { + return true; + } + + bool timeSlice() + { + } + + bool onNewConnection( Connection *pCon, int nPort ) + { + StressProtocol *sp = new StressProtocol(); + pCon->setProtocol( sp ); + + printf(" sys: New connection: socket(%d), port(%d)\n", + pCon->getSocket(), nPort ); + + return true; + } + + bool onClosedConnection( Connection *pCon ) + { + printf(" sys: Closed connection: socket(%d)\n", + pCon->getSocket() ); + + return true; + } + + LinkMessage *processIRM( LinkMessage *pMsg ) + { + return NULL; + } +}; + +int main() +{ + printf("Starting server...\n"); + + ConnectionManager srv; + StressMonitor telnet; + + srv.setConnectionMonitor( &telnet ); + + srv.startServer( 4001 ); + + for(;;) + { + srv.scanConnections( 5000, false ); + } + + return 0; +} diff --git a/src/tests/srvstress/main.cpp b/src/tests/srvstress/main.cpp deleted file mode 100644 index 7fe7657..0000000 --- a/src/tests/srvstress/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "connectionmanager.h" -#include "programlink.h" -#include "linkedlist.h" -#include "protocol.h" - -class StressProtocol : public Protocol -{ -public: - bool onNewData() - { - switch( getConnection()->getInput()[0] ) - { - case 'd': - throw "Hello"; - break; - - case 'w': - getConnection()->appendOutput("Hello"); - break; - }; - - return true; - } - - bool onNewConnection() - { - return true; - } -}; - -class StressMonitor : public ConnectionMonitor, public ProgramLink -{ -public: - bool init() - { - return true; - } - - bool deInit() - { - return true; - } - - bool timeSlice() - { - } - - bool onNewConnection( Connection *pCon, int nPort ) - { - StressProtocol *sp = new StressProtocol(); - pCon->setProtocol( sp ); - - printf(" sys: New connection: socket(%d), port(%d)\n", - pCon->getSocket(), nPort ); - - return true; - } - - bool onClosedConnection( Connection *pCon ) - { - printf(" sys: Closed connection: socket(%d)\n", - pCon->getSocket() ); - - return true; - } - - LinkMessage *processIRM( LinkMessage *pMsg ) - { - return NULL; - } -}; - -int main() -{ - printf("Starting server...\n"); - - ConnectionManager srv; - StressMonitor telnet; - - srv.setConnectionMonitor( &telnet ); - - srv.startServer( 4001 ); - - for(;;) - { - srv.scanConnections( 5000, false ); - } - - return 0; -} diff --git a/src/tests/strhash.cpp b/src/tests/strhash.cpp new file mode 100644 index 0000000..790c5b6 --- /dev/null +++ b/src/tests/strhash.cpp @@ -0,0 +1,12 @@ +#include +#include "hashfunctionstring.h" + +int main( int argc, char *argv[] ) +{ + HashFunctionString h; + + printf("\"%s\": %d\n", argv[1], h.hash( argv[1] ) ); + + return 0; +} + diff --git a/src/tests/strhash/main.cpp b/src/tests/strhash/main.cpp deleted file mode 100644 index 790c5b6..0000000 --- a/src/tests/strhash/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "hashfunctionstring.h" - -int main( int argc, char *argv[] ) -{ - HashFunctionString h; - - printf("\"%s\": %d\n", argv[1], h.hash( argv[1] ) ); - - return 0; -} - diff --git a/src/tests/xmlreadtest.cpp b/src/tests/xmlreadtest.cpp new file mode 100644 index 0000000..98d8a9e --- /dev/null +++ b/src/tests/xmlreadtest.cpp @@ -0,0 +1,29 @@ +#include "xmlfilereader.h" +#include "xmlstringreader.h" +#include "xmlfilewriter.h" + +int main( int argc, char *argv[] ) +{ + if( argc < 4 ) + { + printf("Usage: %s f \n", argv[0] ); + printf(" %s s \n\n", argv[0] ); + return 0; + } + + if( argv[1][0] == 'f' ) + { + XmlFileReader r( argv[2], true ); +// XmlFileWriter w( argv[3], "\t", r.detatchRoot() ); +// w.write(); + } + else if( argv[1][0] == 's' ) + { + XmlStringReader r( argv[2], true ); +// XmlWriter w( argv[3], "\t", r.detatchRoot() ); +// w.write(); + } + + return 0; +} + diff --git a/src/tests/xmlreadtest/xmlreadtest.cpp b/src/tests/xmlreadtest/xmlreadtest.cpp deleted file mode 100644 index 98d8a9e..0000000 --- a/src/tests/xmlreadtest/xmlreadtest.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "xmlfilereader.h" -#include "xmlstringreader.h" -#include "xmlfilewriter.h" - -int main( int argc, char *argv[] ) -{ - if( argc < 4 ) - { - printf("Usage: %s f \n", argv[0] ); - printf(" %s s \n\n", argv[0] ); - return 0; - } - - if( argv[1][0] == 'f' ) - { - XmlFileReader r( argv[2], true ); -// XmlFileWriter w( argv[3], "\t", r.detatchRoot() ); -// w.write(); - } - else if( argv[1][0] == 's' ) - { - XmlStringReader r( argv[2], true ); -// XmlWriter w( argv[3], "\t", r.detatchRoot() ); -// w.write(); - } - - return 0; -} - diff --git a/src/tests/xmlrepltest.cpp b/src/tests/xmlrepltest.cpp new file mode 100644 index 0000000..1fe9ec2 --- /dev/null +++ b/src/tests/xmlrepltest.cpp @@ -0,0 +1,31 @@ +#include "xmlwriter.h" + +int main() +{ + printf("Testing Xml Replacement...\n"); + XmlDocument w; + + w.addNode("text"); + w.setContent("this text is before the node. "); + w.addNode("keepme", "This one we keep...", true ); + w.setContent("this text is after."); + w.addNode("deleteme", "This one we don't...", true ); + w.setContent("this is last..." ); + w.closeNode(); + + //XmlWriter::writeNode( stdout, w.getRoot(), 0, NULL ); + + printf("\n\n"); + + XmlNode *xNode = w.getRoot()->detatchNode( 1 ); + + //XmlWriter::writeNode( stdout, w.getRoot(), 0, NULL ); + + printf("\n\n"); + + //XmlWriter::writeNode( stdout, xNode, 0, NULL ); + + printf("\n\n"); + + return 0; +} diff --git a/src/tests/xmlrepltest/xmlrepltest.cpp b/src/tests/xmlrepltest/xmlrepltest.cpp deleted file mode 100644 index 1fe9ec2..0000000 --- a/src/tests/xmlrepltest/xmlrepltest.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "xmlwriter.h" - -int main() -{ - printf("Testing Xml Replacement...\n"); - XmlDocument w; - - w.addNode("text"); - w.setContent("this text is before the node. "); - w.addNode("keepme", "This one we keep...", true ); - w.setContent("this text is after."); - w.addNode("deleteme", "This one we don't...", true ); - w.setContent("this is last..." ); - w.closeNode(); - - //XmlWriter::writeNode( stdout, w.getRoot(), 0, NULL ); - - printf("\n\n"); - - XmlNode *xNode = w.getRoot()->detatchNode( 1 ); - - //XmlWriter::writeNode( stdout, w.getRoot(), 0, NULL ); - - printf("\n\n"); - - //XmlWriter::writeNode( stdout, xNode, 0, NULL ); - - printf("\n\n"); - - return 0; -} -- cgit v1.2.3