From 937d960d2677c87ac6d68dc5445be115ac001d3e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 29 Jun 2006 05:50:44 +0000 Subject: Completely switched over to the much simpler, nicer pymake. Things look great, and the old Makefile may soon fall into disrepair. To use the old one, which should almost always be able to build at least thi library, call: make -f Makefile.legacy The new Makefile just calls pymake --- src/test/hashtest.cpp | 107 ------------------------------- src/test/hashtest/hashtest.cpp | 107 +++++++++++++++++++++++++++++++ src/test/log.cpp | 29 --------- src/test/log/log.cpp | 29 +++++++++ src/test/md5test.cpp | 19 ------ src/test/md5test/md5test.cpp | 19 ++++++ src/test/param.cpp | 46 ------------- src/test/param.h | 21 ------ src/test/param/param.cpp | 46 +++++++++++++ src/test/param/param.h | 21 ++++++ src/test/serialize.cpp | 30 --------- src/test/serialize/serialize.cpp | 30 +++++++++ src/test/serializetext.cpp | 28 -------- src/test/serializetext/serializetext.cpp | 28 ++++++++ src/test/xmlreadtest.cpp | 29 --------- src/test/xmlreadtest/xmlreadtest.cpp | 29 +++++++++ src/test/xmlrepltest.cpp | 31 --------- src/test/xmlrepltest/xmlrepltest.cpp | 31 +++++++++ src/test/xmlwritetest.cpp | 41 ------------ src/test/xmlwritetest/xmlwritetest.cpp | 41 ++++++++++++ src/unit/hashtable.cpp | 107 ------------------------------- src/unit/hashtable/hashtable.cpp | 107 +++++++++++++++++++++++++++++++ src/unit/xml.cpp | 59 ----------------- src/unit/xml/xml.cpp | 59 +++++++++++++++++ 24 files changed, 547 insertions(+), 547 deletions(-) delete mode 100644 src/test/hashtest.cpp create mode 100644 src/test/hashtest/hashtest.cpp delete mode 100644 src/test/log.cpp create mode 100644 src/test/log/log.cpp delete mode 100644 src/test/md5test.cpp create mode 100644 src/test/md5test/md5test.cpp delete mode 100644 src/test/param.cpp delete mode 100644 src/test/param.h create mode 100644 src/test/param/param.cpp create mode 100644 src/test/param/param.h delete mode 100644 src/test/serialize.cpp create mode 100644 src/test/serialize/serialize.cpp delete mode 100644 src/test/serializetext.cpp create mode 100644 src/test/serializetext/serializetext.cpp delete mode 100644 src/test/xmlreadtest.cpp create mode 100644 src/test/xmlreadtest/xmlreadtest.cpp delete mode 100644 src/test/xmlrepltest.cpp create mode 100644 src/test/xmlrepltest/xmlrepltest.cpp delete mode 100644 src/test/xmlwritetest.cpp create mode 100644 src/test/xmlwritetest/xmlwritetest.cpp delete mode 100644 src/unit/hashtable.cpp create mode 100644 src/unit/hashtable/hashtable.cpp delete mode 100644 src/unit/xml.cpp create mode 100644 src/unit/xml/xml.cpp (limited to 'src') diff --git a/src/test/hashtest.cpp b/src/test/hashtest.cpp deleted file mode 100644 index f31a3f8..0000000 --- a/src/test/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/test/hashtest/hashtest.cpp b/src/test/hashtest/hashtest.cpp new file mode 100644 index 0000000..f31a3f8 --- /dev/null +++ b/src/test/hashtest/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/test/log.cpp b/src/test/log.cpp deleted file mode 100644 index d7cfa0b..0000000 --- a/src/test/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/test/log/log.cpp b/src/test/log/log.cpp new file mode 100644 index 0000000..d7cfa0b --- /dev/null +++ b/src/test/log/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/test/md5test.cpp b/src/test/md5test.cpp deleted file mode 100644 index 6f832df..0000000 --- a/src/test/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/test/md5test/md5test.cpp b/src/test/md5test/md5test.cpp new file mode 100644 index 0000000..6f832df --- /dev/null +++ b/src/test/md5test/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/test/param.cpp b/src/test/param.cpp deleted file mode 100644 index a4d2824..0000000 --- a/src/test/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/test/param.h b/src/test/param.h deleted file mode 100644 index 2756b69..0000000 --- a/src/test/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/test/param/param.cpp b/src/test/param/param.cpp new file mode 100644 index 0000000..a4d2824 --- /dev/null +++ b/src/test/param/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/test/param/param.h b/src/test/param/param.h new file mode 100644 index 0000000..2756b69 --- /dev/null +++ b/src/test/param/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/test/serialize.cpp b/src/test/serialize.cpp deleted file mode 100644 index e233704..0000000 --- a/src/test/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/test/serialize/serialize.cpp b/src/test/serialize/serialize.cpp new file mode 100644 index 0000000..e233704 --- /dev/null +++ b/src/test/serialize/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/test/serializetext.cpp b/src/test/serializetext.cpp deleted file mode 100644 index f6be7d3..0000000 --- a/src/test/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/test/serializetext/serializetext.cpp b/src/test/serializetext/serializetext.cpp new file mode 100644 index 0000000..f6be7d3 --- /dev/null +++ b/src/test/serializetext/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/test/xmlreadtest.cpp b/src/test/xmlreadtest.cpp deleted file mode 100644 index e2d2a0a..0000000 --- a/src/test/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/test/xmlreadtest/xmlreadtest.cpp b/src/test/xmlreadtest/xmlreadtest.cpp new file mode 100644 index 0000000..e2d2a0a --- /dev/null +++ b/src/test/xmlreadtest/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/test/xmlrepltest.cpp b/src/test/xmlrepltest.cpp deleted file mode 100644 index 1fe9ec2..0000000 --- a/src/test/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; -} diff --git a/src/test/xmlrepltest/xmlrepltest.cpp b/src/test/xmlrepltest/xmlrepltest.cpp new file mode 100644 index 0000000..1fe9ec2 --- /dev/null +++ b/src/test/xmlrepltest/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/test/xmlwritetest.cpp b/src/test/xmlwritetest.cpp deleted file mode 100644 index 2986c35..0000000 --- a/src/test/xmlwritetest.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "xmlfilewriter.h" -#include "xmlstringwriter.h" - -void fillItIn( XmlWriter &w ) -{ - w.addNode("thinglist"); - - w.addNode("thing"); - w.addProperty("type", "Weapon"); - - w.addNode("id", "Klophin Staff", true ); - w.addNode("name", "Klophin Staff", true ); - w.addNode("durability", "0.01", true ); - w.addNode("size", "0.1", true ); - - w.addNode("config"); - w.addNode("damage", "3d6+4", true ); - w.addNode("class", "melee", true ); - w.addNode("type", "bludgeon", true ); - w.addNode("damagedesc", "club/clubs", true ); - w.closeNode(); - - w.closeNode(); - - w.closeNode(); -} - -int main() -{ - printf("Testing XmlWriter...\n"); - //XmlFileWriter wf("test.xml", "\t"); - - //fillItIn( wf ); - - //XmlStringWriter ws("\t"); - //fillItIn( ws ); - - //printf("Now the string version:\n\n%s\n", ws.getString().c_str() ); - - return 0; -} diff --git a/src/test/xmlwritetest/xmlwritetest.cpp b/src/test/xmlwritetest/xmlwritetest.cpp new file mode 100644 index 0000000..2986c35 --- /dev/null +++ b/src/test/xmlwritetest/xmlwritetest.cpp @@ -0,0 +1,41 @@ +#include "xmlfilewriter.h" +#include "xmlstringwriter.h" + +void fillItIn( XmlWriter &w ) +{ + w.addNode("thinglist"); + + w.addNode("thing"); + w.addProperty("type", "Weapon"); + + w.addNode("id", "Klophin Staff", true ); + w.addNode("name", "Klophin Staff", true ); + w.addNode("durability", "0.01", true ); + w.addNode("size", "0.1", true ); + + w.addNode("config"); + w.addNode("damage", "3d6+4", true ); + w.addNode("class", "melee", true ); + w.addNode("type", "bludgeon", true ); + w.addNode("damagedesc", "club/clubs", true ); + w.closeNode(); + + w.closeNode(); + + w.closeNode(); +} + +int main() +{ + printf("Testing XmlWriter...\n"); + //XmlFileWriter wf("test.xml", "\t"); + + //fillItIn( wf ); + + //XmlStringWriter ws("\t"); + //fillItIn( ws ); + + //printf("Now the string version:\n\n%s\n", ws.getString().c_str() ); + + return 0; +} diff --git a/src/unit/hashtable.cpp b/src/unit/hashtable.cpp deleted file mode 100644 index b2e1cf5..0000000 --- a/src/unit/hashtable.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "hashfunctionstring.h" -#include "hashfunctioncasestring.h" -#include "hashfunctionint.h" - -class HashFunctionSuite : public Test::Suite -{ -public: - HashFunctionSuite() - { - TEST_ADD( HashFunctionSuite::functionString ) - TEST_ADD( HashFunctionSuite::functionCaseString ) - TEST_ADD( HashFunctionSuite::functionInt ) - } - -private: - void functionStringWorker( HashFunction &hf, std::set &sCodes, char *str, int nLevel, int nMax ) - { - for( char let = 'A'; let <= 'z'; let += 3 ) - { - str[nLevel+1] = '\0'; - str[nLevel] = let; - unsigned long x = hf.hash( str ); - TEST_ASSERT( sCodes.find( x ) == sCodes.end() ); - TEST_ASSERT( hf.cmpIDs( str, str ) ); - sCodes.insert( x ); - - if( nLevel < nMax ) - functionStringWorker( hf, sCodes, str, nLevel+1, nMax ); - } - } - - void functionString() - { - HashFunctionString hf; - char str[10]; - - std::set sCodes; - - functionStringWorker( hf, sCodes, str, 0, 3 ); - } - - void functionCaseStringWorker( HashFunction &hf, std::map &sCodes, char *str, int nLevel, int nMax ) - { - for( char let = 'A'; let <= 'z'; let += 3 ) - { - str[nLevel+1] = '\0'; - str[nLevel] = let; - unsigned long x = hf.hash( str ); - std::map::iterator i = sCodes.find( x ); - if( i == sCodes.end() ) - { - sCodes[x] = strdup( str ); - } - else - { - TEST_ASSERT( strcasecmp( (*i).second, str ) == 0 ); - TEST_ASSERT( hf.cmpIDs( (*i).second, str ) == true ); - } - - if( nLevel < nMax ) - functionCaseStringWorker( hf, sCodes, str, nLevel+1, nMax ); - } - } - - void functionCaseString() - { - HashFunctionCaseString hf; - char str[10]; - - std::map sCodes; - - functionCaseStringWorker( hf, sCodes, str, 0, 3 ); - - std::map::iterator i; - for( i = sCodes.begin(); i != sCodes.end(); i++ ) - { - free( (*i).second ); - } - } - - void functionInt() - { - HashFunctionInt hf; - - for( long i = -100000; i <= 100000; i += 100 ) - { - TEST_ASSERT( ((long)hf.hash( (void *)i )) == i ); - TEST_ASSERT( ((long)hf.cmpIDs( (void *)i, (void *)i )) ); - } - } -}; - -int main( int argc, char *argv[] ) -{ - Test::TextOutput output( Test::TextOutput::Verbose ); - HashFunctionSuite ts; - return ts.run( output ) ? EXIT_SUCCESS : EXIT_FAILURE; -} - diff --git a/src/unit/hashtable/hashtable.cpp b/src/unit/hashtable/hashtable.cpp new file mode 100644 index 0000000..b2e1cf5 --- /dev/null +++ b/src/unit/hashtable/hashtable.cpp @@ -0,0 +1,107 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "hashfunctionstring.h" +#include "hashfunctioncasestring.h" +#include "hashfunctionint.h" + +class HashFunctionSuite : public Test::Suite +{ +public: + HashFunctionSuite() + { + TEST_ADD( HashFunctionSuite::functionString ) + TEST_ADD( HashFunctionSuite::functionCaseString ) + TEST_ADD( HashFunctionSuite::functionInt ) + } + +private: + void functionStringWorker( HashFunction &hf, std::set &sCodes, char *str, int nLevel, int nMax ) + { + for( char let = 'A'; let <= 'z'; let += 3 ) + { + str[nLevel+1] = '\0'; + str[nLevel] = let; + unsigned long x = hf.hash( str ); + TEST_ASSERT( sCodes.find( x ) == sCodes.end() ); + TEST_ASSERT( hf.cmpIDs( str, str ) ); + sCodes.insert( x ); + + if( nLevel < nMax ) + functionStringWorker( hf, sCodes, str, nLevel+1, nMax ); + } + } + + void functionString() + { + HashFunctionString hf; + char str[10]; + + std::set sCodes; + + functionStringWorker( hf, sCodes, str, 0, 3 ); + } + + void functionCaseStringWorker( HashFunction &hf, std::map &sCodes, char *str, int nLevel, int nMax ) + { + for( char let = 'A'; let <= 'z'; let += 3 ) + { + str[nLevel+1] = '\0'; + str[nLevel] = let; + unsigned long x = hf.hash( str ); + std::map::iterator i = sCodes.find( x ); + if( i == sCodes.end() ) + { + sCodes[x] = strdup( str ); + } + else + { + TEST_ASSERT( strcasecmp( (*i).second, str ) == 0 ); + TEST_ASSERT( hf.cmpIDs( (*i).second, str ) == true ); + } + + if( nLevel < nMax ) + functionCaseStringWorker( hf, sCodes, str, nLevel+1, nMax ); + } + } + + void functionCaseString() + { + HashFunctionCaseString hf; + char str[10]; + + std::map sCodes; + + functionCaseStringWorker( hf, sCodes, str, 0, 3 ); + + std::map::iterator i; + for( i = sCodes.begin(); i != sCodes.end(); i++ ) + { + free( (*i).second ); + } + } + + void functionInt() + { + HashFunctionInt hf; + + for( long i = -100000; i <= 100000; i += 100 ) + { + TEST_ASSERT( ((long)hf.hash( (void *)i )) == i ); + TEST_ASSERT( ((long)hf.cmpIDs( (void *)i, (void *)i )) ); + } + } +}; + +int main( int argc, char *argv[] ) +{ + Test::TextOutput output( Test::TextOutput::Verbose ); + HashFunctionSuite ts; + return ts.run( output ) ? EXIT_SUCCESS : EXIT_FAILURE; +} + diff --git a/src/unit/xml.cpp b/src/unit/xml.cpp deleted file mode 100644 index e4d779c..0000000 --- a/src/unit/xml.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include -#include -#include - -#include "xmlstringreader.h" -#include "xmlexception.h" - -class XmlCoreTestSuite : public Test::Suite -{ -public: - XmlCoreTestSuite() - { - TEST_ADD( XmlCoreTestSuite::badXml01 ) - TEST_ADD( XmlCoreTestSuite::badXml02 ) - TEST_ADD( XmlCoreTestSuite::badXml03 ) - - TEST_ADD( XmlCoreTestSuite::entityBuiltin01 ) - - TEST_ADD( XmlCoreTestSuite::entityDoc01 ) - } - -private: - void badXml01() - { - TEST_THROWS( XmlStringReader r(""), XmlException & ); - } - - void badXml02() - { - TEST_THROWS( XmlStringReader r(""), XmlException & ); - } - - void badXml03() - { - TEST_THROWS( XmlStringReader r("><&'""); - TEST_ASSERT( strcmp( r.getRoot()->getContent(), "><&\'\"" ) == 0 ); - } - - void entityDoc01() - { - XmlStringReader r(""&name;""); - TEST_ASSERT( strcmp( r.getRoot()->getContent(), "\"bob the man\"" ) == 0 ); - } -}; - -int main( int argc, char *argv[] ) -{ - Test::TextOutput output( Test::TextOutput::Verbose ); - XmlCoreTestSuite ts; - return ts.run( output ) ? EXIT_SUCCESS : EXIT_FAILURE; -} - diff --git a/src/unit/xml/xml.cpp b/src/unit/xml/xml.cpp new file mode 100644 index 0000000..e4d779c --- /dev/null +++ b/src/unit/xml/xml.cpp @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include + +#include "xmlstringreader.h" +#include "xmlexception.h" + +class XmlCoreTestSuite : public Test::Suite +{ +public: + XmlCoreTestSuite() + { + TEST_ADD( XmlCoreTestSuite::badXml01 ) + TEST_ADD( XmlCoreTestSuite::badXml02 ) + TEST_ADD( XmlCoreTestSuite::badXml03 ) + + TEST_ADD( XmlCoreTestSuite::entityBuiltin01 ) + + TEST_ADD( XmlCoreTestSuite::entityDoc01 ) + } + +private: + void badXml01() + { + TEST_THROWS( XmlStringReader r(""), XmlException & ); + } + + void badXml02() + { + TEST_THROWS( XmlStringReader r(""), XmlException & ); + } + + void badXml03() + { + TEST_THROWS( XmlStringReader r("><&'""); + TEST_ASSERT( strcmp( r.getRoot()->getContent(), "><&\'\"" ) == 0 ); + } + + void entityDoc01() + { + XmlStringReader r(""&name;""); + TEST_ASSERT( strcmp( r.getRoot()->getContent(), "\"bob the man\"" ) == 0 ); + } +}; + +int main( int argc, char *argv[] ) +{ + Test::TextOutput output( Test::TextOutput::Verbose ); + XmlCoreTestSuite ts; + return ts.run( output ) ? EXIT_SUCCESS : EXIT_FAILURE; +} + -- cgit v1.2.3