diff options
Diffstat (limited to '')
| -rw-r--r-- | src/tests/archive.cpp | 3 | ||||
| -rw-r--r-- | src/tests/archive2.cpp | 6 | ||||
| -rw-r--r-- | src/tests/cache.cpp | 1 | ||||
| -rw-r--r-- | src/tests/fastcgi.cpp | 2 | ||||
| -rw-r--r-- | src/tests/heap.cpp | 53 | ||||
| -rw-r--r-- | src/tests/itoheap.cpp | 1 | ||||
| -rw-r--r-- | src/tests/listsort.cpp | 60 | ||||
| -rw-r--r-- | src/tests/ringbuffer.cpp | 2 | ||||
| -rw-r--r-- | src/tests/serverticks.cpp | 1 | ||||
| -rw-r--r-- | src/tests/socketblock.cpp | 1 | ||||
| -rw-r--r-- | src/tests/socketbreak.cpp | 1 | ||||
| -rw-r--r-- | src/tests/uuid.cpp | 14 |
12 files changed, 141 insertions, 4 deletions
diff --git a/src/tests/archive.cpp b/src/tests/archive.cpp index 131d4de..8a5f6ee 100644 --- a/src/tests/archive.cpp +++ b/src/tests/archive.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | #include "bu/archive.h" | 8 | #include "bu/archive.h" |
| 9 | #include "bu/file.h" | 9 | #include "bu/file.h" |
| 10 | #include "bu/fstring.h" | ||
| 10 | 11 | ||
| 11 | using namespace Bu; | 12 | using namespace Bu; |
| 12 | 13 | ||
| @@ -15,7 +16,7 @@ int main() | |||
| 15 | File f("test.dat", File::Write ); | 16 | File f("test.dat", File::Write ); |
| 16 | Archive ar( f, Archive::save ); | 17 | Archive ar( f, Archive::save ); |
| 17 | 18 | ||
| 18 | std::string s("Hello there"); | 19 | Bu::FString s("Hello there"); |
| 19 | ar << s; | 20 | ar << s; |
| 20 | 21 | ||
| 21 | return 0; | 22 | return 0; |
diff --git a/src/tests/archive2.cpp b/src/tests/archive2.cpp index fddb91b..3d95c2f 100644 --- a/src/tests/archive2.cpp +++ b/src/tests/archive2.cpp | |||
| @@ -23,7 +23,7 @@ public: | |||
| 23 | { | 23 | { |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | virtual void archive( Bu::Archive &ar ) | 26 | virtual void archive( Bu::ArchiveBase &ar ) |
| 27 | { | 27 | { |
| 28 | ar && iId; | 28 | ar && iId; |
| 29 | } | 29 | } |
| @@ -47,7 +47,7 @@ public: | |||
| 47 | delete a2; | 47 | delete a2; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | virtual void archive( Bu::Archive &ar ) | 50 | virtual void archive( Bu::ArchiveBase &ar ) |
| 51 | { | 51 | { |
| 52 | //ar && iId && a1 && a2; | 52 | //ar && iId && a1 && a2; |
| 53 | ar << iId << a1 << a2; | 53 | ar << iId << a1 << a2; |
| @@ -73,7 +73,7 @@ public: | |||
| 73 | delete b; | 73 | delete b; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | virtual void archive( Bu::Archive &ar ) | 76 | virtual void archive( Bu::ArchiveBase &ar ) |
| 77 | { | 77 | { |
| 78 | //ar && iId && a && b; | 78 | //ar && iId && a && b; |
| 79 | ar << iId; | 79 | ar << iId; |
diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp index 3fcc34c..a098145 100644 --- a/src/tests/cache.cpp +++ b/src/tests/cache.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <sys/stat.h> | 10 | #include <sys/stat.h> |
| 11 | #include <sys/types.h> | 11 | #include <sys/types.h> |
| 12 | #include <errno.h> | 12 | #include <errno.h> |
| 13 | #include <unistd.h> | ||
| 13 | 14 | ||
| 14 | #include "bu/cache.h" | 15 | #include "bu/cache.h" |
| 15 | #include "bu/file.h" | 16 | #include "bu/file.h" |
diff --git a/src/tests/fastcgi.cpp b/src/tests/fastcgi.cpp index cd6cdda..46a7d62 100644 --- a/src/tests/fastcgi.cpp +++ b/src/tests/fastcgi.cpp | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | #include "bu/fastcgi.h" | 8 | #include "bu/fastcgi.h" |
| 9 | 9 | ||
| 10 | #include <unistd.h> | ||
| 11 | |||
| 10 | class Cgi : public Bu::FastCgi | 12 | class Cgi : public Bu::FastCgi |
| 11 | { | 13 | { |
| 12 | public: | 14 | public: |
diff --git a/src/tests/heap.cpp b/src/tests/heap.cpp index daa0356..ae130ec 100644 --- a/src/tests/heap.cpp +++ b/src/tests/heap.cpp | |||
| @@ -8,7 +8,10 @@ | |||
| 8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| 10 | 10 | ||
| 11 | #include "bu/formatter.h" | ||
| 11 | #include "bu/heap.h" | 12 | #include "bu/heap.h" |
| 13 | #include "bu/fstring.h" | ||
| 14 | #include "bu/file.h" | ||
| 12 | 15 | ||
| 13 | typedef struct num | 16 | typedef struct num |
| 14 | { | 17 | { |
| @@ -35,8 +38,18 @@ typedef struct num | |||
| 35 | } | 38 | } |
| 36 | } num; | 39 | } num; |
| 37 | 40 | ||
| 41 | void printHeap( Bu::Heap<Bu::FString> &h, int j ) | ||
| 42 | { | ||
| 43 | Bu::FString sFName; | ||
| 44 | sFName.format("graph-step-%02d.dot", j ); | ||
| 45 | Bu::File fOut( sFName, Bu::File::WriteNew ); | ||
| 46 | Bu::Formatter f( Bu::File ); | ||
| 47 | //h.print( f ); | ||
| 48 | } | ||
| 49 | |||
| 38 | int main() | 50 | int main() |
| 39 | { | 51 | { |
| 52 | /* | ||
| 40 | Bu::Heap<num> hNum; | 53 | Bu::Heap<num> hNum; |
| 41 | 54 | ||
| 42 | for( int j = 0; j < 30; j++ ) | 55 | for( int j = 0; j < 30; j++ ) |
| @@ -53,6 +66,46 @@ int main() | |||
| 53 | hNum.dequeue(); | 66 | hNum.dequeue(); |
| 54 | } | 67 | } |
| 55 | printf("\n"); | 68 | printf("\n"); |
| 69 | */ | ||
| 70 | Bu::Heap<Bu::FString> hStr; | ||
| 71 | int j = 0; | ||
| 72 | |||
| 73 | hStr.enqueue("George"); | ||
| 74 | printHeap( hStr, j++ ); | ||
| 75 | hStr.enqueue("Sam"); | ||
| 76 | printHeap( hStr, j++ ); | ||
| 77 | hStr.enqueue("Abby"); | ||
| 78 | printHeap( hStr, j++ ); | ||
| 79 | hStr.enqueue("Zorro"); | ||
| 80 | printHeap( hStr, j++ ); | ||
| 81 | hStr.enqueue("Brianna"); | ||
| 82 | printHeap( hStr, j++ ); | ||
| 83 | hStr.enqueue("Kate"); | ||
| 84 | printHeap( hStr, j++ ); | ||
| 85 | hStr.enqueue("Soggy"); | ||
| 86 | printHeap( hStr, j++ ); | ||
| 87 | |||
| 88 | while( !hStr.isEmpty() ) | ||
| 89 | { | ||
| 90 | printf("\"%s\" ", hStr.dequeue().getStr() ); | ||
| 91 | printHeap( hStr, j++ ); | ||
| 92 | } | ||
| 93 | printf("\n"); | ||
| 94 | |||
| 95 | Bu::List<Bu::FString> lStr; | ||
| 96 | |||
| 97 | lStr.insertSorted("George"); | ||
| 98 | lStr.insertSorted("Sam"); | ||
| 99 | lStr.insertSorted("Abby"); | ||
| 100 | lStr.insertSorted("Zorro"); | ||
| 101 | lStr.insertSorted("Brianna"); | ||
| 102 | lStr.insertSorted("Kate"); | ||
| 103 | lStr.insertSorted("Soggy"); | ||
| 104 | for( Bu::List<Bu::FString>::iterator i = lStr.begin(); i; i++ ) | ||
| 105 | { | ||
| 106 | printf("\"%s\" ", (*i).getStr() ); | ||
| 107 | } | ||
| 108 | printf("\n"); | ||
| 56 | 109 | ||
| 57 | return 0; | 110 | return 0; |
| 58 | } | 111 | } |
diff --git a/src/tests/itoheap.cpp b/src/tests/itoheap.cpp index 9016d86..c5816b2 100644 --- a/src/tests/itoheap.cpp +++ b/src/tests/itoheap.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| 10 | #include <unistd.h> | ||
| 10 | 11 | ||
| 11 | #include "bu/itoheap.h" | 12 | #include "bu/itoheap.h" |
| 12 | #include "bu/ito.h" | 13 | #include "bu/ito.h" |
diff --git a/src/tests/listsort.cpp b/src/tests/listsort.cpp new file mode 100644 index 0000000..f9236e6 --- /dev/null +++ b/src/tests/listsort.cpp | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | #include <bu/list.h> | ||
| 2 | #include <bu/sio.h> | ||
| 3 | #include <bu/fstring.h> | ||
| 4 | |||
| 5 | using namespace Bu; | ||
| 6 | |||
| 7 | int main() | ||
| 8 | { | ||
| 9 | FString a("Soggy"), b("Sam"); | ||
| 10 | |||
| 11 | if( a < b ) | ||
| 12 | { | ||
| 13 | sio << "Bad" << sio.nl; | ||
| 14 | } | ||
| 15 | else | ||
| 16 | { | ||
| 17 | sio << "Good" << sio.nl; | ||
| 18 | } | ||
| 19 | |||
| 20 | typedef List<FString> StrList; | ||
| 21 | |||
| 22 | StrList lNames; | ||
| 23 | |||
| 24 | lNames.append("George"); | ||
| 25 | lNames.append("Sam"); | ||
| 26 | lNames.append("Abby"); | ||
| 27 | lNames.append("Zorro"); | ||
| 28 | lNames.append("Brianna"); | ||
| 29 | lNames.append("Kate"); | ||
| 30 | lNames.append("Soggy"); | ||
| 31 | |||
| 32 | sio << "Names: " << lNames << sio.nl; | ||
| 33 | lNames.sort(); | ||
| 34 | |||
| 35 | sio << "Names: " << lNames << sio.nl; | ||
| 36 | |||
| 37 | StrList lNames2; | ||
| 38 | |||
| 39 | lNames2.insertSorted("George"); | ||
| 40 | lNames2.insertSorted("Sam"); | ||
| 41 | lNames2.insertSorted("Abby"); | ||
| 42 | lNames2.insertSorted("Zorro"); | ||
| 43 | lNames2.insertSorted("Brianna"); | ||
| 44 | lNames2.insertSorted("Kate"); | ||
| 45 | lNames2.insertSorted("Soggy"); | ||
| 46 | |||
| 47 | sio << "Names: " << lNames2 << sio.nl; | ||
| 48 | |||
| 49 | if( lNames == lNames2 ) | ||
| 50 | { | ||
| 51 | sio << "They're the same." << sio.nl; | ||
| 52 | } | ||
| 53 | else | ||
| 54 | { | ||
| 55 | sio << "They're different." << sio.nl; | ||
| 56 | } | ||
| 57 | |||
| 58 | return 0; | ||
| 59 | } | ||
| 60 | |||
diff --git a/src/tests/ringbuffer.cpp b/src/tests/ringbuffer.cpp index 46c515b..9489b30 100644 --- a/src/tests/ringbuffer.cpp +++ b/src/tests/ringbuffer.cpp | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | #include "bu/ringbuffer.h" | 8 | #include "bu/ringbuffer.h" |
| 9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| 10 | #include <stdint.h> | ||
| 11 | #include <stdio.h> | ||
| 10 | 12 | ||
| 11 | int main() | 13 | int main() |
| 12 | { | 14 | { |
diff --git a/src/tests/serverticks.cpp b/src/tests/serverticks.cpp index e599444..3aad746 100644 --- a/src/tests/serverticks.cpp +++ b/src/tests/serverticks.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "bu/server.h" | 8 | #include "bu/server.h" |
| 9 | #include "bu/client.h" | 9 | #include "bu/client.h" |
| 10 | #include "bu/protocol.h" | 10 | #include "bu/protocol.h" |
| 11 | #include <unistd.h> | ||
| 11 | 12 | ||
| 12 | class TickProtocol : public Bu::Protocol | 13 | class TickProtocol : public Bu::Protocol |
| 13 | { | 14 | { |
diff --git a/src/tests/socketblock.cpp b/src/tests/socketblock.cpp index 2a7dfdc..5dad46c 100644 --- a/src/tests/socketblock.cpp +++ b/src/tests/socketblock.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "bu/socket.h" | 9 | #include "bu/socket.h" |
| 10 | #include "bu/serversocket.h" | 10 | #include "bu/serversocket.h" |
| 11 | #include <stdio.h> | 11 | #include <stdio.h> |
| 12 | #include <unistd.h> | ||
| 12 | 13 | ||
| 13 | class TstServer : public Bu::Ito | 14 | class TstServer : public Bu::Ito |
| 14 | { | 15 | { |
diff --git a/src/tests/socketbreak.cpp b/src/tests/socketbreak.cpp index e77ae4f..b873830 100644 --- a/src/tests/socketbreak.cpp +++ b/src/tests/socketbreak.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | #include "bu/serversocket.h" | 8 | #include "bu/serversocket.h" |
| 9 | #include "bu/socket.h" | 9 | #include "bu/socket.h" |
| 10 | #include <unistd.h> | ||
| 10 | 11 | ||
| 11 | int main() | 12 | int main() |
| 12 | { | 13 | { |
diff --git a/src/tests/uuid.cpp b/src/tests/uuid.cpp new file mode 100644 index 0000000..4544543 --- /dev/null +++ b/src/tests/uuid.cpp | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #include <bu/uuid.h> | ||
| 2 | #include <bu/sio.h> | ||
| 3 | |||
| 4 | using namespace Bu; | ||
| 5 | |||
| 6 | int main() | ||
| 7 | { | ||
| 8 | Uuid i = Uuid::gen(); | ||
| 9 | |||
| 10 | sio << i.toString() << sio.nl; | ||
| 11 | |||
| 12 | return 0; | ||
| 13 | } | ||
| 14 | |||
