From 366a8063730aa7ae696bcb9cf56eafd13d43dfc0 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 8 Feb 2009 00:44:10 +0000 Subject: 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. --- src/tests/rh.cpp | 52 ---------------------------------------------------- src/tests/url.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 52 deletions(-) delete mode 100644 src/tests/rh.cpp create mode 100644 src/tests/url.cpp (limited to 'src/tests') 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 @@ -#include "bu/file.h" -#include "bu/hash.h" -#include "bu/archive.h" -#include "bu/fstring.h" -#include "bu/nids.h" -#include "bu/nidsstream.h" - -int main( int argc, char *argv[] ) -{ - if( argv[1][0] == 'r' ) - { - typedef Bu::Hash Hsh; - - Bu::File fIn( argv[2], Bu::File::Read ); - Bu::Archive ar( fIn, Bu::Archive::load ); - - Hsh h; - ar >> h; - - printf("Read %d.\n", h.getSize() ); - for( Hsh::iterator i = h.begin(); i != h.end(); i++ ) - { - printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() ); - } - - printf("%d vs. %d\n", h.getSize(), h.getKeys().getSize() ); - } - else if( argv[1][0] == 'n' ) - { - typedef Bu::Hash Hsh; - - Bu::File fIn( argv[2], Bu::File::Read ); - Bu::Nids n( fIn ); - n.initialize(); - Bu::NidsStream sIn = n.openStream( 0 ); - Bu::Archive ar( sIn, Bu::Archive::load ); - - Hsh h; - ar >> h; - - printf("Read %d.\n", h.getSize() ); - for( Hsh::iterator i = h.begin(); i != h.end(); i++ ) - { - printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() ); - } - - printf("%d vs. %d\n", h.getSize(), h.getKeys().getSize() ); - } - - return 0; -} - 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 @@ +#include "bu/url.h" + +#include + +int main( int argc, char *argv[] ) +{ + printf("encodede: %s\n", Bu::Url::encode( argv[1] ).getStr() ); + printf("decodede: %s\n", Bu::Url::decode( argv[1] ).getStr() ); + Bu::Url u( argv[1] ); + + printf("Protocol: %s\n", u.getProtocol().getStr() ); + printf("User: %s\n", u.getUser().getStr() ); + printf("Pass: %s\n", u.getPass().getStr() ); + printf("Host: %s\n", u.getHost().getStr() ); + printf("Path: %s\n", u.getPath().getStr() ); + try + { + printf("Port: %d\n", u.getPort() ); + } catch( Bu::ExceptionBase &e ) + { + printf("Port: not set.\n"); + } + printf("Parameters:\n"); + for( Bu::Url::ParamList::const_iterator i = u.getParamBegin(); i; i++ ) + { + printf(" \"%s\" = \"%s\"\n", + (*i).sName.getStr(), (*i).sValue.getStr() + ); + } + + return 0; +} -- cgit v1.2.3