summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-02-08 00:44:10 +0000
committerMike Buland <eichlan@xagasoft.com>2009-02-08 00:44:10 +0000
commit366a8063730aa7ae696bcb9cf56eafd13d43dfc0 (patch)
tree42e3597edfde0c183506ad0d452f045cb7726137 /src/tests
parent4f59dec6bad120b72f1bc075715d79bfbe881f7e (diff)
downloadlibbu++-366a8063730aa7ae696bcb9cf56eafd13d43dfc0.tar.gz
libbu++-366a8063730aa7ae696bcb9cf56eafd13d43dfc0.tar.bz2
libbu++-366a8063730aa7ae696bcb9cf56eafd13d43dfc0.tar.xz
libbu++-366a8063730aa7ae696bcb9cf56eafd13d43dfc0.zip
So many updates. I recommend using the new FString iterators instead of direct
indexing. It is now many times faster, and requires less overhead. Also, more stuff iterator related in every class. More on that later.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/rh.cpp52
-rw-r--r--src/tests/url.cpp32
2 files changed, 32 insertions, 52 deletions
diff --git a/src/tests/rh.cpp b/src/tests/rh.cpp
deleted file mode 100644
index 70abcb7..0000000
--- a/src/tests/rh.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
1#include "bu/file.h"
2#include "bu/hash.h"
3#include "bu/archive.h"
4#include "bu/fstring.h"
5#include "bu/nids.h"
6#include "bu/nidsstream.h"
7
8int main( int argc, char *argv[] )
9{
10 if( argv[1][0] == 'r' )
11 {
12 typedef Bu::Hash<Bu::FString, int> Hsh;
13
14 Bu::File fIn( argv[2], Bu::File::Read );
15 Bu::Archive ar( fIn, Bu::Archive::load );
16
17 Hsh h;
18 ar >> h;
19
20 printf("Read %d.\n", h.getSize() );
21 for( Hsh::iterator i = h.begin(); i != h.end(); i++ )
22 {
23 printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() );
24 }
25
26 printf("%d vs. %d\n", h.getSize(), h.getKeys().getSize() );
27 }
28 else if( argv[1][0] == 'n' )
29 {
30 typedef Bu::Hash<Bu::FString, int> Hsh;
31
32 Bu::File fIn( argv[2], Bu::File::Read );
33 Bu::Nids n( fIn );
34 n.initialize();
35 Bu::NidsStream sIn = n.openStream( 0 );
36 Bu::Archive ar( sIn, Bu::Archive::load );
37
38 Hsh h;
39 ar >> h;
40
41 printf("Read %d.\n", h.getSize() );
42 for( Hsh::iterator i = h.begin(); i != h.end(); i++ )
43 {
44 printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() );
45 }
46
47 printf("%d vs. %d\n", h.getSize(), h.getKeys().getSize() );
48 }
49
50 return 0;
51}
52
diff --git a/src/tests/url.cpp b/src/tests/url.cpp
new file mode 100644
index 0000000..c9af676
--- /dev/null
+++ b/src/tests/url.cpp
@@ -0,0 +1,32 @@
1#include "bu/url.h"
2
3#include <stdio.h>
4
5int main( int argc, char *argv[] )
6{
7 printf("encodede: %s\n", Bu::Url::encode( argv[1] ).getStr() );
8 printf("decodede: %s\n", Bu::Url::decode( argv[1] ).getStr() );
9 Bu::Url u( argv[1] );
10
11 printf("Protocol: %s\n", u.getProtocol().getStr() );
12 printf("User: %s\n", u.getUser().getStr() );
13 printf("Pass: %s\n", u.getPass().getStr() );
14 printf("Host: %s\n", u.getHost().getStr() );
15 printf("Path: %s\n", u.getPath().getStr() );
16 try
17 {
18 printf("Port: %d\n", u.getPort() );
19 } catch( Bu::ExceptionBase &e )
20 {
21 printf("Port: not set.\n");
22 }
23 printf("Parameters:\n");
24 for( Bu::Url::ParamList::const_iterator i = u.getParamBegin(); i; i++ )
25 {
26 printf(" \"%s\" = \"%s\"\n",
27 (*i).sName.getStr(), (*i).sValue.getStr()
28 );
29 }
30
31 return 0;
32}