diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-02-11 05:29:41 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-02-11 05:29:41 +0000 |
commit | f4b191f0ea396b58465bfba40749977780a3af58 (patch) | |
tree | 891490e91ab3b67524be67b2b71c85d84fd2f92a /src/old/tests | |
parent | 292ae9453e7fdb2f1023ed9dfc99cbcd751f8b90 (diff) | |
download | libbu++-f4b191f0ea396b58465bfba40749977780a3af58.tar.gz libbu++-f4b191f0ea396b58465bfba40749977780a3af58.tar.bz2 libbu++-f4b191f0ea396b58465bfba40749977780a3af58.tar.xz libbu++-f4b191f0ea396b58465bfba40749977780a3af58.zip |
Just removing some things that are cluttering up the source tree.
Diffstat (limited to 'src/old/tests')
33 files changed, 0 insertions, 1395 deletions
diff --git a/src/old/tests/clistress.cpp b/src/old/tests/clistress.cpp deleted file mode 100644 index 6b0ac66..0000000 --- a/src/old/tests/clistress.cpp +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | #include "connection.h" | ||
2 | |||
3 | int main() | ||
4 | { | ||
5 | Connection c; | ||
6 | |||
7 | c.open("localhost", 4001 ); | ||
8 | |||
9 | c.appendOutput("w"); | ||
10 | c.writeOutput(); | ||
11 | |||
12 | c.waitForInput( 6, 5, 0 ); | ||
13 | |||
14 | printf("read: %s\n", c.getInput() ); | ||
15 | |||
16 | c.close(); | ||
17 | |||
18 | return 0; | ||
19 | } | ||
20 | |||
diff --git a/src/old/tests/confpair.cpp b/src/old/tests/confpair.cpp deleted file mode 100644 index fb1b0d3..0000000 --- a/src/old/tests/confpair.cpp +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | #include "confpair.h" | ||
2 | #include <iostream> | ||
3 | |||
4 | using namespace std; | ||
5 | |||
6 | int main() | ||
7 | { | ||
8 | ConfPair<float> p1("DebugMode"); | ||
9 | p1.value() = 12; | ||
10 | cout << p1.value() << "\n"; | ||
11 | p1.value() = 55; | ||
12 | cout << p1.value() << "\n"; | ||
13 | |||
14 | ConfPairBase &p = p1; | ||
15 | |||
16 | p = "33.12"; | ||
17 | cout << p.getAsString(); | ||
18 | } | ||
19 | |||
diff --git a/src/old/tests/connect.cpp b/src/old/tests/connect.cpp deleted file mode 100644 index a9fca64..0000000 --- a/src/old/tests/connect.cpp +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <unistd.h> | ||
4 | #include <fcntl.h> | ||
5 | #include "connection.h" | ||
6 | |||
7 | int main() | ||
8 | { | ||
9 | Connection c; | ||
10 | c.open("127.0.0.1", 12457 ); | ||
11 | |||
12 | { | ||
13 | int newSocket = c.getSocket(); | ||
14 | int flags; | ||
15 | |||
16 | flags = fcntl(newSocket, F_GETFL, 0); | ||
17 | flags |= O_NONBLOCK; | ||
18 | if (fcntl(newSocket, F_SETFL, flags) < 0) | ||
19 | { | ||
20 | return false; | ||
21 | } | ||
22 | } | ||
23 | |||
24 | for( int i = 0; i < 50; i++ ) | ||
25 | { | ||
26 | usleep( 100000 ); | ||
27 | int nbytes = c.readInput(); | ||
28 | if( nbytes == 0 ) | ||
29 | printf("0 bytes, EOF?\n"); | ||
30 | else | ||
31 | printf("Got %d bytes, whacky...\n", nbytes ); | ||
32 | } | ||
33 | |||
34 | c.close(); | ||
35 | |||
36 | return 0; | ||
37 | } | ||
38 | |||
diff --git a/src/old/tests/exception.cpp b/src/old/tests/exception.cpp deleted file mode 100644 index 6417692..0000000 --- a/src/old/tests/exception.cpp +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | #include <iostream> | ||
2 | #include "exceptions.h" | ||
3 | |||
4 | int main() | ||
5 | { | ||
6 | try | ||
7 | { | ||
8 | throw ExceptionBase( 42, "There was an error on line: %d", __LINE__ ); | ||
9 | } | ||
10 | catch( ExceptionBase &e ) | ||
11 | { | ||
12 | std::cout << "Error "<< e.getErrorCode() << ": " << e.what() << "\n"; | ||
13 | } | ||
14 | |||
15 | throw ExceptionBase( 112, "This exception wasn't caught!"); | ||
16 | } | ||
diff --git a/src/old/tests/formula.cpp b/src/old/tests/formula.cpp deleted file mode 100644 index 976b039..0000000 --- a/src/old/tests/formula.cpp +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | #include "formula.h" | ||
2 | |||
3 | int main( int argc, char *argv[] ) | ||
4 | { | ||
5 | if( argc < 2 ) return 0; | ||
6 | |||
7 | Formula f; | ||
8 | double dOut = f.run( argv[1] ); | ||
9 | printf("%s = %f\n", argv[1], dOut ); | ||
10 | |||
11 | return 0; | ||
12 | } | ||
13 | |||
diff --git a/src/old/tests/hash.cpp b/src/old/tests/hash.cpp deleted file mode 100644 index 2fc6968..0000000 --- a/src/old/tests/hash.cpp +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | #include "hash.h" | ||
2 | #include "staticstring.h" | ||
3 | |||
4 | int main() | ||
5 | { | ||
6 | const char *names[]={ | ||
7 | "Homer the Great", | ||
8 | "And Maggie Makes Three", | ||
9 | "Bart's Comet", | ||
10 | "Homie The Clown", | ||
11 | "Bart Vs Australia", | ||
12 | "Homer vs Patty and Selma", | ||
13 | "A star is burns", | ||
14 | "Lisa's Wedding", | ||
15 | "Two Dozen and One Greyhounds", | ||
16 | "The PTA Disbands", | ||
17 | "Round Springfield", | ||
18 | "The Springfield connection", | ||
19 | "Lemon of Troy", | ||
20 | "Who Shot Mr. Burns (Pt. 1)", | ||
21 | "Who Shot Mr. Burns (pt. 2)", | ||
22 | "Radioactive Man", | ||
23 | "Home Sweet Homediddly-dum-doodly", | ||
24 | "Bart Sells His Soul", | ||
25 | "Lisa the Vegetarian", | ||
26 | "Treehouse of horror VI", | ||
27 | "King Size Homer", | ||
28 | "Mother Simpson", | ||
29 | "Sideshow Bob's Last Gleaming", | ||
30 | "The Simpson's 138th Show Spectacular", | ||
31 | "Marge Be Not Proud", | ||
32 | "Team Homer", | ||
33 | "Two Bad Neighbors", | ||
34 | "Scenes From the Class Struggle in Springfield", | ||
35 | "Bart the Fink", | ||
36 | "Lisa the Iconoclast", | ||
37 | "Homer the Smithers", | ||
38 | "The Day the Violence Died", | ||
39 | "A Fish Called Selma", | ||
40 | "Bart on the road", | ||
41 | "22 Short Films about Springfield", | ||
42 | "The Curse of the Flying Hellfish", | ||
43 | "Much Apu about Nothing", | ||
44 | "Homerpalooza", | ||
45 | "The Summer of 4 Ft 2", | ||
46 | "Treehouse of Horror VII", | ||
47 | "You Only Move Twice", | ||
48 | "The Homer They Fall", | ||
49 | "Burns Baby Burns", | ||
50 | "Bart After Dark", | ||
51 | "A Millhouse Divided", | ||
52 | "Lisas Date With Destiny", | ||
53 | "Hurricane Neddy", | ||
54 | "The Mysterious Voyage of Our Homer", | ||
55 | "The Springfield Files", | ||
56 | "The Twisted World of Marge Simpson", | ||
57 | "Mountain of Madness", | ||
58 | NULL | ||
59 | }; | ||
60 | |||
61 | Hash<const char *, int> sTest; | ||
62 | |||
63 | printf("Inserting\n-------------------\n\n"); | ||
64 | for( int j = 0; j < 33; j++ ) | ||
65 | { | ||
66 | sTest[names[j]] = j; | ||
67 | } | ||
68 | |||
69 | printf("Test1: %d, Test2: %d\n", sTest.has("Lemon of Troy"), sTest.has(std::string("Lemon of Troy").c_str() ) ); | ||
70 | |||
71 | sTest.has(std::string("Lemon of Troy").c_str() ); | ||
72 | |||
73 | printf("Getting\n-------------------\n\n"); | ||
74 | |||
75 | sTest.erase("Homer the Great"); | ||
76 | sTest["Bart's Comet"].erase(); | ||
77 | |||
78 | for( Hash<const char *, int>::iterator i = sTest.begin(); | ||
79 | i != sTest.end(); i++ ) | ||
80 | { | ||
81 | Hash<const char *, int>::iterator j = i; | ||
82 | printf("%d: %s\n", (*j).second, (*j).first ); | ||
83 | } | ||
84 | |||
85 | printf("Testing\n-------------------\n\n"); | ||
86 | for( int j = 0; j < 33; j++ ) | ||
87 | { | ||
88 | if( sTest.has(names[j]) ) | ||
89 | { | ||
90 | if( sTest[names[j]] != j ) | ||
91 | { | ||
92 | printf("'%s' should be %d, is %d\n", | ||
93 | names[j], j, | ||
94 | sTest[names[j]].value() | ||
95 | ); | ||
96 | } | ||
97 | } | ||
98 | else | ||
99 | { | ||
100 | printf("Missing element %d, '%s'\n", j, names[j] ); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | printf("Clearing\n-------------------\n\n"); | ||
105 | |||
106 | sTest.clear(); | ||
107 | |||
108 | for( Hash<const char *, int>::iterator i = sTest.begin(); | ||
109 | i != sTest.end(); i++ ) | ||
110 | { | ||
111 | Hash<const char *, int>::iterator j = i; | ||
112 | printf("%d: %s\n", (*j).second, (*j).first ); | ||
113 | } | ||
114 | |||
115 | } | ||
116 | |||
diff --git a/src/old/tests/hashtest.cpp b/src/old/tests/hashtest.cpp deleted file mode 100644 index eaa84a0..0000000 --- a/src/old/tests/hashtest.cpp +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <iostream> | ||
3 | #include "hashtable.h" | ||
4 | #include "hashfunctioncasestring.h" | ||
5 | |||
6 | int main() | ||
7 | { | ||
8 | const char *names[]={ | ||
9 | "Homer the Great", | ||
10 | "And Maggie Makes Three", | ||
11 | "Bart's Comet", | ||
12 | "Homie The Clown", | ||
13 | "Bart Vs Australia", | ||
14 | "Homer vs Patty and Selma", | ||
15 | "A star is burns", | ||
16 | "Lisa's Wedding", | ||
17 | "Two Dozen and One Greyhounds", | ||
18 | "The PTA Disbands", | ||
19 | "Round Springfield", | ||
20 | "The Springfield connection", | ||
21 | "Lemon of Troy", | ||
22 | "Who Shot Mr. Burns (Pt. 1)", | ||
23 | "Who Shot Mr. Burns (pt. 2)", | ||
24 | "Radioactive Man", | ||
25 | "Home Sweet Homediddly-dum-doodly", | ||
26 | "Bart Sells His Soul", | ||
27 | "Lisa the Vegetarian", | ||
28 | "Treehouse of horror VI", | ||
29 | "King Size Homer", | ||
30 | "Mother Simpson", | ||
31 | "Sideshow Bob's Last Gleaming", | ||
32 | "The Simpson's 138th Show Spectacular", | ||
33 | "Marge Be Not Proud", | ||
34 | "Team Homer", | ||
35 | "Two Bad Neighbors", | ||
36 | "Scenes From the Class Struggle in Springfield", | ||
37 | "Bart the Fink", | ||
38 | "Lisa the Iconoclast", | ||
39 | "Homer the Smithers", | ||
40 | "The Day the Violence Died", | ||
41 | "A Fish Called Selma", | ||
42 | "Bart on the road", | ||
43 | "22 Short Films about Springfield", | ||
44 | "The Curse of the Flying Hellfish", | ||
45 | "Much Apu about Nothing", | ||
46 | "Homerpalooza", | ||
47 | "The Summer of 4 Ft 2", | ||
48 | "Treehouse of Horror VII", | ||
49 | "You Only Move Twice", | ||
50 | "The Homer They Fall", | ||
51 | "Burns Baby Burns", | ||
52 | "Bart After Dark", | ||
53 | "A Millhouse Divided", | ||
54 | "Lisas Date With Destiny", | ||
55 | "Hurricane Neddy", | ||
56 | "The Mysterious Voyage of Our Homer", | ||
57 | "The Springfield Files", | ||
58 | "The Twisted World of Marge Simpson", | ||
59 | "Mountain of Madness", | ||
60 | NULL | ||
61 | }; | ||
62 | |||
63 | HashTable h( new HashFunctionCaseString(), 5, false ); | ||
64 | |||
65 | int j; | ||
66 | printf("Inserting...\n"); | ||
67 | for( j = 0; j < 10; j++ ) | ||
68 | { | ||
69 | h.insert( names[j], (void *)(j+1) ); | ||
70 | h.insert( names[j], (void *)(j+1) ); | ||
71 | printf("Capacity: %lu, Size: %lu, Load: %f\n", | ||
72 | h.getCapacity(), | ||
73 | h.getSize(), | ||
74 | h.getLoad() | ||
75 | ); | ||
76 | } | ||
77 | |||
78 | for( j = 0; j < 10; j++ ) | ||
79 | { | ||
80 | printf("\"%s\" = %d\n", names[j], (int)h[names[j]] ); | ||
81 | } | ||
82 | |||
83 | printf("\nDeleting some...\n"); | ||
84 | |||
85 | for( int k = 0; k < 7; k++ ) | ||
86 | { | ||
87 | h.del( names[k] ); | ||
88 | //h.insert( names[j], (void *)(j+1) ); | ||
89 | printf("Capacity: %lu, Size: %lu, Load: %f\n", | ||
90 | h.getCapacity(), | ||
91 | h.getSize(), | ||
92 | h.getLoad() | ||
93 | ); | ||
94 | } | ||
95 | |||
96 | printf("\nInserting more...\n"); | ||
97 | |||
98 | for( ; names[j] != NULL; j++ ) | ||
99 | { | ||
100 | h.insert( names[j], (void *)(j+1) ); | ||
101 | printf("Capacity: %lu, Size: %lu, Load: %f\n", | ||
102 | h.getCapacity(), | ||
103 | h.getSize(), | ||
104 | h.getLoad() | ||
105 | ); | ||
106 | } | ||
107 | } | ||
diff --git a/src/old/tests/hashtest2.cpp b/src/old/tests/hashtest2.cpp deleted file mode 100644 index 74700fd..0000000 --- a/src/old/tests/hashtest2.cpp +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | #include "hash.h" | ||
2 | #include <string.h> | ||
3 | |||
4 | int main() | ||
5 | { | ||
6 | char *a, *b; | ||
7 | a = new char[10]; | ||
8 | b = new char[10]; | ||
9 | strcpy( a, "Hey there"); | ||
10 | strcpy( b, "Hey there"); | ||
11 | printf("Same: %s\n", __cmpHashKeys( a, b )?"yes":"no"); | ||
12 | |||
13 | return 0; | ||
14 | } | ||
15 | |||
diff --git a/src/old/tests/httpsrv/httpconnectionmonitor.cpp b/src/old/tests/httpsrv/httpconnectionmonitor.cpp deleted file mode 100644 index 51d82f3..0000000 --- a/src/old/tests/httpsrv/httpconnectionmonitor.cpp +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | #include "httpconnectionmonitor.h" | ||
2 | #include "http.h" | ||
3 | #include "exceptions.h" | ||
4 | #include <sys/stat.h> | ||
5 | |||
6 | HttpConnectionMonitor::HttpConnectionMonitor() | ||
7 | { | ||
8 | } | ||
9 | |||
10 | HttpConnectionMonitor::~HttpConnectionMonitor() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | bool HttpConnectionMonitor::onNewConnection( Connection *pCon, int nPort ) | ||
15 | { | ||
16 | printf("Got connection on port %d\n", nPort ); | ||
17 | |||
18 | try | ||
19 | { | ||
20 | pCon->readInput( 60, 0 ); | ||
21 | printf("#######################\n%s\n#######################\n", pCon->getInput() ); | ||
22 | |||
23 | Http hp( pCon ); | ||
24 | while( hp.parseRequest() == false ); | ||
25 | printf("Done parsing.\n\n"); | ||
26 | |||
27 | if( hp.getRequestType() == Http::reqGet ) | ||
28 | { | ||
29 | printf("\"\"\"%s\"\"\"\n", hp.getRequestURI() ); | ||
30 | if( !strcmp( hp.getRequestURI(), "/" ) ) | ||
31 | { | ||
32 | std::string content("<html><head><title>Server Test</test></head><body>This is a test of a new system where all the pages will be more or less dynamic...<br>If you want to try to login, you can do that here:<br><form method=\"post\" action=\"showvars\" enctype=\"multipart/form-data\">Name: <input type=\"text\" name=\"name\"><br>Password: <input type=\"password\" name=\"pass\"><br><input type=\"submit\" name=\"action\" value=\"login\"></form></body></html>"); | ||
33 | hp.buildResponse(); | ||
34 | hp.setResponseContent( | ||
35 | "text/html", | ||
36 | content.c_str(), | ||
37 | content.size() | ||
38 | ); | ||
39 | hp.sendResponse(); | ||
40 | } | ||
41 | else | ||
42 | { | ||
43 | std::string content("<html><head><title>URL Not Found</test></head><body>There is no content mapped to the URL you requested. Please try another one.</body></html>"); | ||
44 | hp.buildResponse( 404, "File not found."); | ||
45 | hp.setResponseContent( | ||
46 | "text/html", | ||
47 | content.c_str(), | ||
48 | content.size() | ||
49 | ); | ||
50 | hp.sendResponse(); | ||
51 | } | ||
52 | } | ||
53 | else | ||
54 | { | ||
55 | printf("Non get: %s\n", hp.getRequestTypeStr() ); | ||
56 | pCon->appendOutput("HTTP/1.1 100 Continue\r\n\r\n"); | ||
57 | } | ||
58 | pCon->writeOutput(); | ||
59 | //for( int j = 0; j < 50; j++ ) | ||
60 | { | ||
61 | pCon->readInput( 1, 0 ); | ||
62 | //printf("Size so far: %d\n", pCon->getInputAmnt() ); | ||
63 | } | ||
64 | |||
65 | if( pCon->hasInput() ) | ||
66 | { | ||
67 | std::string s( pCon->getInput(), pCon->getInputAmnt() ); | ||
68 | |||
69 | pCon->printInputDebug(); | ||
70 | //printf("Reamining data\n==============\n%s\n==============\n", | ||
71 | // s.c_str() ); | ||
72 | } | ||
73 | |||
74 | pCon->disconnect(); | ||
75 | } | ||
76 | catch( ConnectionException &e ) | ||
77 | { | ||
78 | printf("Connection: %s\n", e.what() ); | ||
79 | } | ||
80 | |||
81 | return true; | ||
82 | } | ||
83 | |||
84 | bool HttpConnectionMonitor::onClosedConnection( Connection *pCon ) | ||
85 | { | ||
86 | return true; | ||
87 | } | ||
88 | |||
diff --git a/src/old/tests/httpsrv/httpconnectionmonitor.h b/src/old/tests/httpsrv/httpconnectionmonitor.h deleted file mode 100644 index 30c0afd..0000000 --- a/src/old/tests/httpsrv/httpconnectionmonitor.h +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | #ifndef HTTPCONNECTIONMONITOR_H | ||
2 | #define HTTPCONNECTIONMONITOR_H | ||
3 | |||
4 | #include "connectionmonitor.h" | ||
5 | |||
6 | class HttpConnectionMonitor : public ConnectionMonitor | ||
7 | { | ||
8 | public: | ||
9 | HttpConnectionMonitor(); | ||
10 | ~HttpConnectionMonitor(); | ||
11 | |||
12 | bool onNewConnection( Connection *pCon, int nPort ); | ||
13 | bool onClosedConnection( Connection *pCon ); | ||
14 | }; | ||
15 | |||
16 | #endif | ||
diff --git a/src/old/tests/httpsrv/main.cpp b/src/old/tests/httpsrv/main.cpp deleted file mode 100644 index 2f1563c..0000000 --- a/src/old/tests/httpsrv/main.cpp +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #include "connectionmanager.h" | ||
2 | #include "httpconnectionmonitor.h" | ||
3 | |||
4 | int main() | ||
5 | { | ||
6 | printf("Starting server...\n"); | ||
7 | |||
8 | ConnectionManager srv; | ||
9 | HttpConnectionMonitor http; | ||
10 | |||
11 | srv.setConnectionMonitor( &http ); | ||
12 | |||
13 | printf("Listening on port 7331\n"); | ||
14 | srv.startServer( 7331 ); | ||
15 | |||
16 | for(;;) | ||
17 | { | ||
18 | srv.scanConnections( 5000, false ); | ||
19 | } | ||
20 | |||
21 | return 0; | ||
22 | } | ||
diff --git a/src/old/tests/log.cpp b/src/old/tests/log.cpp deleted file mode 100644 index d7cfa0b..0000000 --- a/src/old/tests/log.cpp +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <iostream> | ||
4 | #include "multilog.h" | ||
5 | #include "multilogtext.h" | ||
6 | |||
7 | class Test | ||
8 | { | ||
9 | public: | ||
10 | Test() | ||
11 | { | ||
12 | MultiLineLog( 4, "Test init'd\n"); | ||
13 | } | ||
14 | }; | ||
15 | |||
16 | int main() | ||
17 | { | ||
18 | MultiLog &xLog = MultiLog::getInstance(); | ||
19 | |||
20 | xLog.LineLog( 2, "Hello again"); | ||
21 | |||
22 | MultiLog::getInstance().addChannel( | ||
23 | new MultiLogText( STDOUT_FILENO, "%02y-%02m-%02d %02h:%02M:%02s: %t" ) | ||
24 | ); | ||
25 | |||
26 | MultiLineLog( MultiLog::LError, "Hi there!"); | ||
27 | Test t; | ||
28 | } | ||
29 | |||
diff --git a/src/old/tests/md5test.cpp b/src/old/tests/md5test.cpp deleted file mode 100644 index 6f832df..0000000 --- a/src/old/tests/md5test.cpp +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <string.h> | ||
3 | #include "md5.h" | ||
4 | |||
5 | int main() | ||
6 | { | ||
7 | md5 mproc; | ||
8 | md5sum sum; | ||
9 | char hexstr[33]; | ||
10 | |||
11 | memset( hexstr, 0, 33 ); | ||
12 | |||
13 | mproc.sumString( &sum, "qwertyuiopasdfgh" ); | ||
14 | mproc.sumToHex( &sum, hexstr ); | ||
15 | printf("sum: %s\n", hexstr ); | ||
16 | printf("chk: 1ebfc043d8880b758b13ddc8aa1638ef\n"); | ||
17 | |||
18 | return 0; | ||
19 | } | ||
diff --git a/src/old/tests/ordhash.cpp b/src/old/tests/ordhash.cpp deleted file mode 100644 index f1d96ec..0000000 --- a/src/old/tests/ordhash.cpp +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | #include "ordhash.h" | ||
2 | #include <string> | ||
3 | |||
4 | typedef struct eldef | ||
5 | { | ||
6 | eldef( int a, int b, const std::string &c ) : | ||
7 | id( a ), nSequence( b ), sName( c ) {} | ||
8 | int id; | ||
9 | int nSequence; | ||
10 | std::string sName; | ||
11 | } eldef; | ||
12 | |||
13 | struct seqcmp | ||
14 | { | ||
15 | bool operator()( eldef **a, eldef **b ) | ||
16 | { | ||
17 | return (*a)->nSequence < (*b)->nSequence; | ||
18 | } | ||
19 | }; | ||
20 | |||
21 | struct namcmp | ||
22 | { | ||
23 | bool operator()( eldef **a, eldef **b ) | ||
24 | { | ||
25 | return (*a)->sName < (*b)->sName; | ||
26 | } | ||
27 | }; | ||
28 | |||
29 | typedef OrdHash<int, eldef, seqcmp> AHash; | ||
30 | //typedef OrdHash<int, eldef, namcmp> AHash; | ||
31 | |||
32 | int main() | ||
33 | { | ||
34 | AHash hsh; | ||
35 | hsh[1] = eldef( 0, 43, "Bob"); | ||
36 | hsh[4] = eldef( 1, 443, "Abby"); | ||
37 | hsh[2] = eldef( 2, 1, "Name"); | ||
38 | hsh[5] = eldef( 3, 0, "Catagory"); | ||
39 | hsh[32] = eldef( 4, 12, "Epilogue"); | ||
40 | |||
41 | for( AHash::iterator i = hsh.begin(); i != hsh.end(); i++ ) | ||
42 | { | ||
43 | eldef e = (*i).second; | ||
44 | printf("%d, %d, %s\n", e.id, e.nSequence, e.sName.c_str() ); | ||
45 | } | ||
46 | |||
47 | } | ||
48 | |||
diff --git a/src/old/tests/param.cpp b/src/old/tests/param.cpp deleted file mode 100644 index a4d2824..0000000 --- a/src/old/tests/param.cpp +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | #include "param.h" | ||
2 | #include <stdio.h> | ||
3 | |||
4 | Param::Param() | ||
5 | { | ||
6 | addHelpBanner("param - A test of the libbu++ parameter systems\n" | ||
7 | "Enjoy with care and caution\n\nTest stuff:\n"); | ||
8 | addParam( "name", 's', mkproc( Param::printStuff ), &str, "Test a param param" ); | ||
9 | //addParam( "name", &str ); | ||
10 | addParam( "job", 'U', mkproc( Param::printStuff ), "Test a paramless param" ); | ||
11 | |||
12 | addHelpBanner("\nInformational:\n"); | ||
13 | addParam( "help", mkproc( ParamProc::help ), "Help!" ); | ||
14 | |||
15 | addHelpBanner("\nThanks for trying my test!\n\n"); | ||
16 | } | ||
17 | |||
18 | Param::~Param() | ||
19 | { | ||
20 | } | ||
21 | |||
22 | int Param::printStuff( int argc, char *argv[] ) | ||
23 | { | ||
24 | printf("------------%02d-------------\n", argc ); | ||
25 | for( int j = 0; j < argc; j++ ) | ||
26 | { | ||
27 | printf("%d: %s\n", j, argv[j] ); | ||
28 | } | ||
29 | printf("---------------------------\n" ); | ||
30 | printf("SETVAR===\"%s\"\n", str.c_str() ); | ||
31 | |||
32 | return 1; | ||
33 | } | ||
34 | |||
35 | int main( int argc, char *argv[] ) | ||
36 | { | ||
37 | if( argc == 1 ) | ||
38 | { | ||
39 | printf("You have to enter some parameter, try '--help'\n\n"); | ||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | Param p; | ||
44 | p.process( argc, argv ); | ||
45 | } | ||
46 | |||
diff --git a/src/old/tests/param.h b/src/old/tests/param.h deleted file mode 100644 index 2756b69..0000000 --- a/src/old/tests/param.h +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | #ifndef PARAM_H | ||
2 | #define PARAM_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | |||
6 | #include "paramproc.h" | ||
7 | |||
8 | class Param : public ParamProc | ||
9 | { | ||
10 | public: | ||
11 | Param(); | ||
12 | virtual ~Param(); | ||
13 | |||
14 | private: | ||
15 | int printStuff( int argc, char *argv[] ); | ||
16 | |||
17 | std::string str; | ||
18 | uint32_t uint32; | ||
19 | }; | ||
20 | |||
21 | #endif | ||
diff --git a/src/old/tests/plugin/main.cpp b/src/old/tests/plugin/main.cpp deleted file mode 100644 index 51c8390..0000000 --- a/src/old/tests/plugin/main.cpp +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | #include "plugger.h" | ||
2 | #include "plugin.h" | ||
3 | |||
4 | int main() | ||
5 | { | ||
6 | Plugger<Plugin> p; | ||
7 | |||
8 | p.registerExternalPlugin( "./guy.so", "Guy" ); | ||
9 | |||
10 | Plugin *t = p.instantiate( "Guy" ); | ||
11 | |||
12 | p.destroy( t ); | ||
13 | } | ||
14 | |||
diff --git a/src/old/tests/plugin/plugin.cpp b/src/old/tests/plugin/plugin.cpp deleted file mode 100644 index ea558fd..0000000 --- a/src/old/tests/plugin/plugin.cpp +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | #include "plugin.h" | ||
2 | |||
3 | Plugin::Plugin() | ||
4 | { | ||
5 | } | ||
6 | |||
7 | Plugin::~Plugin() | ||
8 | { | ||
9 | } | ||
10 | |||
diff --git a/src/old/tests/plugin/plugin.h b/src/old/tests/plugin/plugin.h deleted file mode 100644 index f726867..0000000 --- a/src/old/tests/plugin/plugin.h +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | #ifndef PLUGIN_H | ||
2 | #define PLUGIN_H | ||
3 | |||
4 | class Plugin | ||
5 | { | ||
6 | public: | ||
7 | Plugin(); | ||
8 | virtual ~Plugin(); | ||
9 | |||
10 | private: | ||
11 | |||
12 | }; | ||
13 | |||
14 | #endif | ||
diff --git a/src/old/tests/qsort.cpp b/src/old/tests/qsort.cpp deleted file mode 100644 index 28c6f03..0000000 --- a/src/old/tests/qsort.cpp +++ /dev/null | |||
@@ -1,228 +0,0 @@ | |||
1 | #define _QSORT_SWAP(a, b, t) ((void)((t = *a), (*a = *b), (*b = t))) | ||
2 | |||
3 | /* Discontinue quicksort algorithm when partition gets below this size. | ||
4 | This particular magic number was chosen to work best on a Sun 4/260. */ | ||
5 | #define _QSORT_MAX_THRESH 4 | ||
6 | |||
7 | /* Stack node declarations used to store unfulfilled partition obligations | ||
8 | * (inlined in QSORT). | ||
9 | typedef struct { | ||
10 | QSORT_TYPE *_lo, *_hi; | ||
11 | } qsort_stack_node; | ||
12 | */ | ||
13 | |||
14 | /* The next 4 #defines implement a very fast in-line stack abstraction. */ | ||
15 | /* The stack needs log (total_elements) entries (we could even subtract | ||
16 | log(MAX_THRESH)). Since total_elements has type unsigned, we get as | ||
17 | upper bound for log (total_elements): | ||
18 | bits per byte (CHAR_BIT) * sizeof(unsigned). */ | ||
19 | #define _QSORT_STACK_SIZE (8 * sizeof(unsigned)) | ||
20 | #define _QSORT_PUSH(top, low, high) \ | ||
21 | (((top->_lo = (low)), (top->_hi = (high)), ++top)) | ||
22 | #define _QSORT_POP(low, high, top) \ | ||
23 | ((--top, (low = top->_lo), (high = top->_hi))) | ||
24 | #define _QSORT_STACK_NOT_EMPTY (_stack < _top) | ||
25 | |||
26 | |||
27 | /* Order size using quicksort. This implementation incorporates | ||
28 | four optimizations discussed in Sedgewick: | ||
29 | |||
30 | 1. Non-recursive, using an explicit stack of pointer that store the | ||
31 | next array partition to sort. To save time, this maximum amount | ||
32 | of space required to store an array of SIZE_MAX is allocated on the | ||
33 | stack. Assuming a 32-bit (64 bit) integer for size_t, this needs | ||
34 | only 32 * sizeof(stack_node) == 256 bytes (for 64 bit: 1024 bytes). | ||
35 | Pretty cheap, actually. | ||
36 | |||
37 | 2. Chose the pivot element using a median-of-three decision tree. | ||
38 | This reduces the probability of selecting a bad pivot value and | ||
39 | eliminates certain extraneous comparisons. | ||
40 | |||
41 | 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving | ||
42 | insertion sort to order the MAX_THRESH items within each partition. | ||
43 | This is a big win, since insertion sort is faster for small, mostly | ||
44 | sorted array segments. | ||
45 | |||
46 | 4. The larger of the two sub-partitions is always pushed onto the | ||
47 | stack first, with the algorithm then concentrating on the | ||
48 | smaller partition. This *guarantees* no more than log (total_elems) | ||
49 | stack size is needed (actually O(1) in this case)! */ | ||
50 | |||
51 | /* The main code starts here... */ | ||
52 | |||
53 | template<typename QSORT_TYPE, typename QSORT_LTT> | ||
54 | void qsrt( QSORT_TYPE *QSORT_BASE, int QSORT_NELT ) | ||
55 | { | ||
56 | QSORT_LTT QSORT_LT; | ||
57 | QSORT_TYPE *const _base = (QSORT_BASE); | ||
58 | const unsigned _elems = (QSORT_NELT); | ||
59 | QSORT_TYPE _hold; | ||
60 | |||
61 | /* Don't declare two variables of type QSORT_TYPE in a single | ||
62 | * statement: eg `TYPE a, b;', in case if TYPE is a pointer, | ||
63 | * expands to `type* a, b;' wich isn't what we want. | ||
64 | */ | ||
65 | |||
66 | if (_elems > _QSORT_MAX_THRESH) { | ||
67 | QSORT_TYPE *_lo = _base; | ||
68 | QSORT_TYPE *_hi = _lo + _elems - 1; | ||
69 | struct { | ||
70 | QSORT_TYPE *_hi; QSORT_TYPE *_lo; | ||
71 | } _stack[_QSORT_STACK_SIZE], *_top = _stack + 1; | ||
72 | |||
73 | while (_QSORT_STACK_NOT_EMPTY) { | ||
74 | QSORT_TYPE *_left_ptr; QSORT_TYPE *_right_ptr; | ||
75 | |||
76 | /* Select median value from among LO, MID, and HI. Rearrange | ||
77 | LO and HI so the three values are sorted. This lowers the | ||
78 | probability of picking a pathological pivot value and | ||
79 | skips a comparison for both the LEFT_PTR and RIGHT_PTR in | ||
80 | the while loops. */ | ||
81 | |||
82 | QSORT_TYPE *_mid = _lo + ((_hi - _lo) >> 1); | ||
83 | |||
84 | if (QSORT_LT (_mid, _lo)) | ||
85 | _QSORT_SWAP (_mid, _lo, _hold); | ||
86 | if (QSORT_LT (_hi, _mid)) | ||
87 | _QSORT_SWAP (_mid, _hi, _hold); | ||
88 | else | ||
89 | goto _jump_over; | ||
90 | if (QSORT_LT (_mid, _lo)) | ||
91 | _QSORT_SWAP (_mid, _lo, _hold); | ||
92 | _jump_over:; | ||
93 | |||
94 | _left_ptr = _lo + 1; | ||
95 | _right_ptr = _hi - 1; | ||
96 | |||
97 | /* Here's the famous ``collapse the walls'' section of quicksort. | ||
98 | Gotta like those tight inner loops! They are the main reason | ||
99 | that this algorithm runs much faster than others. */ | ||
100 | do { | ||
101 | while (QSORT_LT (_left_ptr, _mid)) | ||
102 | ++_left_ptr; | ||
103 | |||
104 | while (QSORT_LT (_mid, _right_ptr)) | ||
105 | --_right_ptr; | ||
106 | |||
107 | if (_left_ptr < _right_ptr) { | ||
108 | _QSORT_SWAP (_left_ptr, _right_ptr, _hold); | ||
109 | if (_mid == _left_ptr) | ||
110 | _mid = _right_ptr; | ||
111 | else if (_mid == _right_ptr) | ||
112 | _mid = _left_ptr; | ||
113 | ++_left_ptr; | ||
114 | --_right_ptr; | ||
115 | } | ||
116 | else if (_left_ptr == _right_ptr) { | ||
117 | ++_left_ptr; | ||
118 | --_right_ptr; | ||
119 | break; | ||
120 | } | ||
121 | } while (_left_ptr <= _right_ptr); | ||
122 | |||
123 | /* Set up pointers for next iteration. First determine whether | ||
124 | left and right partitions are below the threshold size. If so, | ||
125 | ignore one or both. Otherwise, push the larger partition's | ||
126 | bounds on the stack and continue sorting the smaller one. */ | ||
127 | |||
128 | if (_right_ptr - _lo <= _QSORT_MAX_THRESH) { | ||
129 | if (_hi - _left_ptr <= _QSORT_MAX_THRESH) | ||
130 | /* Ignore both small partitions. */ | ||
131 | _QSORT_POP (_lo, _hi, _top); | ||
132 | else | ||
133 | /* Ignore small left partition. */ | ||
134 | _lo = _left_ptr; | ||
135 | } | ||
136 | else if (_hi - _left_ptr <= _QSORT_MAX_THRESH) | ||
137 | /* Ignore small right partition. */ | ||
138 | _hi = _right_ptr; | ||
139 | else if (_right_ptr - _lo > _hi - _left_ptr) { | ||
140 | /* Push larger left partition indices. */ | ||
141 | _QSORT_PUSH (_top, _lo, _right_ptr); | ||
142 | _lo = _left_ptr; | ||
143 | } | ||
144 | else { | ||
145 | /* Push larger right partition indices. */ | ||
146 | _QSORT_PUSH (_top, _left_ptr, _hi); | ||
147 | _hi = _right_ptr; | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | |||
152 | /* Once the BASE array is partially sorted by quicksort the rest | ||
153 | is completely sorted using insertion sort, since this is efficient | ||
154 | for partitions below MAX_THRESH size. BASE points to the | ||
155 | beginning of the array to sort, and END_PTR points at the very | ||
156 | last element in the array (*not* one beyond it!). */ | ||
157 | |||
158 | { | ||
159 | QSORT_TYPE *const _end_ptr = _base + _elems - 1; | ||
160 | QSORT_TYPE *_tmp_ptr = _base; | ||
161 | register QSORT_TYPE *_run_ptr; | ||
162 | QSORT_TYPE *_thresh; | ||
163 | |||
164 | _thresh = _base + _QSORT_MAX_THRESH; | ||
165 | if (_thresh > _end_ptr) | ||
166 | _thresh = _end_ptr; | ||
167 | |||
168 | /* Find smallest element in first threshold and place it at the | ||
169 | array's beginning. This is the smallest array element, | ||
170 | and the operation speeds up insertion sort's inner loop. */ | ||
171 | |||
172 | for (_run_ptr = _tmp_ptr + 1; _run_ptr <= _thresh; ++_run_ptr) | ||
173 | if (QSORT_LT (_run_ptr, _tmp_ptr)) | ||
174 | _tmp_ptr = _run_ptr; | ||
175 | |||
176 | if (_tmp_ptr != _base) | ||
177 | _QSORT_SWAP (_tmp_ptr, _base, _hold); | ||
178 | |||
179 | /* Insertion sort, running from left-hand-side | ||
180 | * up to right-hand-side. */ | ||
181 | |||
182 | _run_ptr = _base + 1; | ||
183 | while (++_run_ptr <= _end_ptr) { | ||
184 | _tmp_ptr = _run_ptr - 1; | ||
185 | while (QSORT_LT (_run_ptr, _tmp_ptr)) | ||
186 | --_tmp_ptr; | ||
187 | |||
188 | ++_tmp_ptr; | ||
189 | if (_tmp_ptr != _run_ptr) { | ||
190 | QSORT_TYPE *_trav = _run_ptr + 1; | ||
191 | while (--_trav >= _run_ptr) { | ||
192 | QSORT_TYPE *_hi; QSORT_TYPE *_lo; | ||
193 | _hold = *_trav; | ||
194 | |||
195 | for (_hi = _lo = _trav; --_lo >= _tmp_ptr; _hi = _lo) | ||
196 | *_hi = *_lo; | ||
197 | *_hi = _hold; | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | |||
203 | } | ||
204 | |||
205 | |||
206 | struct cc | ||
207 | { | ||
208 | bool operator()( int *a, int *b ) | ||
209 | { | ||
210 | return *a < *b; | ||
211 | } | ||
212 | }; | ||
213 | |||
214 | #include <stdio.h> | ||
215 | |||
216 | int main() | ||
217 | { | ||
218 | int lst[] = { 43, 1, 342, 12, 491, 32, 12321, 32, 3, -3 }; | ||
219 | |||
220 | for( int j = 0; j < 10; j++ ) | ||
221 | printf("%s%d", (j>0)?", ":"", lst[j] ); | ||
222 | printf("\n"); | ||
223 | qsrt<int, cc>( lst, 10 ); | ||
224 | for( int j = 0; j < 10; j++ ) | ||
225 | printf("%s%d", (j>0)?", ":"", lst[j] ); | ||
226 | printf("\n"); | ||
227 | } | ||
228 | |||
diff --git a/src/old/tests/sbuffer.cpp b/src/old/tests/sbuffer.cpp deleted file mode 100644 index 02798cb..0000000 --- a/src/old/tests/sbuffer.cpp +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | #include "sbuffer.h" | ||
2 | |||
3 | int main() | ||
4 | { | ||
5 | SBuffer buf; | ||
6 | |||
7 | buf.write("abcdefg", 7 ); | ||
8 | |||
9 | printf("tell: %ld\n", buf.tell() ); | ||
10 | |||
11 | char abuf[6]; | ||
12 | int nRead; | ||
13 | nRead = buf.read( abuf, 5 ); | ||
14 | abuf[nRead] = '\0'; | ||
15 | printf("Read %d bytes \"%s\"\n", nRead, abuf ); | ||
16 | |||
17 | buf.setPos( 0 ); | ||
18 | nRead = buf.read( abuf, 5 ); | ||
19 | abuf[nRead] = '\0'; | ||
20 | printf("Read %d bytes \"%s\"\n", nRead, abuf ); | ||
21 | |||
22 | nRead = buf.read( abuf, 5 ); | ||
23 | abuf[nRead] = '\0'; | ||
24 | printf("Read %d bytes \"%s\"\n", nRead, abuf ); | ||
25 | |||
26 | } | ||
27 | |||
diff --git a/src/old/tests/serialize.cpp b/src/old/tests/serialize.cpp deleted file mode 100644 index e233704..0000000 --- a/src/old/tests/serialize.cpp +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #include "serializerbinary.h" | ||
2 | #include "staticstring.h" | ||
3 | #include <stdio.h> | ||
4 | #include <string> | ||
5 | |||
6 | int main() | ||
7 | { | ||
8 | int32_t one; | ||
9 | double two; | ||
10 | bool three; | ||
11 | StaticString s("Test string!"); | ||
12 | std::string ss("Another test string"); | ||
13 | SerializerBinary ar("hello.dat", false); | ||
14 | ar << (int)85; | ||
15 | ar << (double)2.63434; | ||
16 | ar << false; | ||
17 | ar << ss; | ||
18 | ar.close(); | ||
19 | |||
20 | one = 0; two = 0; three = true; s = "die"; | ||
21 | |||
22 | SerializerBinary ar2("hello.dat", true); | ||
23 | ar2 >> one; | ||
24 | ar2 >> two; | ||
25 | ar2 >> three; | ||
26 | ar2 >> s; | ||
27 | |||
28 | printf("we got %d - %f - %s - \"%s\"\n", one, two, (three ? "true":"false"), s.getString() ); | ||
29 | return 0; | ||
30 | } | ||
diff --git a/src/old/tests/serializetext.cpp b/src/old/tests/serializetext.cpp deleted file mode 100644 index f6be7d3..0000000 --- a/src/old/tests/serializetext.cpp +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | #include "serializertext.h" | ||
2 | #include "staticstring.h" | ||
3 | #include <iostream> | ||
4 | |||
5 | int main() | ||
6 | { | ||
7 | StaticString s("You're a dog!!"); | ||
8 | SerializerText ar("hello.dat", false); | ||
9 | |||
10 | ar << 4 << 3.993 << true << s; | ||
11 | |||
12 | ar.close(); | ||
13 | |||
14 | int one=0;float two=0.0;bool three=false; s = ""; | ||
15 | |||
16 | SerializerText ar2("hello.dat", true); | ||
17 | |||
18 | ar2 >> one; | ||
19 | ar2 >> two; | ||
20 | ar2 >> three; | ||
21 | ar2 >> s; | ||
22 | |||
23 | //printf("out: %d, %f, %s, \"%s\"\n", one, two, (three ? "true" : "false"), s.getString()); | ||
24 | std::cout << one << ", " << two << ", " << three << ", " << s.getString() << "\n"; | ||
25 | |||
26 | return 0; | ||
27 | } | ||
28 | |||
diff --git a/src/old/tests/sha1.cpp b/src/old/tests/sha1.cpp deleted file mode 100644 index df3113c..0000000 --- a/src/old/tests/sha1.cpp +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | #include "sha1.h" | ||
2 | #include "sfile.h" | ||
3 | |||
4 | #define BS 1024 | ||
5 | |||
6 | int main( int argc, char *argv[] ) | ||
7 | { | ||
8 | argc--; argv++; | ||
9 | |||
10 | if( argc == 0 ) | ||
11 | { | ||
12 | printf("Provide a filename.\n"); | ||
13 | return 0; | ||
14 | } | ||
15 | |||
16 | char buf[BS]; | ||
17 | |||
18 | Sha1 s; | ||
19 | SFile fin( *argv, "rb" ); | ||
20 | for(;;) | ||
21 | { | ||
22 | int nRead = fin.read( buf, BS ); | ||
23 | if( nRead == 0 ) | ||
24 | break; | ||
25 | |||
26 | s.update( buf, nRead ); | ||
27 | if( nRead < BS ) | ||
28 | break; | ||
29 | } | ||
30 | |||
31 | unsigned char *dig = s.getDigest(); | ||
32 | |||
33 | char val[]={"0123456789ABCDEF"}; | ||
34 | |||
35 | for( int j = 0; j < 20; j++ ) | ||
36 | { | ||
37 | putchar( val[dig[j]>>4] ); | ||
38 | putchar( val[dig[j]&0x0F] ); | ||
39 | } | ||
40 | putchar('\n'); | ||
41 | |||
42 | delete[] dig; | ||
43 | } | ||
44 | |||
diff --git a/src/old/tests/sptr.cpp b/src/old/tests/sptr.cpp deleted file mode 100644 index 38d3675..0000000 --- a/src/old/tests/sptr.cpp +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include "sptr.h" | ||
3 | |||
4 | class Annoy | ||
5 | { | ||
6 | public: | ||
7 | Annoy() : nCnt( 0 ) | ||
8 | { | ||
9 | printf("Created.\n"); | ||
10 | } | ||
11 | |||
12 | ~Annoy() | ||
13 | { | ||
14 | printf("Destroyed.\n"); | ||
15 | } | ||
16 | |||
17 | void go() | ||
18 | { | ||
19 | printf("%d: I'm annoying.\n", ++nCnt); | ||
20 | } | ||
21 | |||
22 | int nCnt; | ||
23 | }; | ||
24 | |||
25 | void beAnnoying( SPtr<Annoy> bob ) | ||
26 | { | ||
27 | printf("bob-Count: %d\n", bob.count() ); | ||
28 | bob->go(); | ||
29 | } | ||
30 | |||
31 | int main() | ||
32 | { | ||
33 | SPtr<Annoy> pt( new Annoy ); | ||
34 | printf("Count: %d\n", pt.count() ); | ||
35 | pt->go(); | ||
36 | |||
37 | { | ||
38 | SPtr<Annoy> pt2 = pt; | ||
39 | printf("Count: %d\n", pt2.count() ); | ||
40 | |||
41 | pt2->go(); | ||
42 | |||
43 | { | ||
44 | SPtr<Annoy> pt3( pt2 ); | ||
45 | printf("Count: %d\n", pt3.count() ); | ||
46 | |||
47 | pt3->go(); | ||
48 | |||
49 | beAnnoying( pt3 ); | ||
50 | } | ||
51 | printf("Count: %d\n", pt.count() ); | ||
52 | } | ||
53 | printf("Count: %d\n", pt.count() ); | ||
54 | } | ||
55 | |||
diff --git a/src/old/tests/srvstress.cpp b/src/old/tests/srvstress.cpp deleted file mode 100644 index d9a9a1c..0000000 --- a/src/old/tests/srvstress.cpp +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | #include "connectionmanager.h" | ||
2 | #include "programlink.h" | ||
3 | #include "linkedlist.h" | ||
4 | #include "protocol.h" | ||
5 | |||
6 | class StressProtocol : public Protocol | ||
7 | { | ||
8 | public: | ||
9 | bool onNewData() | ||
10 | { | ||
11 | switch( getConnection()->getInput()[0] ) | ||
12 | { | ||
13 | case 'd': | ||
14 | throw "Hello"; | ||
15 | break; | ||
16 | |||
17 | case 'w': | ||
18 | getConnection()->appendOutput("Hello"); | ||
19 | break; | ||
20 | }; | ||
21 | |||
22 | return true; | ||
23 | } | ||
24 | |||
25 | bool onNewConnection() | ||
26 | { | ||
27 | return true; | ||
28 | } | ||
29 | }; | ||
30 | |||
31 | class StressMonitor : public ConnectionMonitor, public ProgramLink | ||
32 | { | ||
33 | public: | ||
34 | bool init() | ||
35 | { | ||
36 | return true; | ||
37 | } | ||
38 | |||
39 | bool deInit() | ||
40 | { | ||
41 | return true; | ||
42 | } | ||
43 | |||
44 | bool timeSlice() | ||
45 | { | ||
46 | return true; | ||
47 | } | ||
48 | |||
49 | bool onNewConnection( Connection *pCon, int nPort ) | ||
50 | { | ||
51 | StressProtocol *sp = new StressProtocol(); | ||
52 | pCon->setProtocol( sp ); | ||
53 | |||
54 | printf(" sys: New connection: socket(%d), port(%d)\n", | ||
55 | pCon->getSocket(), nPort ); | ||
56 | |||
57 | return true; | ||
58 | } | ||
59 | |||
60 | bool onClosedConnection( Connection *pCon ) | ||
61 | { | ||
62 | printf(" sys: Closed connection: socket(%d)\n", | ||
63 | pCon->getSocket() ); | ||
64 | |||
65 | return true; | ||
66 | } | ||
67 | |||
68 | LinkMessage *processIRM( LinkMessage *pMsg ) | ||
69 | { | ||
70 | return NULL; | ||
71 | } | ||
72 | }; | ||
73 | |||
74 | int main() | ||
75 | { | ||
76 | printf("Starting server...\n"); | ||
77 | |||
78 | ConnectionManager srv; | ||
79 | StressMonitor telnet; | ||
80 | |||
81 | srv.setConnectionMonitor( &telnet ); | ||
82 | |||
83 | srv.startServer( 4001 ); | ||
84 | |||
85 | for(;;) | ||
86 | { | ||
87 | srv.scanConnections( 5000, false ); | ||
88 | } | ||
89 | |||
90 | return 0; | ||
91 | } | ||
diff --git a/src/old/tests/strhash.cpp b/src/old/tests/strhash.cpp deleted file mode 100644 index f6528ca..0000000 --- a/src/old/tests/strhash.cpp +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include "hashfunctionstring.h" | ||
3 | |||
4 | int main( int argc, char *argv[] ) | ||
5 | { | ||
6 | HashFunctionString h; | ||
7 | |||
8 | printf("\"%s\": %lu\n", argv[1], h.hash( argv[1] ) ); | ||
9 | |||
10 | return 0; | ||
11 | } | ||
12 | |||
diff --git a/src/old/tests/teltest/main.cpp b/src/old/tests/teltest/main.cpp deleted file mode 100644 index 5d3ec26..0000000 --- a/src/old/tests/teltest/main.cpp +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | #include "connectionmanager.h" | ||
2 | #include "telnetmonitor.h" | ||
3 | |||
4 | int main() | ||
5 | { | ||
6 | printf("Starting server...\n"); | ||
7 | |||
8 | ConnectionManager srv; | ||
9 | TelnetMonitor telnet; | ||
10 | |||
11 | srv.setConnectionMonitor( &telnet ); | ||
12 | |||
13 | srv.startServer( 4001 ); | ||
14 | |||
15 | for(;;) | ||
16 | { | ||
17 | srv.scanConnections( 5000, false ); | ||
18 | } | ||
19 | |||
20 | return 0; | ||
21 | } | ||
diff --git a/src/old/tests/teltest/telnetmonitor.cpp b/src/old/tests/teltest/telnetmonitor.cpp deleted file mode 100644 index 65954eb..0000000 --- a/src/old/tests/teltest/telnetmonitor.cpp +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | #include "telnetmonitor.h" | ||
2 | #include "protocoltelnet.h" | ||
3 | #include <sys/stat.h> | ||
4 | |||
5 | TelnetMonitor::TelnetMonitor() | ||
6 | { | ||
7 | } | ||
8 | |||
9 | TelnetMonitor::~TelnetMonitor() | ||
10 | { | ||
11 | } | ||
12 | |||
13 | bool TelnetMonitor::init() | ||
14 | { | ||
15 | return true; | ||
16 | } | ||
17 | |||
18 | bool TelnetMonitor::deInit() | ||
19 | { | ||
20 | return true; | ||
21 | } | ||
22 | |||
23 | bool TelnetMonitor::timeSlice() | ||
24 | { | ||
25 | for( int j = 0; j < lCon.getSize(); j++ ) | ||
26 | { | ||
27 | if( ((Connection *)lCon[j])->hasInput() ) | ||
28 | { | ||
29 | printf("%s\n", ((Connection *)lCon[j])->getInput() ); | ||
30 | } | ||
31 | } | ||
32 | return true; | ||
33 | } | ||
34 | |||
35 | LinkMessage* TelnetMonitor::processIRM( LinkMessage *pMsg ) | ||
36 | { | ||
37 | return NULL; | ||
38 | } | ||
39 | |||
40 | bool TelnetMonitor::onNewConnection( Connection *pCon, int nPort ) | ||
41 | { | ||
42 | ProtocolTelnet *pt = new ProtocolTelnet(); | ||
43 | pCon->setProtocol( pt ); | ||
44 | |||
45 | lCon.append( pt ); | ||
46 | |||
47 | return true; | ||
48 | } | ||
49 | |||
50 | bool TelnetMonitor::onClosedConnection( Connection *pCon ) | ||
51 | { | ||
52 | return true; | ||
53 | } | ||
54 | |||
diff --git a/src/old/tests/teltest/telnetmonitor.h b/src/old/tests/teltest/telnetmonitor.h deleted file mode 100644 index ba5761e..0000000 --- a/src/old/tests/teltest/telnetmonitor.h +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | #ifndef HTTPCONNECTIONMONITOR_H | ||
2 | #define HTTPCONNECTIONMONITOR_H | ||
3 | |||
4 | #include "connectionmonitor.h" | ||
5 | #include "programlink.h" | ||
6 | #include "linkedlist.h" | ||
7 | |||
8 | class TelnetMonitor : public ConnectionMonitor, public ProgramLink | ||
9 | { | ||
10 | public: | ||
11 | TelnetMonitor(); | ||
12 | ~TelnetMonitor(); | ||
13 | |||
14 | bool init(); | ||
15 | bool deInit(); | ||
16 | bool timeSlice(); | ||
17 | LinkMessage* processIRM( LinkMessage *pMsgIn ); | ||
18 | |||
19 | bool onNewConnection( Connection *pCon, int nPort ); | ||
20 | bool onClosedConnection( Connection *pCon ); | ||
21 | |||
22 | private: | ||
23 | LinkedList lCon; | ||
24 | }; | ||
25 | |||
26 | #endif | ||
diff --git a/src/old/tests/xmlreadtest.cpp b/src/old/tests/xmlreadtest.cpp deleted file mode 100644 index d061810..0000000 --- a/src/old/tests/xmlreadtest.cpp +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | #include "xmlfilereader.h" | ||
2 | #include "xmlstringreader.h" | ||
3 | #include "xmlfilewriter.h" | ||
4 | |||
5 | int main( int argc, char *argv[] ) | ||
6 | { | ||
7 | if( argc < 4 ) | ||
8 | { | ||
9 | printf("Usage: %s f <file in> <file out>\n", argv[0] ); | ||
10 | printf(" %s s <xml string> <file out>\n\n", argv[0] ); | ||
11 | return 0; | ||
12 | } | ||
13 | |||
14 | if( argv[1][0] == 'f' ) | ||
15 | { | ||
16 | XmlFileReader r( argv[2], true ); | ||
17 | // XmlFileWriter w( argv[3], "\t", r.detatchRoot() ); | ||
18 | // w.write(); | ||
19 | } | ||
20 | else if( argv[1][0] == 's' ) | ||
21 | { | ||
22 | XmlStringReader r( argv[2], true ); | ||
23 | XmlFileWriter w(stdout, "\t", r.detatchRoot() ); | ||
24 | w.write(); | ||
25 | } | ||
26 | |||
27 | return 0; | ||
28 | } | ||
29 | |||
diff --git a/src/old/tests/xmlrepltest.cpp b/src/old/tests/xmlrepltest.cpp deleted file mode 100644 index 9667705..0000000 --- a/src/old/tests/xmlrepltest.cpp +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | #include "xmlwriter.h" | ||
2 | |||
3 | int main() | ||
4 | { | ||
5 | printf("Testing Xml Replacement...\n"); | ||
6 | XmlDocument w; | ||
7 | |||
8 | w.addNode("text"); | ||
9 | w.setContent("this text is before the node. "); | ||
10 | w.addNode("keepme", "This one we keep...", true ); | ||
11 | w.setContent("this text is after."); | ||
12 | w.addNode("deleteme", "This one we don't...", true ); | ||
13 | w.setContent("this is last..." ); | ||
14 | w.closeNode(); | ||
15 | |||
16 | //XmlWriter::writeNode( stdout, w.getRoot(), 0, NULL ); | ||
17 | |||
18 | printf("\n\n"); | ||
19 | |||
20 | //XmlNode *xNode = w.getRoot()->detatchNode( 1 ); | ||
21 | |||
22 | //XmlWriter::writeNode( stdout, w.getRoot(), 0, NULL ); | ||
23 | |||
24 | printf("\n\n"); | ||
25 | |||
26 | //XmlWriter::writeNode( stdout, xNode, 0, NULL ); | ||
27 | |||
28 | printf("\n\n"); | ||
29 | |||
30 | return 0; | ||
31 | } | ||
diff --git a/src/old/tests/xmlwritetest.cpp b/src/old/tests/xmlwritetest.cpp deleted file mode 100644 index a22d19d..0000000 --- a/src/old/tests/xmlwritetest.cpp +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | #include "xmlfilewriter.h" | ||
2 | #include "xmlstringwriter.h" | ||
3 | #include "xmlstringreader.h" | ||
4 | |||
5 | void fillItIn( XmlWriter &w ) | ||
6 | { | ||
7 | w.addNode("thinglist"); | ||
8 | |||
9 | w.addNode("thing"); | ||
10 | w.addProperty("type", " ±î´<M-F6><M-F6>³¸®°êòì¯"); | ||
11 | |||
12 | w.addNode("id", "Klophin²³±¹¸·µ´äêíëã Staff", true ); | ||
13 | w.addNode("name", "Klophin Staff", true ); | ||
14 | w.addNode("durability", "0.01", true ); | ||
15 | w.addNode("size", "0.1", true ); | ||
16 | |||
17 | w.addNode("config"); | ||
18 | w.addNode("damage", "3d6+4", true ); | ||
19 | w.addNode("class", "melee", true ); | ||
20 | w.addNode("type", "bludgeon", true ); | ||
21 | w.addNode("damagedesc", "club/clubs", true ); | ||
22 | w.closeNode(); | ||
23 | |||
24 | w.closeNode(); | ||
25 | |||
26 | w.closeNode(); | ||
27 | } | ||
28 | |||
29 | int main() | ||
30 | { | ||
31 | printf("Testing XmlWriter...\n"); | ||
32 | |||
33 | //XmlStringReader *xsr = new XmlStringReader("<stuff/>"); | ||
34 | |||
35 | //printf("%08X\n%08X\n%08X\n", xsr, (XmlReader *)xsr, (XmlDocument *)xsr ); | ||
36 | |||
37 | //delete (XmlDocument *)xsr; | ||
38 | XmlFileWriter wf("test.xml", "\t"); | ||
39 | |||
40 | fillItIn( wf ); | ||
41 | |||
42 | XmlStringWriter ws("\t"); | ||
43 | fillItIn( ws ); | ||
44 | |||
45 | printf("Now the string version:\n\n%s\n", ws.getString().c_str() ); | ||
46 | |||
47 | return 0; | ||
48 | } | ||