From 4b9289cfb260f4bcecaf23a810584ef6ef8e8501 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 30 Mar 2011 22:33:41 +0000 Subject: Ok, string stuff is working much, much better, a load of new unit tests have been added, and I deleted a whole slew of stupid old tests that I don't need. --- src/optparser.cpp | 62 ++ src/optparser.h | 1 + src/string.cpp | 34 +- src/string.h | 45 +- src/tests/archive.cpp | 27 - src/tests/archive2.cpp | 102 ---- src/tests/atom.cpp | 32 -- src/tests/buffer.cpp | 45 -- src/tests/cache.cpp | 260 --------- src/tests/conduit.cpp | 56 -- src/tests/console.cpp | 43 -- src/tests/cryptpass.cpp | 25 - src/tests/csv.cpp | 50 -- src/tests/daysinmonth.cpp | 23 - src/tests/fastcgi.cpp | 90 --- src/tests/formula.cpp | 56 -- src/tests/fstratsptr.cpp | 53 -- src/tests/fstrstd.cpp | 16 - src/tests/hash.cpp | 31 - src/tests/hash2.cpp | 35 -- src/tests/heap.cpp | 120 ---- src/tests/itoheap.cpp | 70 --- src/tests/itoqueue1.cpp | 115 ---- src/tests/itoqueue2.cpp | 87 --- src/tests/itoserver.cpp | 80 --- src/tests/list.cpp | 77 --- src/tests/list2.cpp | 26 - src/tests/listsort.cpp | 79 --- src/tests/logger.cpp | 37 -- src/tests/md5.cpp | 34 -- src/tests/minicron.cpp | 63 --- src/tests/mmparse.cpp | 22 - src/tests/multiserver.cpp | 76 --- src/tests/procs.cpp | 37 -- src/tests/queuebuf.cpp | 66 --- src/tests/regex.cpp | 38 -- src/tests/ringbuffer.cpp | 38 -- src/tests/rot13.cpp | 91 --- src/tests/serverticks.cpp | 69 --- src/tests/sha1.cpp | 39 -- src/tests/sharedcore.cpp | 98 ---- src/tests/signals.cpp | 131 ----- src/tests/size.cpp | 20 - src/tests/socketblock.cpp | 56 -- src/tests/socketbreak.cpp | 35 -- src/tests/speed.cpp | 58 -- src/tests/stdstream.cpp | 39 -- src/tests/streamstack.cpp | 100 ---- src/tests/string.cpp | 154 ----- src/tests/stringspeed.cpp | 122 ---- src/tests/tcpsocket.cpp | 73 --- src/tests/telnetsrv.cpp | 92 --- src/tests/tracer.cpp | 36 -- src/tests/udpsocket.cpp | 86 --- src/tests/url.cpp | 42 -- src/tests/variant.cpp | 52 -- src/unit/string.unit | 159 +++++- test.taf | 1381 ++++++++++++++++++++++++++++++++++++++++++++- 58 files changed, 1648 insertions(+), 3436 deletions(-) delete mode 100644 src/tests/archive.cpp delete mode 100644 src/tests/archive2.cpp delete mode 100644 src/tests/atom.cpp delete mode 100644 src/tests/buffer.cpp delete mode 100644 src/tests/cache.cpp delete mode 100644 src/tests/conduit.cpp delete mode 100644 src/tests/console.cpp delete mode 100644 src/tests/cryptpass.cpp delete mode 100644 src/tests/csv.cpp delete mode 100644 src/tests/daysinmonth.cpp delete mode 100644 src/tests/fastcgi.cpp delete mode 100644 src/tests/formula.cpp delete mode 100644 src/tests/fstratsptr.cpp delete mode 100644 src/tests/fstrstd.cpp delete mode 100644 src/tests/hash.cpp delete mode 100644 src/tests/hash2.cpp delete mode 100644 src/tests/heap.cpp delete mode 100644 src/tests/itoheap.cpp delete mode 100644 src/tests/itoqueue1.cpp delete mode 100644 src/tests/itoqueue2.cpp delete mode 100644 src/tests/itoserver.cpp delete mode 100644 src/tests/list.cpp delete mode 100644 src/tests/list2.cpp delete mode 100644 src/tests/listsort.cpp delete mode 100644 src/tests/logger.cpp delete mode 100644 src/tests/md5.cpp delete mode 100644 src/tests/minicron.cpp delete mode 100644 src/tests/mmparse.cpp delete mode 100644 src/tests/multiserver.cpp delete mode 100644 src/tests/procs.cpp delete mode 100644 src/tests/queuebuf.cpp delete mode 100644 src/tests/regex.cpp delete mode 100644 src/tests/ringbuffer.cpp delete mode 100644 src/tests/rot13.cpp delete mode 100644 src/tests/serverticks.cpp delete mode 100644 src/tests/sha1.cpp delete mode 100644 src/tests/sharedcore.cpp delete mode 100644 src/tests/signals.cpp delete mode 100644 src/tests/size.cpp delete mode 100644 src/tests/socketblock.cpp delete mode 100644 src/tests/socketbreak.cpp delete mode 100644 src/tests/speed.cpp delete mode 100644 src/tests/stdstream.cpp delete mode 100644 src/tests/streamstack.cpp delete mode 100644 src/tests/string.cpp delete mode 100644 src/tests/stringspeed.cpp delete mode 100644 src/tests/tcpsocket.cpp delete mode 100644 src/tests/telnetsrv.cpp delete mode 100644 src/tests/tracer.cpp delete mode 100644 src/tests/udpsocket.cpp delete mode 100644 src/tests/url.cpp delete mode 100644 src/tests/variant.cpp diff --git a/src/optparser.cpp b/src/optparser.cpp index bab93d0..74aba3e 100644 --- a/src/optparser.cpp +++ b/src/optparser.cpp @@ -167,6 +167,68 @@ void Bu::OptParser::parse( int argc, char **argv ) } } +void Bu::OptParser::parse( const Bu::String &sLine ) +{ + Bu::String sCmd = sLine.clone(); + int iParams = 0; + bool bInGap = true; + bool bInQuote = false; + for( Bu::String::iterator i = sCmd.begin(); i; i++ ) + { + if( bInQuote == false && (*i == ' ' || *i == '\t') ) + { + if( bInGap == false ) + { + bInGap = true; + } + } + else if( *i == '"' ) + { + bInQuote = !bInQuote; + } + else + { + if( bInGap ) + { + iParams++; + bInGap = false; + } + } + } + + bInQuote = false; + bInGap = true; + char **asParam = new char*[iParams]; + iParams = 0; + for( char *i = sCmd.getStr(); *i; i++ ) + { + if( bInQuote == false && (*i == ' ' || *i == '\t') ) + { + if( bInGap == false ) + { + bInGap = true; + *i = '\0'; + } + } + else if( *i == '"' ) + { + bInQuote = !bInQuote; + } + else + { + if( bInGap ) + { + asParam[iParams++] = i; + bInGap = false; + } + } + } + + parse( iParams, asParam ); + + delete[] asParam; +} + void Bu::OptParser::addOption( const Option &opt ) { lOption.append( opt ); diff --git a/src/optparser.h b/src/optparser.h index 2033850..f2fe531 100644 --- a/src/optparser.h +++ b/src/optparser.h @@ -133,6 +133,7 @@ namespace Bu virtual ~OptParser(); void parse( int argc, char **argv ); + void parse( const Bu::String &sLine ); void addOption( const Option &opt ); diff --git a/src/string.cpp b/src/string.cpp index 5834da1..edc45f9 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -443,7 +443,7 @@ Bu::String Bu::String::replace( const Bu::String &fnd, const_iterator o = begin(); while( true ) { - const_iterator i = o.find( fnd ); + const_iterator i = o.find( fnd, fnd.getSize() ); if( !i ) { out.append( o ); @@ -994,7 +994,7 @@ Bu::String::const_iterator Bu::String::find( const String &rStr, if( !iStart ) iStart = begin(); for( ; iStart; iStart++ ) { - if( iStart.compare( rStr, rStr.getSize() ) ) + if( iStart.compare( rStr ) ) return iStart; } return end(); @@ -1133,6 +1133,36 @@ void Bu::String::trimBack( long iAmnt ) core->nLength -= iAmnt; } +Bu::String Bu::String::trimWhitespace() const +{ + if( core->nLength == 0 ) + return ""; + const_iterator i = begin(); + for( ; i && (*i == ' ' || *i == '\t' || *i == '\n' || *i == '\r'); i++ ) { } + if( !i ) + return ""; + + const_iterator e = i; + for( ; e; e++ ) + { + if( *e == ' ' || *e == '\t' || *e == '\n' || *e == '\r' ) + { + const_iterator t = e; + for( ; t && (*t == ' ' || *t == '\t' || *t == '\n' || *t == '\r'); t++ ) { } + if( t ) + { + e = t; + } + else + { + break; + } + } + } + + return Bu::String( i, e ); +} + Bu::String::iterator Bu::String::begin() { if( core->nLength == 0 ) diff --git a/src/string.h b/src/string.h index 3ac161b..2874e37 100644 --- a/src/string.h +++ b/src/string.h @@ -117,6 +117,13 @@ namespace Bu iPos = i.iPos; return *this; } + + const_iterator &operator=( const iterator &i ) + { + pChunk = i.pChunk; + iPos = i.iPos; + return *this; + } const_iterator &operator++() { @@ -203,7 +210,8 @@ namespace Bu if( *a != *b ) return false; } - + if( (bool)a != (bool)b ) + return false; return true; } @@ -213,14 +221,11 @@ namespace Bu const_iterator b = c; if( a == b ) return true; - int j; - for( j = 0; a && b && j < nLen; a++, b++, j++ ) + for(int j = 0; j < nLen; a++, b++, j++ ) { - if( *a != *b ) + if( !a || !b || *a != *b ) return false; } - if( j < nLen ) - return false; return true; } @@ -256,7 +261,7 @@ namespace Bu bool compare( const String &s ) const { if( !pChunk ) return false; - return compare( s.begin(), s.getSize() ); + return compare( s.begin() ); } bool compare( const String &s, int nLen ) const @@ -442,10 +447,10 @@ namespace Bu return pChunk != NULL; } - bool compare( const iterator &c ) const + bool compare( const const_iterator &c ) const { - iterator a = *this; - iterator b = c; + const_iterator a( *this ); + const_iterator b = c; if( a == b ) return true; for(; a && b; a++, b++ ) @@ -453,23 +458,22 @@ namespace Bu if( *a != *b ) return false; } + if( (bool)a != (bool)b ) + return false; return true; } - bool compare( const iterator &c, int nLen ) const + bool compare( const const_iterator &c, int nLen ) const { - iterator a = *this; - iterator b = c; + const_iterator a( *this ); + const_iterator b = c; if( a == b ) return true; - int j; - for( j = 0; a && b && j < nLen; a++, b++, j++ ) + for(int j = 0; j < nLen; a++, b++, j++ ) { - if( *a != *b ) + if( !a || !b || *a != *b ) return false; } - if( j < nLen ) - return false; return true; } @@ -505,7 +509,7 @@ namespace Bu bool compare( const String &s ) const { if( !pChunk ) return false; - return compare( s.begin(), s.getSize() ); + return compare( s.begin() ); } bool compare( const String &s, int nLen ) const @@ -924,8 +928,9 @@ namespace Bu */ void trimFront( long nAmnt ); - // void trimBack( char c ); void trimBack( long iAmnt ); + + Bu::String trimWhitespace() const; iterator begin(); diff --git a/src/tests/archive.cpp b/src/tests/archive.cpp deleted file mode 100644 index c905007..0000000 --- a/src/tests/archive.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/archive.h" -#include "bu/file.h" -#include "bu/string.h" - -using namespace Bu; - -int main() -{ - File f("test.dat", File::WriteNew ); - Archive ar( f, Archive::save ); - - Bu::String s("Hello there"); - ar << s; - - ar.setProp("hi", 45 ); - printf("Hi: %d", ar.getProp("hi") ); - - return 0; -} - diff --git a/src/tests/archive2.cpp b/src/tests/archive2.cpp deleted file mode 100644 index e8d3360..0000000 --- a/src/tests/archive2.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/archive.h" -#include "bu/archival.h" -#include "bu/file.h" - -int giId = 0; - -class A : public Bu::Archival -{ -public: - A() : - iId( giId++ ) - { - } - - virtual ~A() - { - } - - virtual void archive( Bu::ArchiveBase &ar ) - { - ar && iId; - } - - int iId; -}; - -class B : public Bu::Archival -{ -public: - B() : - iId( giId++ ), - a1( new A ), - a2( new A ) - { - } - - virtual ~B() - { - delete a1; - delete a2; - } - - virtual void archive( Bu::ArchiveBase &ar ) - { - //ar && iId && a1 && a2; - ar << iId << a1 << a2; - } - - int iId; - A *a1, *a2; -}; - -class C : public Bu::Archival -{ -public: - C() : - iId( giId++ ), - a( new A ), - b( new B ) - { - } - - virtual ~C() - { - delete a; - delete b; - } - - virtual void archive( Bu::ArchiveBase &ar ) - { - //ar && iId && a && b; - ar << iId; - ar << a << b; - } - - int iId; - A *a; - B *b; -}; - -void write() -{ - C *c = new C; - - Bu::File f( "test.archive", Bu::File::Write ); - Bu::Archive ar( f, Bu::Archive::save ); - ar << c; -} - -int main() -{ - write(); - -} - diff --git a/src/tests/atom.cpp b/src/tests/atom.cpp deleted file mode 100644 index 7808282..0000000 --- a/src/tests/atom.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/atom.h" -#include -#include - -typedef struct bob -{ - int a, b; -} bob; -int main() -{ - Bu::Atom aInt; - Bu::Atom aStr; - Bu::Atom aBob; - - aBob = bob(); - aBob->a = 5; - - aStr.set("Hey there, dude"); - aInt.set( 55 ); - int me = aInt; - aInt = 12; - printf("%d, %d\n", aInt.get(), me ); - printf("%s\n", aStr.get() ); -} - diff --git a/src/tests/buffer.cpp b/src/tests/buffer.cpp deleted file mode 100644 index f3f6f41..0000000 --- a/src/tests/buffer.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/membuf.h" -#include "bu/buffer.h" -#include "bu/file.h" - -using namespace Bu; - -int main( int argc, char *argv[] ) -{ - argc--,argv++; - if( argc == 0 ) - { - MemBuf mOut; - Buffer bOut( mOut, 10 ); - - for( int j = 0; j < 4; j++ ) - bOut.write("hi ", 3 ); - - printf("Preflush: \"%s\"\n", mOut.getString().getStr() ); - bOut.flush(); - - printf("Final: \"%s\"\n", mOut.getString().getStr() ); - } - else - { - File fIn( *argv, File::Read ); - Buffer bIn( fIn, 10 ); - - char buf[5]; - for( int j = 0; j < 5; j++ ) - { - buf[bIn.read( buf, 4 )] = '\0'; - printf("Four chars: \"%s\"\n", buf ); - } - } - - return 0; -} - diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp deleted file mode 100644 index e9dbd86..0000000 --- a/src/tests/cache.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include -#include -#include -#include -#include - -#include "bu/cache.h" -#include "bu/file.h" -#include "bu/string.h" -#include "bu/cachecalc.h" - -class Bob -{ -public: - Bob() - { - TRACE(); - } - - Bob( int i ) : - iInt( i ) - { - TRACE( i ); - } - - virtual ~Bob() - { - TRACE(); - } - - void setInt( int i ) - { - TRACE( i ); - iInt = i; - } - - long getKey() const - { - TRACE( i ); - return iInt; - } - - int getInt() - { - return iInt; - } - - int iInt; -}; - -namespace Bu { - template<> - void __tracer_format( Bob* const &c ) - { - printf("%08X=%d", (uint32_t)c, c->getInt() ); - } -} - -class BobStore : public Bu::CacheStore -{ -public: - BobStore() : - cLastId( 0 ) - { - TRACE(); - if( access( "bobcache/last", R_OK|W_OK ) ) - { - mkdir("bobcache", 0755 ); - Bu::File f("bobcache/last", Bu::File::Write|Bu::File::Create ); - f.write("0", 1); - printf("Initializing cache: %s\n", strerror( errno ) ); - } - else - { - cLastId = readNum("bobcache/last"); - } - } - - ~BobStore() - { - TRACE(); - writeNum("bobcache/last", cLastId ); - } - - long readNum( const Bu::String &sFile ) - { - TRACE( sFile ); - Bu::File f( sFile, Bu::File::Read ); - char buf[80]; - buf[f.read( buf, 80 )] = '\0'; - return strtol( buf, NULL, 0 ); - } - - void writeNum( const Bu::String &sFile, long num ) - { - TRACE( sFile, num ); - Bu::File f( sFile, - Bu::File::Write|Bu::File::Create|Bu::File::Truncate - ); - f.write( Bu::String("%1").arg( num ) ); - } - - virtual void sync( Bob *, const long & ) - { - } - - virtual void sync() - { - } - - virtual bool has( const long & ) - { - return true; - } - - virtual Bob *load( const long &key ) - { - TRACE( key ); - Bu::String sDest = Bu::String("bobcache/%1").arg( key ); - return new Bob( readNum( sDest ) ); - } - - virtual void unload( Bob *pObj, const long &key ) - { - TRACE( pObj, key ); - Bu::String sDest = Bu::String("bobcache/%1").arg( key ); - writeNum( sDest, pObj->getInt() ); - delete pObj; - } - - virtual long create( Bob *rSrc ) - { - TRACE( rSrc ); - long id = ++cLastId; - Bu::String sDest = Bu::String("bobcache/%1").arg( id ); - writeNum( sDest, rSrc->getInt() ); - return id; - } - - virtual void destroy( Bob *pObj, const long &key ) - { - TRACE( pObj, key ); - Bu::String sDest = Bu::String("bobcache/%1").arg( key ); - if( !access( sDest.getStr(), F_OK ) ) - unlink( sDest.getStr() ); - delete pObj; - } - - virtual void destroy( const long &key ) - { - TRACE( pObj, key ); - Bu::String sDest = Bu::String("bobcache/%1").arg( key ); - if( !access( sDest.getStr(), F_OK ) ) - unlink( sDest.getStr() ); - } - -private: - long cLastId; -}; - -class BobCalc : public Bu::CacheCalc -{ -public: - BobCalc() - { - } - - virtual ~BobCalc() - { - } - - virtual void onLoad( Bob *, const long & ) - { - } - - virtual void onUnload( Bob *, const long & ) - { - } - - virtual void onDestroy( Bob *, const long & ) - { - } - - virtual void onDestroy( const long & ) - { - } - - virtual bool shouldSync( Bob *, const long &, time_t ) - { - return false; - } - -private: - -}; - -int main( int argc, char *argv[] ) -{ - TRACE( argc, argv ); - typedef Bu::Cache BobCache; - typedef BobCache::Ptr BobPtr; - - if( argc < 3 ) - { - printf("Try: %s [crudl] []\n\n", argv[0] ); - return 0; - } - - BobCache cBob( new BobCalc(), new BobStore() ); - switch( argv[1][0] ) - { - case 'c': - { - BobCache::Ptr pBob = cBob.insert( - new Bob( strtol( argv[2], NULL, 0 ) ) - ); - printf("Key = %ld\n", pBob.getKey() ); - } - return 0; - - case 'r': - { - BobCache::Ptr pBob = cBob.get( strtol( argv[2], NULL, 0 ) ); - printf("Value = %d\n", pBob->getInt() ); - } - return 0; - - case 'u': - { - BobCache::Ptr pBob = cBob.get( strtol( argv[2], NULL, 0 ) ); - pBob->setInt( strtol( argv[3], NULL, 0 ) ); - } - return 0; - - case 'd': - { - cBob.erase( strtol( argv[2], NULL, 0 ) ); - } - return 0; - - case 'l': - { - BobCache::Ptr pBob = cBob.getLazy( strtol( argv[2], NULL, 0 ) ); - printf("isBound: %s\n", pBob.isBound()?"yes":"no"); - printf("Value = %d\n", pBob->getInt() ); - printf("isBound: %s\n", pBob.isBound()?"yes":"no"); - } - return 0; - } - -} - diff --git a/src/tests/conduit.cpp b/src/tests/conduit.cpp deleted file mode 100644 index d8d9e03..0000000 --- a/src/tests/conduit.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "bu/conduit.h" -#include "bu/sio.h" -#include "bu/ito.h" - -using namespace Bu; - -class Reader : public Bu::Ito -{ -public: - Reader( Bu::Conduit &rCond ) : - rCond( rCond ) - { - } - - virtual ~Reader() - { - } - -protected: - virtual void run() - { - while( rCond.isOpen() ) - { - char buf[1025]; - - sio << "Reading..." << sio.flush; - Bu::size iRead = rCond.read( buf, 1024 ); - buf[iRead] = '\0'; - sio << "got " << iRead << " >" << buf << "<" << sio.nl; - } - - sio << "Conduit closed, exting thread." << sio.nl; - } - -private: - Bu::Conduit &rCond; -}; - -int main() -{ - Conduit c; - Reader r( c ); - r.start(); - - sleep( 3 ); - c.write("Hi there", 8 ); - sleep( 3 ); - c.write("Goodbye, soon.", 14 ); - sleep( 3 ); - c.write("...NOW!", 9 ); - c.close(); - sleep( 3 ); - - return 0; -} - diff --git a/src/tests/console.cpp b/src/tests/console.cpp deleted file mode 100644 index 670ff5b..0000000 --- a/src/tests/console.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -using namespace Bu; - -#include -using namespace std; - -typedef struct Counter -{ - Counter() : i( 0 ) - { - } - - int get() - { - i++; - return i-1; - } - - int i; -} Counter; - -template -void runtest( a &out ) -{ - Counter c; - out << c.get() << ", " << c.get() << ", " << c.get() << ", " << c.get() << ", " << c.get() << "\n"; -} - -int main() -{ - runtest( cout ); - runtest( sio ); - - return 0; -} - diff --git a/src/tests/cryptpass.cpp b/src/tests/cryptpass.cpp deleted file mode 100644 index d272344..0000000 --- a/src/tests/cryptpass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/crypt.h" -#include "bu/sio.h" - -using namespace Bu; - -int main( int argc, char *argv[] ) -{ - if( argc == 1 ) - sio << "Syntax: " << argv[0] << " [salt]" << sio.nl - << sio.nl; - else if( argc == 2 ) - sio << "Crypt1: >> " << cryptPass( argv[1] ) << " <<" << sio.nl; - else - sio << "Crypt2: >> " << cryptPass( argv[1], argv[2] ) << " <<" << sio.nl; - - return 0; -} - diff --git a/src/tests/csv.cpp b/src/tests/csv.cpp deleted file mode 100644 index 850fda8..0000000 --- a/src/tests/csv.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/optparser.h" -#include "bu/file.h" -#include "bu/newline.h" -#include "bu/csvreader.h" -#include "bu/buffer.h" -#include "bu/sio.h" - -using namespace Bu; - -class Options : public OptParser -{ -public: - Options( int argc, char *argv[] ) - { - addOption( slot( this, &Options::onRead ), 'r', "read", - "Read and display a csv file." ); - - addHelpOption(); - - parse( argc, argv ); - } - - int onRead( StrArray aArgs ) - { - File fIn( aArgs[1], File::Read ); - NewLine nlIn( fIn ); - Buffer bIn( nlIn ); - CsvReader rCsv( bIn ); - while( !fIn.isEos() ) - { - sio << rCsv.readLine() << sio.nl; - } - sio << sio.nl; - return 1; - } -}; - -int main( int argc, char *argv[] ) -{ - Options opts( argc, argv ); - return 0; -} - diff --git a/src/tests/daysinmonth.cpp b/src/tests/daysinmonth.cpp deleted file mode 100644 index 1e78eb3..0000000 --- a/src/tests/daysinmonth.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/sio.h" -#include "bu/util.h" - -using namespace Bu; - -int main() -{ - for( int j = 0; j < 12; j++ ) - { - sio << "2012-" << j << " = " - << getDaysInMonth( j, 2012 ) << sio.nl; - } - - return 0; -} - diff --git a/src/tests/fastcgi.cpp b/src/tests/fastcgi.cpp deleted file mode 100644 index 7447a6f..0000000 --- a/src/tests/fastcgi.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/fastcgi.h" - -#include - -class Cgi : public Bu::FastCgi -{ -public: - Cgi() : - Bu::FastCgi::FastCgi() - { - } - - Cgi( int iPort ) : - Bu::FastCgi::FastCgi( iPort ) - { - } - - virtual ~Cgi() - { - } - - virtual int onRequest( const StrHash &hParams, - const Bu::String &sStdIn, Bu::Stream &sStdOut, - Bu::Stream &/*sStdErr*/ ) - { - Bu::String sOut("Content-Type: text/html\r\n\r\n"); - sOut += "

Environment:

    "; - for( StrHash::const_iterator i = hParams.begin(); i; i++ ) - { - sOut += "
  • " + i.getKey() + " = " + - i.getValue() + "
  • "; - } - sOut += "
"; - char buf[2048]; - sOut += "

Cwd:

  • "; - sOut += getcwd( buf, 2048 ); - sOut += "
"; - sOut += "

Stdin:

"; - sOut += Bu::String("%1 bytes
").arg( sStdIn.getSize() );
-		Bu::String sL, sR;
-		for( Bu::String::const_iterator i = sStdIn.begin();
-			i; i++ )
-		{
-			sL += Bu::String("%1").arg(
-					(unsigned int)((unsigned char)*i), Bu::Fmt::hex().width(2).fill('0') );
-			if( *i < 27 )
-				sR += ". ";
-			else
-				sR += Bu::String("&#%1; ").arg(
-					(unsigned int)((unsigned char)*i) );
-			if( sL.getSize()/3 == 8 )
-			{
-				sOut += sL + " | " + sR + "\n";
-				sL = sR = "";
-			}
-		}
-		if( sL != "" )
-		{
-			while( sL.getSize()/3 < 8 )
-				sL += "   ";
-			sOut += sL + " | " + sR + "\n";
-		}
-		sOut += "

";
-		sOut += sStdIn;
-		sOut += "
"; - sOut += "


"; - sOut += ""; - - sStdOut.write( sOut ); - - return 0; - } -}; - -int main() -{ - Cgi c( 8789 ); - - c.run(); - - return 0; -} - diff --git a/src/tests/formula.cpp b/src/tests/formula.cpp deleted file mode 100644 index a90ddaf..0000000 --- a/src/tests/formula.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/formula.h" -#include - -int main( int argc, char *argv[] ) -{ - if( argc < 2 ) - { - printf("usage: %s \n", argv[0] ); - return -1; - } - Bu::Formula uForm; - Bu::Formula dForm; - - class DblCeilFunc : public Bu::Formula::Func - { - public: - virtual double operator()( double x ) - { - return ceil( x ); - } - }; - - dForm.hFunc.insert( "ceil", new DblCeilFunc() ); - - class IntCeilFunc : public Bu::Formula::Func - { - public: - virtual uint32_t operator()( uint32_t x ) - { - return x; - } - }; - - uForm.hFunc.insert( "ceil", new IntCeilFunc() ); - - uForm.hVars.insert("x", 10 ); - dForm.hVars.insert("x", 10.00 ); - uForm.hVars.insert("y", 10 ); - dForm.hVars.insert("y", 10.00 ); - - for( int j = 1; j < argc; j++ ) - { - printf("u: %s = %u\n", argv[j], uForm.run( argv[j] ) ); - printf("d: %s = %f\n", argv[j], dForm.run( argv[j] ) ); - } - - return 0; -} - diff --git a/src/tests/fstratsptr.cpp b/src/tests/fstratsptr.cpp deleted file mode 100644 index 5053dd1..0000000 --- a/src/tests/fstratsptr.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/string.h" -#include "bu/atom.h" -#include "bu/sptr.h" - -class Person -{ -public: - Person(){}; - virtual ~Person(){}; - - Bu::Atom sFirstName; - Bu::Atom sLastName; -}; - -typedef Bu::SPtr PersonPtr; - -void Swap(PersonPtr one, PersonPtr two) -{ - PersonPtr three(new Person); - three->sFirstName = one->sFirstName; - three->sLastName = two->sLastName; - - printf( - "%s %s\n", - three->sFirstName->getStr(), - three->sLastName->getStr() ); -} - -int main() -{ -/* PersonPtr one(new Person); - PersonPtr two(new Person); - one->sFirstName = "Bob"; - one->sLastName = "Smith"; - two->sFirstName = "Fred"; - two->sLastName = "Carpenter"; - - Swap(one, two); -*/ - - Bu::Atom sOne, sTwo; - sOne = "Hello"; - sTwo = sOne; - - return 0; -} diff --git a/src/tests/fstrstd.cpp b/src/tests/fstrstd.cpp deleted file mode 100644 index b2fed8a..0000000 --- a/src/tests/fstrstd.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include "bu/string.h" - -int main() -{ - Bu::String s("Hey there, dude.\n"); - -// std::cout << s << 5; -} diff --git a/src/tests/hash.cpp b/src/tests/hash.cpp deleted file mode 100644 index 7cefb79..0000000 --- a/src/tests/hash.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/hash.h" -#include "bu/sptr.h" - -typedef struct Bob -{ - int nID; -} Bob; - -int main() -{ - Bu::Hash > lb; - for( int j = 0; j < 10; j++ ) - { - Bob *b = new Bob; - b->nID = j; - lb.insert( j, b ); - } - - for( int j = 0; j < 10; j++ ) - { - printf("%d\n", lb[j].getValue()->nID ); - } -} - diff --git a/src/tests/hash2.cpp b/src/tests/hash2.cpp deleted file mode 100644 index 55bb4c9..0000000 --- a/src/tests/hash2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include - -int main() -{ - Bu::Hash hCmd; - - hCmd.insert("help", 5 ); - hCmd.insert("exit", 5 ); - hCmd.insert("getkey", 5 ); - hCmd.insert("setcrypt", 5 ); - hCmd.insert("user", 5 ); - hCmd.insert("pass", 5 ); - hCmd.erase("getkey"); - hCmd.erase("setcrypt"); - hCmd.insert("user", 5 ); - hCmd.insert("pass", 5 ); - hCmd.erase("pass"); - hCmd.erase("user"); - hCmd.insert("acl", 5 ); - hCmd.insert("owner", 5 ); - hCmd.insert("operator", 5 ); - hCmd.insert("admin", 5 ); - hCmd.insert("monitor", 5 ); - hCmd.insert("shutdown", 5 ); - - return 0; -} diff --git a/src/tests/heap.cpp b/src/tests/heap.cpp deleted file mode 100644 index 520a57f..0000000 --- a/src/tests/heap.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include - -#include "bu/formatter.h" -#include "bu/heap.h" -#include "bu/string.h" -#include "bu/file.h" - -typedef struct num -{ - num( int iNum, int iOrder ) : iNum( iNum ), iOrder( iOrder ) - { - } - - num( const num &src ) : iNum( src.iNum ), iOrder( src.iOrder ) - { - } - - int iNum; - int iOrder; - - bool operator<( const num &oth ) const - { - if( iNum == oth.iNum ) - return iOrder < oth.iOrder; - return iNum < oth.iNum; - } - bool operator>( const num &oth ) const - { - return iNum > oth.iNum; - } -} num; - -void printHeap( Bu::Heap &h, int j ) -{ -// return; - Bu::String sFName = Bu::String("graph-step-%1.dot").arg( j, Bu::Fmt().width(2).fill('0') ); - Bu::File fOut( sFName, Bu::File::WriteNew ); - Bu::Formatter f( fOut ); - f << "Graph step: " << j << ", total size: " << h.getSize() << f.nl; - for( Bu::Heap::iterator i = h.begin(); i; i++ ) - { - f << *i << f.nl; - } - f << f.nl; -} - -int main() -{ - /* - Bu::Heap hNum; - - for( int j = 0; j < 30; j++ ) - { - int r = rand()%10; - printf("Pushing: %d, top: ", r ); - hNum.enqueue( num( r, j ) ); - printf("%d\n", hNum.peek().iNum ); - } - - while( !hNum.isEmpty() ) - { - printf("(%d:%d) ", hNum.peek().iOrder, hNum.peek().iNum ); - hNum.dequeue(); - } - printf("\n"); -*/ - Bu::Heap hStr; - int j = 0; - - hStr.enqueue("George"); - printHeap( hStr, j++ ); - hStr.enqueue("George"); - printHeap( hStr, j++ ); - hStr.enqueue("Sam"); - printHeap( hStr, j++ ); - hStr.enqueue("Abby"); - printHeap( hStr, j++ ); - hStr.enqueue("Zorro"); - printHeap( hStr, j++ ); - hStr.enqueue("Brianna"); - printHeap( hStr, j++ ); - hStr.enqueue("Kate"); - printHeap( hStr, j++ ); - hStr.enqueue("Soggy"); - printHeap( hStr, j++ ); - - while( !hStr.isEmpty() ) - { - printf("\"%s\" ", hStr.dequeue().getStr() ); - printHeap( hStr, j++ ); - } - printf("\n"); - - Bu::List lStr; - - lStr.insertSorted("George"); - lStr.insertSorted("George"); - lStr.insertSorted("Sam"); - lStr.insertSorted("Abby"); - lStr.insertSorted("Zorro"); - lStr.insertSorted("Brianna"); - lStr.insertSorted("Kate"); - lStr.insertSorted("Soggy"); - for( Bu::List::iterator i = lStr.begin(); i; i++ ) - { - printf("\"%s\" ", (*i).getStr() ); - } - printf("\n"); - - return 0; -} - diff --git a/src/tests/itoheap.cpp b/src/tests/itoheap.cpp deleted file mode 100644 index ec06b90..0000000 --- a/src/tests/itoheap.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include -#include - -#include "bu/itoheap.h" -#include "bu/ito.h" - -class Consumer : public Bu::Ito -{ -public: - Consumer() - { - } - - virtual ~Consumer() - { - } - - void run() - { - for( int j = 0; j < 10; j++ ) - { - printf("Trying to read [%d].\n", j ); - - try - { - int iNum = hInt.dequeue( 0, 500000 ); - printf("Read %d\n", iNum ); - } - catch( Bu::HeapException &e ) - { - printf("Nothing yet...\n"); - } - } - } - - Bu::ItoHeap hInt; -}; - - -int main() -{ - Consumer c; - - for( int j = 0; j < 3; j++ ) - { - int iNum = rand()%10; - printf("Enqueuing %d.\n", iNum ); - c.hInt.enqueue( iNum ); - } - - printf("Sarting consumer.\n"); - c.start(); - - for( int j = 0; j < 5; j++ ) - { - sleep( 1 ); - int iNum = rand()%10; - printf("Enqueuing %d.\n", iNum ); - c.hInt.enqueue( iNum ); - } -} - diff --git a/src/tests/itoqueue1.cpp b/src/tests/itoqueue1.cpp deleted file mode 100644 index 27cb93c..0000000 --- a/src/tests/itoqueue1.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include "bu/ito.h" -#include "bu/itoqueue.h" -#include -#include - -class Reader : public Bu::Ito -{ -public: - Reader( Bu::ItoQueue &q, int id ) : - q( q ), - id( id ) - { - } - - void run() - { - for( int i = 0; i < 10; i++ ) - { - std::string *pStr = q.dequeue( true ); - if( pStr == NULL ) - { - printf("Null received...\n"); - } - else - { - printf("[%d] read: %s\n", id, pStr->c_str() ); - delete pStr; - } - usleep( (int)(((double)rand())/((double)RAND_MAX)*2000000.0) ); - } - } - -private: - Bu::ItoQueue &q; - int id; -}; - -class Writer : public Bu::Ito -{ -public: - Writer( Bu::ItoQueue &q, int id, const char *strbase ) : - q( q ), - strbase( strbase ), - id( id ) - { - } - - void run() - { - for( int i = 0; i < 11; i++ ) - { - usleep( (int)(((double)rand())/((double)RAND_MAX)*2000000.0) ); - q.enqueue( new std::string( strbase ) ); - printf("[%d] write: %s\n", id, strbase ); - } - } - -private: - Bu::ItoQueue &q; - const char *strbase; - int id; -}; - -int main() -{ - Writer *wr[5]; - Reader *rd[5]; - const char bob[][7]={ - {"Test 1"}, - {"Test 2"}, - {"Test 3"}, - {"Test 4"}, - {"Test 5"} - }; - - Bu::ItoQueue q; - - for( int j = 0; j < 5; j++ ) - { - wr[j] = new Writer( q, j, bob[j] ); - rd[j] = new Reader( q, j ); - } - - for( int j = 0; j < 5; j++ ) - { - rd[j]->start(); - } - - for( int j = 0; j < 5; j++ ) - { - wr[j]->start(); - } - - for( int j = 0; j < 5; j++ ) - { - rd[j]->join(); - } - - for( int j = 0; j < 5; j++ ) - { - delete wr[j]; - delete rd[j]; - } - - return 0; -} - diff --git a/src/tests/itoqueue2.cpp b/src/tests/itoqueue2.cpp deleted file mode 100644 index 10bc566..0000000 --- a/src/tests/itoqueue2.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include "bu/ito.h" -#include "bu/itoqueue.h" -#include -#include - -class Reader : public Bu::Ito -{ -public: - Reader( Bu::ItoQueue &q, int id ) : - q( q ), - id( id ) - { - } - - void run() - { - for( int i = 0; i < 10; i++ ) - { - std::string *pStr = q.dequeue( 0, 500000 ); - if( pStr == NULL ) - { - printf("Null received...\n"); - i--; - } - else - { - printf("[%d] read: %s\n", id, pStr->c_str() ); - delete pStr; - } - } - } - -private: - Bu::ItoQueue &q; - int id; -}; - -class Writer : public Bu::Ito -{ -public: - Writer( Bu::ItoQueue &q, int id, const char *strbase ) : - q( q ), - strbase( strbase ), - id( id ) - { - } - - void run() - { - for( int i = 0; i < 11; i++ ) - { - sleep( 2 ); - printf("[%d] write: %s\n", id, strbase ); - q.enqueue( new std::string( strbase ) ); - } - } - -private: - Bu::ItoQueue &q; - const char *strbase; - int id; -}; - -int main() -{ - printf("ETIMEDOUT: %d\n", ETIMEDOUT ); - Bu::ItoQueue q; - Writer wr( q, 0, "writer" ); - Reader rd( q, 0 ); - - rd.start(); - wr.start(); - - rd.join(); - wr.join(); - - return 0; -} - diff --git a/src/tests/itoserver.cpp b/src/tests/itoserver.cpp deleted file mode 100644 index 48ef527..0000000 --- a/src/tests/itoserver.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/itoserver.h" -#include "bu/protocol.h" -#include "bu/client.h" - -#define BU_TRACE -#include "bu/trace.h" - -class ProtocolEcho : public Bu::Protocol -{ -public: - ProtocolEcho() - { - TRACE(); - } - virtual ~ProtocolEcho() - { - TRACE(); - } - - virtual void onNewConnection( Bu::Client * ) - { - TRACE(); - // Huh... - } - - virtual void onNewData( Bu::Client *pClient ) - { - TRACE(); - char buf[1024]; - while( pClient->hasInput() ) - { - int iAmnt = pClient->read( buf, 1024 ); - pClient->write( buf, iAmnt ); - } - } -}; - -class TestServer : public Bu::ItoServer -{ -public: - TestServer() - { - TRACE(); - } - virtual ~TestServer() - { - TRACE(); - } - - virtual void onNewConnection( Bu::Client *pClient, int ) - { - TRACE(); - pClient->setProtocol( new ProtocolEcho() ); - } - - virtual void onClosedConnection( Bu::Client *pClient ) - { - TRACE(); - delete pClient->getProtocol(); - } -}; - -int main() -{ - TRACE(); - - TestServer ts; - - ts.addPort( 5555 ); - ts.start(); - ts.join(); -} - diff --git a/src/tests/list.cpp b/src/tests/list.cpp deleted file mode 100644 index aa3d32d..0000000 --- a/src/tests/list.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/list.h" -#include - -typedef struct Bob -{ - int nID; -} Bob; - -int main() -{ - Bu::List l; - - l.append( 0 ); - - for( int j = 3; j <= 21; j += 3 ) - { - l.append( j ); - l.prepend( -j ); - } - - { - Bu::List::iterator i = l.begin(); - Bu::List::iterator j = i; - int a, b; - a = *j; - printf("end: %s\n", (j != l.end())?"no":"yes"); - j--; - printf("end: %s\n", (j != l.end())?"no":"yes"); - j++; - printf("end: %s\n", (j != l.end())?"no":"yes"); - i = j; - b = *i; - printf("%d -> %d\n", a, b ); - } - - for( Bu::List::iterator i = l.begin(); i != l.end(); i++ ) - { - printf("%d ", *i ); - } - printf("\n"); - for( Bu::List::iterator i = l.begin(); i != l.end(); i++ ) - { - Bu::List::iterator j = i; j--; - l.erase( i ); - i = j; - if( i != l.end() ) - printf("!%d ", *i ); - } - - printf("\n\n"); - - Bu::List lb; - for( int j = 0; j < 10; j++ ) - { - Bob b; - b.nID = j; - lb.append( b ); - } - - const Bu::List rb = lb; - - for( Bu::List::const_iterator i = rb.begin(); i != rb.end(); i++ ) - { - //i->nID += 2; - //(*i).nID = 4; - printf("%d ", i->nID ); - } - printf("\n\n"); -} - diff --git a/src/tests/list2.cpp b/src/tests/list2.cpp deleted file mode 100644 index 567370e..0000000 --- a/src/tests/list2.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include - -using namespace Bu; - -int main() -{ - List lInt; - - lInt.append( 512 ); - lInt.append( 1024 ); - lInt.append( 4096 ); - lInt.append( 12 ); - lInt.erase( 12 ); - lInt.append( 12 ); - lInt.erase( 12 ); - lInt.append( 12 ); -} - diff --git a/src/tests/listsort.cpp b/src/tests/listsort.cpp deleted file mode 100644 index 4873a05..0000000 --- a/src/tests/listsort.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include -#include - -using namespace Bu; - -int main() -{ - /* - List il; - il.append( 5 ); - il.append( 12 ); - il.append( 0 ); - il.append( 7 ); - il.append( 3 ); - il.append( 5 ); - Bu::__basicLTCmp cmp; - il.sortI( cmp ); - */ - - String a("Soggy"), b("Sam"); - - if( a < b ) - { - sio << "Bad" << sio.nl; - } - else - { - sio << "Good" << sio.nl; - } - - typedef List StrList; - - StrList lNames; - - lNames.append("George"); - lNames.append("Sam"); - lNames.append("Abby"); - lNames.append("Zorro"); - lNames.append("Brianna"); - lNames.append("Kate"); - lNames.append("Soggy"); - - sio << "Names: " << lNames << sio.nl; - lNames.sort(); - - sio << "Names: " << lNames << sio.nl; - - StrList lNames2; - - lNames2.insertSorted("George"); - lNames2.insertSorted("Sam"); - lNames2.insertSorted("Abby"); - lNames2.insertSorted("Zorro"); - lNames2.insertSorted("Brianna"); - lNames2.insertSorted("Kate"); - lNames2.insertSorted("Soggy"); - - sio << "Names: " << lNames2 << sio.nl; - - if( lNames == lNames2 ) - { - sio << "They're the same." << sio.nl; - } - else - { - sio << "They're different." << sio.nl; - } - - return 0; -} - diff --git a/src/tests/logger.cpp b/src/tests/logger.cpp deleted file mode 100644 index e97193c..0000000 --- a/src/tests/logger.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/logger.h" -#include -#include - -class Thing -{ - public: - Thing() - { - lineLog( 2, "Want a thing?"); - } - - void go( int ) - { - lineLog( 1, "GO!!!!"); - } -}; - -int main() -{ - setLogLevel( 4 ); - setLogFormat("%L: %y-%02m-%02d %h:%02M:%02s %f:%l:%F: %t"); - lineLog( 5, "Hey, error: %s", strerror( errno ) ); - - logHexDump( 5, "This is a test of the hex-dump facility", 16, "Random stuff"); - - Thing gh; - gh.go( 6 ); -} - diff --git a/src/tests/md5.cpp b/src/tests/md5.cpp deleted file mode 100644 index a32f669..0000000 --- a/src/tests/md5.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/sio.h" -#include "bu/file.h" -#include "bu/md5.h" - -using Bu::sio; - -int main( int argc, char *argv[] ) -{ - argv++, argc--; - for(; *argv; argv++ ) - { - Bu::File fIn( *argv, Bu::File::Read ); - Bu::Md5 m; - - char buf[100000]; - for(;;) - { - int iRead = fIn.read( buf, 100000 ); - m.addData( buf, iRead ); - if( iRead < 100000 ) - break; - } - - sio << m.getHexResult() << " *" << *argv << sio.nl; - } -} - diff --git a/src/tests/minicron.cpp b/src/tests/minicron.cpp deleted file mode 100644 index aed63e2..0000000 --- a/src/tests/minicron.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/minicron.h" -#include "bu/sio.h" - -#include - -using namespace Bu; - -Bu::MiniCron mCron; - -void job0( Bu::MiniCron::Job &job ) -{ - sio << time( NULL ) << ": job0( id = " << job.getId() << ", count = " - << job.getRunCount() << ")" << sio.nl; -} - -void job1( Bu::MiniCron::Job &job ) -{ - sio << time( NULL ) << ": job1( id = " << job.getId() << ", count = " - << job.getRunCount() << ")" << sio.nl; - mCron.removeJob( 4 ); -} - -void job2( Bu::MiniCron::Job &job ) -{ - sio << time( NULL ) << ": job2( id = " << job.getId() << ", count = " - << job.getRunCount() << ")" << sio.nl; -} - -void job3( Bu::MiniCron::Job &job ) -{ - sio << time( NULL ) << ": job3( id = " << job.getId() << ", count = " - << job.getRunCount() << ")" << sio.nl; -} - -int main() -{ - mCron.addJob( - "job0", slot( &job0 ), MiniCron::TimerInterval( time(NULL)+3, 5 ) ); - mCron.addJob( - "job1", slot( &job1 ), MiniCron::TimerInterval( time(NULL)+10, 8 ) ); - mCron.addJob( - "job2", slot( &job2 ), MiniCron::TimerBasic("weekly wed 17") ); - mCron.addJob( - "job3", slot( &job3 ), MiniCron::TimerInterval( time(NULL)+1, 2 ) ); - - sio << time( NULL ) << ": Program started." << sio.nl; - - for(;;) - { - usleep( 50000 ); - mCron.poll(); - } - - return 0; -} - diff --git a/src/tests/mmparse.cpp b/src/tests/mmparse.cpp deleted file mode 100644 index c1ce862..0000000 --- a/src/tests/mmparse.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/minimacro.h" -#include "bu/string.h" - -int main() -{ - Bu::MiniMacro mm; - - mm.addVar("name", "Mike"); - mm.addVar("age", "no"); - - printf("%s\n", mm.parse("Hey there {=name:toupper():tolower()}, how are you?").getStr() ); - - return 0; -} - diff --git a/src/tests/multiserver.cpp b/src/tests/multiserver.cpp deleted file mode 100644 index 12f4681..0000000 --- a/src/tests/multiserver.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/multiserver.h" -#include "bu/protocol.h" -#include "bu/client.h" - -class ProtocolRaw : public Bu::Protocol -{ -public: - virtual void onNewConnection( Bu::Client *pClient ) - { - pClient->write("Raw echo\n"); - } - - virtual void onNewData( Bu::Client *pClient ) - { - char buf[1024]; - while( pClient->hasInput() ) - { - int iAmnt = pClient->read( buf, 1024 ); - pClient->write( buf, iAmnt ); - } - } -}; - -class ProtocolRot13 : public Bu::Protocol -{ -public: - virtual void onNewConnection( Bu::Client *pClient ) - { - pClient->write("Rot13 echo\n"); - } - - virtual void onNewData( Bu::Client *pClient ) - { - while( pClient->hasInput() ) - { - char sTmp[1024]; - int iAmnt = pClient->read( sTmp, 1024 ); - for( int j = 0; j < iAmnt; j++ ) - { - if( sTmp[j] >= 'a' && sTmp[j] <= 'z' ) - { - sTmp[j] = ((sTmp[j]-'a'+13)%26) + 'a'; - } - else if( sTmp[j] >= 'A' && sTmp[j] <= 'Z' ) - { - sTmp[j] = ((sTmp[j]-'A'+13)%26) + 'A'; - } - } - pClient->write( sTmp, iAmnt ); - } - } -}; - -int main() -{ - Bu::MultiServer msMain; - - msMain.addProtocol( Bu::genProtocol, 5550 ); - msMain.addProtocol( Bu::genProtocol, 5551 ); - msMain.setTimeout( 5, 0 ); - - for(;;) - { - msMain.scan(); - } - - return 0; -} - diff --git a/src/tests/procs.cpp b/src/tests/procs.cpp deleted file mode 100644 index 94d2cc5..0000000 --- a/src/tests/procs.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/process.h" - -#include - -int main() -{ - Bu::Process p( Bu::Process::Both, "/bin/bash", "/bin/bash", "-c", "echo Hello 1>&2; echo StdOut; sleep 1; echo Yup; echo Yup 1>&2", NULL ); - - char buf[1000]; - while( !p.isEos() ) - { - bool out, err; - p.select( out, err ); - if( out ) - { - int iSize = p.read( buf, 1000 ); - printf("::read=%d::\n", iSize ); - fwrite( buf, iSize, 1, stdout ); - } - if( err ) - { - int iSize = p.readErr( buf, 1000 ); - printf("::readErr=%d::\n", iSize ); - fwrite( buf, iSize, 1, stdout ); - } - } - - return 0; -} - diff --git a/src/tests/queuebuf.cpp b/src/tests/queuebuf.cpp deleted file mode 100644 index f872738..0000000 --- a/src/tests/queuebuf.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include - -using namespace Bu; - -int main() -{ - static const char *src = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%#"; - QueueBuf qb; - - for( int j = 0; j < 8; j++ ) - { - qb.write( src, 60 ); - } - - char buf[11], bufp[11]; - while( !qb.isEos() ) - { - int iAmntPeek = qb.peek( bufp, 9 ); - int iAmntRead = qb.read( buf, 9 ); - if( iAmntPeek != iAmntRead ) - sio << "Differ: " << iAmntPeek << " vs " << iAmntRead << sio.nl; - buf[iAmntRead] = '\0'; - bufp[iAmntPeek] = '\0'; - if( memcmp( buf, bufp, iAmntPeek ) ) - { - sio << "Buffers differ" << sio.nl - << " " << buf << sio.nl - << " " << bufp << sio.nl; - } - else - sio << "Read: >>" << buf << "<<" << sio.nl; - } - - sio << sio.nl << sio.nl << sio.nl << "Seek test:" << sio.nl << sio.nl; - - for( int j = 0; j < 5; j++ ) - { - qb.write( src, 25 ); - qb.write( src+10, 25 ); - } - - char bufa[26]; - char bufb[26]; - ::memcpy( bufb, src+10, 15 ); - ::memcpy( bufb+15, src+10, 10 ); - bufb[25] = '\0'; - sio << "Comparing to '" << bufb << "'" << sio.nl; - qb.seek( 10 ); - while( !qb.isEos() ) - { - bufa[qb.read( bufa, 25 )] = '\0'; - qb.seek( 25 ); - if( memcmp( bufa, bufb, 25 ) ) - sio << "Differ?" << sio.nl; - sio << "=== '" << bufa << "' == '" << bufb << "'" << sio.nl; - } -} - diff --git a/src/tests/regex.cpp b/src/tests/regex.cpp deleted file mode 100644 index 376fbb2..0000000 --- a/src/tests/regex.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include - -int main( int argc, char *argv[] ) -{ - if( argc < 3 ) - { - printf("No... %s \n\n", argv[0] ); - return 0; - } - - Bu::RegEx re( argv[1] ); - - printf("Regex: %s\n", argv[1] ); - printf("Match: %s\n", argv[2] ); - - if( re.execute( argv[2] ) ) - { - for( int j = 0; j < re.getNumSubStrings(); j++ ) - { - printf("SubStr %d: %s\n", j, re.getSubString( j ).getStr() ); - } - } - else - { - printf("Regex did not match.\n"); - } - - return 0; -} - diff --git a/src/tests/ringbuffer.cpp b/src/tests/ringbuffer.cpp deleted file mode 100644 index da5126c..0000000 --- a/src/tests/ringbuffer.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/ringbuffer.h" -#include -#include -#include - -int main() -{ - Bu::RingBuffer ibuf( 10 ); - - for( int k = 0; k < 2; k++ ) - { - int j = 1; - for(; j < 7; j++ ) - { - ibuf.enqueue( j ); - } - - for(; j < 20; j++ ) - { - ibuf.enqueue( j ); - printf("- %d\n", ibuf.dequeue() ); - } - - for(;;) - { - if( ibuf.isEmpty() ) break; - printf(". %d\n", ibuf.dequeue() ); - } - } -} - diff --git a/src/tests/rot13.cpp b/src/tests/rot13.cpp deleted file mode 100644 index 1530af3..0000000 --- a/src/tests/rot13.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/protocol.h" -#include "bu/multiserver.h" -#include "bu/client.h" -#include "bu/filter.h" - -using namespace Bu; - -class Rot13Filter : public Filter -{ -public: - Rot13Filter( Stream &next ) : - Filter( next ) - { - } - - virtual ~Rot13Filter() - { - } - - virtual void start() - { - } - - virtual Bu::size stop() - { - return 0; - } - - virtual Bu::size read( void *pBuf, Bu::size nBytes ) - { - return rNext.read( pBuf, nBytes ); - } - - virtual Bu::size write( const void *pBuf, Bu::size nBytes ) - { - const char *cBuf = (const char *)pBuf; - char *buf = new char[nBytes]; - for( Bu::size j = 0; j < nBytes; j++ ) - { - if( cBuf[j] >= 'a' && cBuf[j] <= 'z' ) - buf[j] = (cBuf[j]-'a'+13)%26+'a'; - else if( cBuf[j] >= 'A' && cBuf[j] <= 'Z' ) - buf[j] = (cBuf[j]-'A'+13)%26+'A'; - else - buf[j] = cBuf[j]; - } - rNext.write( buf, nBytes ); - delete[] buf; - return nBytes; - } -}; - -class Rot13Protocol : public Protocol -{ -public: - void onNewConnection( Bu::Client *pClient ) - { - pClient->pushFilter(); - } - - void onNewData( Bu::Client *pClient ) - { - char buf[1024]; - while( pClient->hasInput() ) - { - int iAmnt = pClient->read( buf, 1024 ); - pClient->write( buf, iAmnt ); - } - } -}; - -int main() -{ - MultiServer xSrv; - - xSrv.setTimeout( 5 ); - xSrv.addProtocol( genProtocol, 9999 ); - - for(;;) - xSrv.scan(); - - return 0; -} - diff --git a/src/tests/serverticks.cpp b/src/tests/serverticks.cpp deleted file mode 100644 index 3872a16..0000000 --- a/src/tests/serverticks.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/server.h" -#include "bu/client.h" -#include "bu/protocol.h" -#include - -class TickProtocol : public Bu::Protocol -{ -public: - TickProtocol() - { - } - - virtual ~TickProtocol() - { - } - - virtual void onTick( Bu::Client *pClient ) - { - printf("tick!\n"); - pClient->write("tick!\n"); - } -}; - -class TickServer : public Bu::Server -{ -public: - TickServer() - { - } - - virtual ~TickServer() - { - } - - virtual void onNewConnection( Bu::Client *pClient, int ) - { - pClient->setProtocol( new TickProtocol() ); - } - - virtual void onClosedConnection( Bu::Client *pClient ) - { - delete pClient->getProtocol(); - } -}; - -int main( int , char *[] ) -{ - TickServer ts; - - ts.setTimeout( 1, 0 ); - ts.setAutoTick(); - ts.addPort( 5555 ); - - for(;;) - { - ts.scan(); - sleep( 1 ); - } - - return 0; -} - diff --git a/src/tests/sha1.cpp b/src/tests/sha1.cpp deleted file mode 100644 index ac795e7..0000000 --- a/src/tests/sha1.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/sio.h" -#include "bu/file.h" -#include "bu/sha1.h" - -using namespace Bu; - -int main( int argc, char *argv[] ) -{ - argv++, argc--; - for(; *argv; argv++ ) - { - Bu::File fIn( *argv, Bu::File::Read ); - Bu::Sha1 m; - - char buf[100000]; - for(;;) - { - int iRead = fIn.read( buf, 100000 ); - m.addData( buf, iRead ); - if( iRead < 100000 ) - break; - } - - Bu::String sRes = m.getResult(); - for( Bu::String::iterator i = sRes.begin(); i; i++ ) - { - sio << Fmt::hex(2,false) << (int)(unsigned char)(*i); - } - sio << " *" << *argv << sio.nl; - } -} - diff --git a/src/tests/sharedcore.cpp b/src/tests/sharedcore.cpp deleted file mode 100644 index c68f07b..0000000 --- a/src/tests/sharedcore.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/sharedcore.h" -#include "bu/sio.h" - -using namespace Bu; - -struct ShintCore -{ - int val; -}; -class Shint : public Bu::SharedCore -{ -public: - Shint() - { - core->val = 0; - } - - Shint( int val ) - { - core->val = val; - } - - int getVal() const - { - return core->val; - } - - void setValBad( int val ) - { - core->val = val; - } - - void setVal( int val ) - { - _hardCopy(); - core->val = val; - } - - bool operator==( const Shint &rhs ) - { - if( core == rhs.core ) - { - sio << "Same pointer (" << Fmt::ptr() << core << ")" << sio.nl; - return true; - } - if( core->val == rhs.core->val ) - { - sio << "Same value " << core->val << " (" - << Fmt::ptr() << core << " vs " - << Fmt::ptr() << rhs.core << ")" - << sio.nl; - return true; - } - sio << "Different" << sio.nl; - return false; - } -}; - -#define line( x ) sio << __FILE__ ": " << __LINE__ << ": " << #x << sio.nl; x - -int main() -{ - line( Shint a; ) - line( Shint b( 5 ); ) - - line( a == b; ) - - line( b = a; ) - line( a == b; ) - - line( b.setValBad( 12 ); ) - sio << a.getVal() << " != " << b.getVal() << sio.nl; - line( a == b; ) - - line( a.setVal( 3 ); ) - sio << a.getVal() << " != " << b.getVal() << sio.nl; - line( a == b; ) - - line( a.setVal( b.getVal() ); ) - line( a == b; ) - - { - Shint c( b ); - Shint d( c ); - sio << c.getVal(); - d.setVal( 43 ); - } - - sio << b.getVal(); -} - diff --git a/src/tests/signals.cpp b/src/tests/signals.cpp deleted file mode 100644 index 14bbc9c..0000000 --- a/src/tests/signals.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include - -using namespace Bu; - -class Thing -{ -public: - Thing() : - iState( 82731 ) - { - } - - virtual ~Thing() - { - } - - void fnc0() - { - sio << iState << ": void fnc0()" << sio.nl; - } - - void fnc1( int a ) - { - sio << iState << ": void fnc1( " << a << " )" << sio.nl; - } - - void fnc2( int a, Bu::String b ) - { - sio << iState << ": void fnc2( " << a << ", \"" << b << "\" )" << sio.nl; - } - - void fnc3( int a, Bu::String b, double c ) - { - sio << iState << ": void fnc3( " << a << ", \"" << b << "\", " << c << " )" << sio.nl; - } - - void fnc4( int a, Bu::String b, double c, char d ) - { - sio << iState << ": void fnc4( " << a << ", \"" << b << "\", " << c << ", '" << d << "' )" << sio.nl; - } - - void fnc5( int a, Bu::String b, double c, char d, long e ) - { - sio << iState << ": void fnc5( " << a << ", \"" << b << "\", " << c << ", '" << d << "', " << e << " )" << sio.nl; - } - -private: - int iState; -}; - -void pfnc0() -{ - sio << ": void pfnc0()" << sio.nl; -} - -void pfnc1( int a ) -{ - sio << ": void pfnc1( " << a << " )" << sio.nl; -} - -void pfnc2( int a, Bu::String b ) -{ - sio << ": void pfnc2( " << a << ", \"" << b << "\" )" << sio.nl; -} - -void pfnc3( int a, Bu::String b, double c ) -{ - sio << ": void pfnc3( " << a << ", \"" << b << "\", " << c << " )" << sio.nl; -} - -void pfnc4( int a, Bu::String b, double c, char d ) -{ - sio << ": void pfnc4( " << a << ", \"" << b << "\", " << c << ", '" << d << "' )" << sio.nl; -} - -void pfnc5( int a, Bu::String b, double c, char d, long e ) -{ - sio << ": void pfnc5( " << a << ", \"" << b << "\", " << c << ", '" << d << "', " << e << " )" << sio.nl; -} - -void callit( Signal0 sig ) -{ - sig(); -} - -int main() -{ - Thing t; - - Signal0 cb0( slot( &t, &Thing::fnc0 ) ); - cb0(); - cb0 = slot( &pfnc0 ); - cb0(); - - Signal1 cb1( slot( &t, &Thing::fnc1 ) ); - cb1( 5 ); - cb1 = slot( &pfnc1 ); - cb1( 5 ); - - Signal2 cb2( slot( &t, &Thing::fnc2 ) ); - cb2( 5, "Hi there" ); - cb2 = slot( &pfnc2 ); - cb2( 5, "Hi there" ); - - Signal3 cb3( slot( &t, &Thing::fnc3 ) ); - cb3( 5, "Hi there", 12.85 ); - cb3 = slot( &pfnc3 ); - cb3( 5, "Hi there", 12.85 ); - - Signal4 cb4( slot( &t, &Thing::fnc4 ) ); - cb4( 5, "Hi there", 12.85, 'z' ); - cb4 = slot( &pfnc4 ); - cb4( 5, "Hi there", 12.85, 'z' ); - - Signal5 cb5( slot( &t, &Thing::fnc5 ) ); - cb5( 5, "Hi there", 12.85, 'z', 849 ); - cb5 = slot( &pfnc5 ); - cb5( 5, "Hi there", 12.85, 'z', 849 ); - -// Signal1 cb1( slot( &t, &Thing::fnc1 ) ); -// sio << "Result: " << cb1( 5 ) << sio.nl; -} - diff --git a/src/tests/size.cpp b/src/tests/size.cpp deleted file mode 100644 index dfad16f..0000000 --- a/src/tests/size.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/hash.h" -#include "bu/string.h" - -#define pSize( t ) printf("%15s: %db\n", #t, sizeof( t ) ); - -int main() -{ - typedef Bu::Hash charcharHash; - typedef Bu::Hash strstrHash; - pSize( Bu::String ); - pSize( charcharHash ); - pSize( strstrHash ); -} diff --git a/src/tests/socketblock.cpp b/src/tests/socketblock.cpp deleted file mode 100644 index e36bb33..0000000 --- a/src/tests/socketblock.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/ito.h" -#include "bu/tcpsocket.h" -#include "bu/tcpserversocket.h" -#include -#include - -class TstServer : public Bu::Ito -{ -public: - TstServer() : - s( 55678 ) - { - } - - virtual void run() - { - Bu::TcpSocket c = s.accept( 45, 0 ); - printf("TstServer: Accetped connection.\n"); fflush( stdout ); - - sleep( 1 ); - printf("TstServer: Trying to read 10 bytes...\n"); fflush( stdout ); - - char buf[10]; - size_t nRead = c.read( buf, 10 ); - printf("TstServer: Got %d bytes...\n", nRead ); fflush( stdout ); - - printf("TstServer: Closing connection...\n"); fflush( stdout ); - c.close(); - } - - Bu::TcpServerSocket s; -}; - -int main() -{ - TstServer ts; - - ts.start(); - - printf("main: Connecting to server.\n"); fflush( stdout ); - Bu::TcpSocket s( "localhost", 55678 ); - - printf("main: Sending 4 bytes.\n"); fflush( stdout ); - s.write( "aoeu", 4 ); - - printf("main: Sleeping 10 seconds for good measure.\n"); fflush( stdout ); - sleep( 10 ); -} - diff --git a/src/tests/socketbreak.cpp b/src/tests/socketbreak.cpp deleted file mode 100644 index d58ebcf..0000000 --- a/src/tests/socketbreak.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/tcpserversocket.h" -#include "bu/tcpsocket.h" -#include - -int main() -{ - Bu::TcpServerSocket sSrv( 9987 ); - - Bu::TcpSocket sSend("localhost", 9987 ); - - Bu::TcpSocket sRecv( sSrv.accept() ); - - printf("Connected sockets.\n"); - - sleep( 1 ); - printf("Closing sRecv.\n"); - sRecv.close(); - sleep( 1 ); - - char buf[3]; - printf("About to write.\n"); - printf("write: %lld\n", sSend.write("hi", 2 ) ); - printf("About to read.\n"); - printf("read: %lld\n", sSend.read( buf, 2 ) ); - - return 0; -} - diff --git a/src/tests/speed.cpp b/src/tests/speed.cpp deleted file mode 100644 index 2fa29aa..0000000 --- a/src/tests/speed.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/string.h" -#include - -template -struct tstCopy -{ - tstCopy( const a &src ) : - src( src ) - { - } - - void operator()() - { - a tmp = src; - } - - a src; -}; - -template -double runTest( f fnc ) -{ - struct timeval tStart, tEnd; - int j = 0; - gettimeofday( &tStart, NULL ); - for(; j < 500000; j++ ) - fnc(); - gettimeofday( &tEnd, NULL ); - - return (double)(tEnd.tv_sec-tStart.tv_sec)+ - (double)(tEnd.tv_usec-tStart.tv_usec)/1000000.0; -} - -template -void fullTest( tst t ) -{ - double dTotal; - int iCount = 10; - for( int j = 0; j < iCount; j++ ) - dTotal += runTest( t ); - printf("Average time: %f\n", dTotal/iCount ); -} - -int main() -{ - Bu::String str; - for( int j = 0; j < 500; j++ ) - str.append("Hey, this is a test string. It will be reapeated many, many times. How's that?"); - fullTest( tstCopy( str ) ); -} - diff --git a/src/tests/stdstream.cpp b/src/tests/stdstream.cpp deleted file mode 100644 index 95df42e..0000000 --- a/src/tests/stdstream.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/sio.h" - -using Bu::sio; -using Bu::Fmt; - -int main() -{ - sio << "Hello there" << sio.nl; - - sio << "sizeof(Fmt) = " << sizeof(Fmt) << sio.nl; - - sio << -123 << ", " << 0 << ", " << 123 << sio.nl; - - sio << "+----------+" << sio.nl; - sio << "|" << Fmt( 10, 10, Fmt::Center ) << "Test" << "|" << sio.nl; - sio << "+----------+" << sio.nl; - sio << "|" << Fmt( 10, 10, Fmt::Left ) << 123 << "|" << sio.nl; - sio << "|" << Fmt( 10, 10, Fmt::Center ) << 123 << "|" << sio.nl; - sio << "|" << Fmt( 10, 10, Fmt::Right ) << 123 << "|" << sio.nl; - sio << "+----------+" << sio.nl; - - sio << Fmt(10,Fmt::Left) << "Hexcode:" << Fmt::ptr() << (void*)(&sio) << sio.nl; - - sio << 0.123 << sio.nl; - sio << true << " and then " << false << sio.nl; - - for( int j = 2; j <= 36; j++ ) - sio << "radix(" << j << ") = " << Fmt().radix( j ).width( 8 ).align( Fmt::Right ) << 255 << sio.nl; - - return 0; -} - diff --git a/src/tests/streamstack.cpp b/src/tests/streamstack.cpp deleted file mode 100644 index 4a0e128..0000000 --- a/src/tests/streamstack.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/streamstack.h" - -#include "bu/file.h" -#include "bu/base64.h" -#include "bu/bzip2.h" - -#include "bu/sio.h" - -#include - -using namespace Bu; - -class DoStuff -{ -public: - DoStuff( Bu::Stream &rStream ) : - rStream( rStream ) - { - } - - virtual ~DoStuff() - { - } - - void write() - { - Bu::String s; - time_t tNow = time( NULL ); - s = ctime( &tNow ); - long lSize = s.getSize()-1; - rStream.write( &lSize, sizeof(long) ); - rStream.write( s.getStr(), lSize ); - } - - void read() - { - Bu::String s; - long lSize; - rStream.read( &lSize, sizeof(long) ); - s.setSize( lSize ); - rStream.read( s.getStr(), lSize ); - sio << "Read str(" << lSize << ") = '" << s << "'" << sio.nl; - } - -private: - Bu::Stream &rStream; -}; - -int main() -{ - Bu::StreamStack ss; - - DoStuff ds( ss ); - - try - { - ds.write(); - sio << "This shouldn't have worked." << sio.nl; - } - catch( Bu::ExceptionBase &e ) - { - sio << "Got exception, this is good: " << e.what() << sio.nl; - } - - ss.setStream( new Bu::File("Hello.test", Bu::File::WriteNew ) ); - - ds.write(); - - ss.pushFilter(); - - ds.write(); - - ss.pushFilter(); - - ds.write(); - - ss.clear(); - - ss.setStream( new Bu::File("Hello.test", Bu::File::Read ) ); - - ds.read(); - - ss.pushFilter(); - - ds.read(); - - ss.pushFilter(); - - ds.read(); - - return 0; -} - diff --git a/src/tests/string.cpp b/src/tests/string.cpp deleted file mode 100644 index b37460e..0000000 --- a/src/tests/string.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/hash.h" -#include "bu/string.h" -#include -#include - -#ifndef WIN32 -inline double getTime() -{ - struct timeval tv; - gettimeofday( &tv, NULL ); - return ((double)tv.tv_sec) + ((double)tv.tv_usec/1000000.0); -} -#else -#include "windows.h" -#include "winbase.h" -inline double getTime() -{ - uint32_t t = (uint32_t) GetTickCount(); - return (double) t / 1000.0; -} -#endif - -Bu::String genThing() -{ - Bu::String bob; - bob.append("ab "); - bob += "cd "; - bob += "efg"; - - printf("---bob------\n%08tX: %s\n", (ptrdiff_t)bob.getStr(), - bob.getStr() ); - return bob; -} - -void thing( Bu::String str ) -{ - printf("Hey: %s\n", str.getStr() ); -} - -void copyfunc( std::string temp ) -{ - temp += "Hi"; -} - -void copyfunc( Bu::String temp ) -{ - temp += "Hi"; -} - -void doTimings() -{ - Bu::String fs1, fs2; - std::string ss1, ss2; - double dStart, dEnd, tfs1, tfs2, tfs3, tss1, tss2, tss3; - int nChars = 50000000, nChunks=50000, nCopies=500000000, nChunkSize=1024*4; - char *buf = new char[nChunkSize]; - memset( buf, '!', nChunkSize ); - - printf("Timing Bu::String single chars...\n"); - dStart = getTime(); - for( int j = 0; j < nChars; j++ ) fs1 += (char)('a'+(j%26)); - fs1.getStr(); - dEnd = getTime(); - tfs1 = dEnd-dStart; - - printf("Timing std::string single chars...\n"); - dStart = getTime(); - for( int j = 0; j < nChars; j++ ) ss1 += (char)('a'+(j%26)); - ss1.c_str(); - dEnd = getTime(); - tss1 = dEnd-dStart; - - printf("Timing Bu::String %d char chunks...\n", nChunkSize); - dStart = getTime(); - for( int j = 0; j < nChunks; j++ ) fs2.append(buf, nChunkSize); - fs2.getStr(); - dEnd = getTime(); - tfs2 = dEnd-dStart; - - printf("Timing std::string %d char chunks...\n", nChunkSize); - dStart = getTime(); - for( int j = 0; j < nChunks; j++ ) ss2.append(buf, nChunkSize); - ss2.c_str(); - dEnd = getTime(); - tss2 = dEnd-dStart; - - fs2 = "Hello there."; - ss2 = "Hello there."; - printf("Timing Bu::String copies...\n"); - dStart = getTime(); - for( int j = 0; j < nCopies; j++ ) Bu::String stmp = fs2; - dEnd = getTime(); - tfs3 = dEnd-dStart; - - printf("Timing std::string copies...\n"); - dStart = getTime(); - for( int j = 0; j < nCopies; j++ ) std::string stpm = ss2; - dEnd = getTime(); - tss3 = dEnd-dStart; - - printf( - "Results: singles: chunks: copies:\n" - "Bu::String %15.2f/s %15.2f/s %15.2f/s\n" - "std::string %15.2f/s %15.2f/s %15.2f/s\n", - nChars/tfs1, nChunks/tfs2, nCopies/tfs3, - nChars/tss1, nChunks/tss2, nCopies/tss3 ); - - delete[] buf; -} - -#define pem printf("---------\n%08tX: %s\n%08tX: %s\n", (ptrdiff_t)str.getConstStr(), str.getConstStr(), (ptrdiff_t)str2.getConstStr(), str2.getConstStr() ); -int main( ) -{ -// Bu::String fs1; -// for( int j = 0; j < 500000; j++ ) fs1 += (char)('a'+(j%26)); -// return 0; - - Bu::String str("th"); - - str.prepend("Hello "); - str.append("ere."); - - Bu::String str2( str ); - pem; - str += " What's up?"; - pem; - str2 += " How are you?"; - pem; - str = str2; - pem; - - str2 = genThing(); - pem; - - str = str2; - pem; - - thing( str2 ); - thing("test."); - - printf("%d == %d\n", Bu::__calcHashCode( str ), Bu::__calcHashCode( str.getStr() ) ); - - doTimings(); - - return 0; -} - diff --git a/src/tests/stringspeed.cpp b/src/tests/stringspeed.cpp deleted file mode 100644 index 5636de7..0000000 --- a/src/tests/stringspeed.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include - -#include -#include - -void timeit( void (*func)(), const char *sName, int iIter ) -{ - struct timeval ts, te; - - gettimeofday( &ts, NULL ); - for( int j = 0; j < iIter; j++ ) - { - func(); - } - gettimeofday( &te, NULL ); - - double dTotal = (double)(te.tv_sec-ts.tv_sec) + (double)(te.tv_usec-ts.tv_usec)/1000000.0; - printf("%10s: %f spi (%f total)\n", sName, dTotal/iIter, dTotal ); -} - -void append1() -{ - Bu::String sTmp; - for( int c = 0; c < 5000; c++ ) - { - sTmp += (char)(c%256); - } -} - -void append2() -{ - Bu::String sTmp; - for( int c = 0; c < 5000; c++ ) - { - sTmp.append( (char)(c%256) ); - } -} - -void append3() -{ - Bu::String sTmp; - for( int c = 0; c < 5000; c++ ) - { - sTmp += "Test"; - } -} - -void append4() -{ - Bu::String sTmp; - for( int c = 0; c < 5000; c++ ) - { - sTmp.append("Test"); - } -} - -void append5() -{ - Bu::String sTmp, sAdd("Test"); - for( int c = 0; c < 5000; c++ ) - { - sTmp += sAdd; - } -} - -void append6() -{ - Bu::String sTmp, sAdd("Test"); - for( int c = 0; c < 5000; c++ ) - { - sTmp.append( sAdd ); - } -} - -void prepend1() -{ - Bu::String sTmp; - for( int c = 0; c < 5000; c++ ) - { - sTmp.prepend('c'); - } -} - -void copy1() -{ - Bu::String sSrc; - for( int c = 0; c < 1000; c++ ) - { - sSrc += (char)(c%256); - Bu::String sTmp = sSrc; - sTmp.append( '-' ); - } -} - -void copy2() -{ - Bu::String sSrc; - for( int c = 0; c < 1000; c++ ) - { - sSrc += (char)(c%256); - Bu::String sTmp = sSrc; - } -} - -void replace1() -{ - Bu::String s("Hey, this is a replacement test, what do you thing of it?"); - s.replace("e", "X").replace("a", "X").replace("what","XXX"); -} - -int main() -{ - timeit( append1, "Append1", 5000 ); - timeit( append2, "Append2", 5000 ); - timeit( append3, "Append3", 2000 ); - timeit( append4, "Append4", 2000 ); - timeit( append4, "Prepend1", 2000 ); - timeit( copy1, "Copy1", 2000 ); - timeit( copy2, "Copy2", 2000 ); - timeit( replace1, "Replace1", 10000 ); -} - diff --git a/src/tests/tcpsocket.cpp b/src/tests/tcpsocket.cpp deleted file mode 100644 index 89c015c..0000000 --- a/src/tests/tcpsocket.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include - -#include -#include - -using namespace Bu; - -bool isUp() -{ - try - { - TcpSocket s("xagasoft.com", 9898, 1 ); - - char buf[5]; - buf[s.read(buf, 2, 1, 0)] = '\0'; - - if( !strcmp( buf, "hi" ) ) - return true; - else - return false; - } - catch(...) - { - return false; - } -} - -int main() -{ - uint32_t uUp = 0; - uint32_t uDown = 0; - uint32_t uTotal = 0; - struct timeval tv; - - for(;;) - { - gettimeofday( &tv, NULL ); - time_t goal = ((tv.tv_sec/5)+1)*5; - tv.tv_sec = goal-tv.tv_sec; - tv.tv_usec = 0-tv.tv_usec; - if( tv.tv_usec < 0 ) - { - tv.tv_sec--; - tv.tv_usec = 1000000+tv.tv_usec; - } - select( 0, NULL, NULL, NULL, &tv ); - gettimeofday( &tv, NULL ); - if( isUp() ) - { - uUp++; - sio << "status: up "; - } - else - { - uDown++; - sio << "status: down "; - } - uTotal++; - - sio << "(up=" << (uUp*5) << "s, down=" << (uDown*5) << ") up for " - << uUp*100/uTotal << "% of " << uTotal*5 << "s" << sio.nl - << sio.flush; - } -} - diff --git a/src/tests/telnetsrv.cpp b/src/tests/telnetsrv.cpp deleted file mode 100644 index aac6b39..0000000 --- a/src/tests/telnetsrv.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/server.h" -#include "bu/protocoltelnet.h" -#include "bu/client.h" - -class MyTelnet : public Bu::ProtocolTelnet -{ -public: - MyTelnet() - { - } - - virtual ~MyTelnet() - { - } - - virtual void onNewConnection( Bu::Client *pClient ) - { - Bu::ProtocolTelnet::onNewConnection( pClient ); - - //oNAWS.remoteSet(); - oEcho.localSet(); - oSuppressGA.remoteSet( true ); - oSuppressGA.localSet( true ); - setCanonical(); - } - - virtual void onSubNAWS( uint16_t iWidth, uint16_t iHeight ) - { - printf("New dim = (%dx%d)\n", iWidth, iHeight ); - } - - virtual void gotLine( Bu::String &sLine ) - { - printf("Line: \"%s\"\n", sLine.getStr() ); - write("\n\r", 2 ); - } - -private: - -}; - -class TelServer : public Bu::Server -{ -public: - TelServer() - { - } - - virtual ~TelServer() - { - } - - virtual void onNewConnection( Bu::Client *pClient, int ) - { - printf("New connection.\n"); - - pClient->setProtocol( new MyTelnet() ); - } - - virtual void onClosedConnection( Bu::Client *pClient ) - { - printf("Lost connection.\n"); - - delete pClient->getProtocol(); - } - -private: - -}; - -int main() -{ - TelServer ts; - - ts.addPort( 4000 ); - ts.setTimeout( 0, 5000 ); - - printf("Initializing server on port: 4000\n"); - - for(;;) - { - ts.scan(); - } -} - diff --git a/src/tests/tracer.cpp b/src/tests/tracer.cpp deleted file mode 100644 index 703fa1a..0000000 --- a/src/tests/tracer.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - - -#define BU_TRACE -#include "bu/trace.h" - -void doThing3( int x, const char *bob, void *p ) -{ - TRACE( x, bob, p ); -} - -void doThing2( int x, const char *bob ) -{ - TRACE( x, bob ); -} - -void doThing( int8_t x ) -{ - TRACE( x ); -} - -int main( int argc, char *argv[] ) -{ - TRACE( argc, argv ); - doThing( 54 ); - doThing2( 128, "Hello" ); - doThing3( 266, "Goodbye", argv ); - - return 0; -} - diff --git a/src/tests/udpsocket.cpp b/src/tests/udpsocket.cpp deleted file mode 100644 index 2a74acf..0000000 --- a/src/tests/udpsocket.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/udpsocket.h" -#include "bu/sio.h" - -#include -#include -#include -#include -#include - -using namespace Bu; - -int main( int argc, char *argv[] ) -{ - sio << Fmt::hex(8) << INADDR_ANY << sio.nl << Fmt::hex(8) << inet_addr("0.0.0.0") << sio.nl; - if( argc == 1 ) - { - sio << "Options are 'l' for listening and 'b' for broadcasting." - << sio.nl; - } - else if( argv[1][0] == 'l' ) - { - sio << "Listening..." << sio.nl; - Bu::UdpSocket udp( "0.0.0.0", 6688, UdpSocket::Read|UdpSocket::Broadcast ); - - for(;;) - { - char buf[1501]; - int iRead = udp.read( buf, 1500 ); - if( iRead >= 0 ) - { - buf[iRead] = '\0'; - sio << "Read(" << iRead << "): '" << buf << "'" << sio.nl; - } - else - { - sio << "Got " << iRead << ": " << strerror( errno ) << sio.nl; - } - } - } - else if( argv[1][0] == 'L' ) - { - sio << "Listening..." << sio.nl; - Bu::UdpSocket udp( "0.0.0.0", 6688, UdpSocket::Read|UdpSocket::Broadcast ); - - for(;;) - { - char buf[1501]; - Bu::UdpSocket::addr aHost; - int iPort; - int iRead = udp.read( buf, 1500, aHost, iPort ); - if( iRead >= 0 ) - { - buf[iRead] = '\0'; - sio << "Read(" << iRead << ") from " << Bu::UdpSocket::addrToStr( aHost ) << ":" << iPort << ": '" << buf << "'" << sio.nl; - } - } - } - else if( argv[1][0] == 'b' ) - { - sio << "Broadcasting..." << sio.nl; - Bu::UdpSocket udp("255.255.255.255", 6688, - UdpSocket::Write|UdpSocket::Broadcast ); - - for(;;) - { - int iWrote = udp.write("hello", 5 ); - sio << "Wrote(" << iWrote << "): " << strerror( errno ) << sio.nl; - usleep( 250000 ); - } - } - else - { - sio << "Options are 'l' for listening and 'b' for broadcasting." - << sio.nl; - } - - return 0; -} - diff --git a/src/tests/url.cpp b/src/tests/url.cpp deleted file mode 100644 index a381cbe..0000000 --- a/src/tests/url.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/url.h" - -#include - -int main( int argc, char *argv[] ) -{ - for( argc--, argv++; argc >= 0; argc--, argv++ ) - { - printf("encodede: %s\n", Bu::Url::encode( *argv ).getStr() ); - printf("decodede: %s\n", Bu::Url::decode( *argv ).getStr() ); - Bu::Url u( *argv ); - - 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; -} diff --git a/src/tests/variant.cpp b/src/tests/variant.cpp deleted file mode 100644 index 68dec4f..0000000 --- a/src/tests/variant.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include -#include -#include - -using namespace Bu; - -Variant getThing( int i ) -{ - Variant v; - switch( i ) - { - case 0: - v = 45; - break; - - case 1: - v = true; - break; - - case 2: - v = List(5).append(10).append(15); - break; - } - - return v; -} - -int main() -{ - Variant a; - Variant b; - Variant c; - - a = getThing( 0 ); - b = getThing( 1 ); - c = getThing( 2 ); - - sio << "a = " << a << " or " << (int)a << sio.nl - << "b = " << b << " or " << b.toString() << sio.nl - << "c = " << c << " or " << c.toString() << sio.nl - << sio.nl; - - return 0; -} - diff --git a/src/unit/string.unit b/src/unit/string.unit index 4911597..5298f8a 100644 --- a/src/unit/string.unit +++ b/src/unit/string.unit @@ -174,7 +174,7 @@ suite String unitTest( a == b ); } - test iterator2 + test iteratorCompare1 { Bu::String a("This is a test."); Bu::String b("--This is a test."); @@ -185,9 +185,12 @@ suite String bi++; bi++; unitTest( ai.compare( bi ) == true ); unitTest( bi.compare( ai ) == true ); + b += "hi"; + unitTest( ai.compare( bi ) == false ); + unitTest( bi.compare( ai ) == false ); } - test iterator3 + test iteratorCompare2 { Bu::String a("1234honour"); Bu::String b("--1234ueje"); @@ -200,19 +203,33 @@ suite String unitTest( bi.compare( ai, 4 ) == true ); unitTest( ai.compare( bi, 5 ) == false ); unitTest( bi.compare( ai, 5 ) == false ); - + + a = "fell"; + b = "-felloo"; + ai = a.begin(); + bi = b.begin()+1; + unitTest( ai.compare( bi, 4 ) == true ); + ai++; + bi++; + unitTest( ai.compare( bi, 4 ) == false ); } - test iterator4 + test iteratorCompare3 { Bu::String a("1234aoeu"); Bu::String::iterator ai = a.begin(); unitTest( ai.compare("1234") == false ); unitTest( ai.compare("1234aoeu") == true ); unitTest( ai.compare("1234aoeuee") == false ); + ai += 4; + unitTest( ai.compare("aoeu") == true ); + unitTest( ai.compare("aoeubo") == false ); + unitTest( ai.compare("aoe") == false ); + unitTest( ai.compare("wrong") == false ); + unitTest( ai.compare("boeu") == false ); } - test iterator5 + test iteratorCompare4 { Bu::String a("1234aoeu"); Bu::String::iterator ai = a.begin(); @@ -221,7 +238,119 @@ suite String unitTest( ai.compare("1234aoeuee", 10) == false ); } - test iterator6 + test iteratorCompare5 + { + Bu::String a("1234aoeu"); + Bu::String b("34ao"); + Bu::String::iterator ai = a.begin(); + unitTest( ai.compare( b ) == false ); + ai += 2; + unitTest( ai.compare( b ) == false ); + b = "oeu"; + ai += 3; + unitTest( ai.compare( b ) == true ); + b += "boo"; + unitTest( ai.compare( b ) == false ); + } + + test iteratorCompare6 + { + Bu::String a("1234aoeu"); + Bu::String::iterator ai = a.begin(); + unitTest( ai.compare( Bu::String("1234"), 4) == true ); + unitTest( ai.compare( Bu::String("1234aoeu"), 8) == true ); + unitTest( ai.compare( Bu::String("1234aoeuee"), 10) == false ); + } + + test const_iteratorCompare1 + { + Bu::String a("This is a test."); + Bu::String b("--This is a test."); + Bu::String::const_iterator ai = a.begin(); + Bu::String::const_iterator bi = b.begin(); + unitTest( ai.compare( bi ) == false ); + unitTest( bi.compare( ai ) == false ); + bi++; bi++; + unitTest( ai.compare( bi ) == true ); + unitTest( bi.compare( ai ) == true ); + b += "hi"; + unitTest( ai.compare( bi ) == false ); + unitTest( bi.compare( ai ) == false ); + } + + test const_iteratorCompare2 + { + Bu::String a("1234honour"); + Bu::String b("--1234ueje"); + Bu::String::const_iterator ai = a.begin(); + Bu::String::const_iterator bi = b.begin(); + unitTest( ai.compare( bi, 4 ) == false ); + unitTest( bi.compare( ai, 4 ) == false ); + bi++; bi++; + unitTest( ai.compare( bi, 4 ) == true ); + unitTest( bi.compare( ai, 4 ) == true ); + unitTest( ai.compare( bi, 5 ) == false ); + unitTest( bi.compare( ai, 5 ) == false ); + + a = "fell"; + b = "-felloo"; + ai = a.begin(); + bi = b.begin()+1; + unitTest( ai.compare( bi, 4 ) == true ); + ai++; + bi++; + unitTest( ai.compare( bi, 4 ) == false ); + } + + test const_iteratorCompare3 + { + Bu::String a("1234aoeu"); + Bu::String::const_iterator ai = a.begin(); + unitTest( ai.compare("1234") == false ); + unitTest( ai.compare("1234aoeu") == true ); + unitTest( ai.compare("1234aoeuee") == false ); + ai += 4; + unitTest( ai.compare("aoeu") == true ); + unitTest( ai.compare("aoeubo") == false ); + unitTest( ai.compare("aoe") == false ); + unitTest( ai.compare("wrong") == false ); + unitTest( ai.compare("boeu") == false ); + } + + test const_iteratorCompare4 + { + Bu::String a("1234aoeu"); + Bu::String::const_iterator ai = a.begin(); + unitTest( ai.compare("1234", 4) == true ); + unitTest( ai.compare("1234aoeu", 8) == true ); + unitTest( ai.compare("1234aoeuee", 10) == false ); + } + + test const_iteratorCompare5 + { + Bu::String a("1234aoeu"); + Bu::String b("34ao"); + Bu::String::const_iterator ai = a.begin(); + unitTest( ai.compare( b ) == false ); + ai += 2; + unitTest( ai.compare( b ) == false ); + b = "oeu"; + ai += 3; + unitTest( ai.compare( b ) == true ); + b += "boo"; + unitTest( ai.compare( b ) == false ); + } + + test const_iteratorCompare6 + { + Bu::String a("1234aoeu"); + Bu::String::const_iterator ai = a.begin(); + unitTest( ai.compare( Bu::String("1234"), 4) == true ); + unitTest( ai.compare( Bu::String("1234aoeu"), 8) == true ); + unitTest( ai.compare( Bu::String("1234aoeuee"), 10) == false ); + } + + test iteratorAppend1 { Bu::String a("just ->this part"); Bu::String b; @@ -247,7 +376,7 @@ suite String unitTest( c == b ); } - test iterator7 + test iteratorAppend2 { Bu::String a("just [this] part"); Bu::String b; @@ -428,6 +557,22 @@ suite String unitTest( s1.toLower() == "hello there, how are you doing?" ); unitTest( s1 == "HeLlO ThErE, HoW ArE YoU DoInG?" ); } + + test trimWhitespace1 + { + unitTest( Bu::String("Hello there").trimWhitespace() + == "Hello there" ); + unitTest( Bu::String(" \t\r\r\nHello there").trimWhitespace() + == "Hello there" ); + unitTest( Bu::String("Hello there \r\n\n\t\t ").trimWhitespace() + == "Hello there" ); + unitTest( Bu::String(" \tHello there\r\n \t").trimWhitespace() + == "Hello there" ); + unitTest( Bu::String(" \t\t\r\n").trimWhitespace() == "" ); + unitTest( Bu::String().trimWhitespace() == "" ); + unitTest( Bu::String(" \tHello \t\t\r\nthere\r\n \t").trimWhitespace() + == "Hello \t\t\r\nthere" ); + } } // 03F09CA4F58AC8CA0E80F0D9D409D0A60700A192270004BC3A99E91D0001034F544603362E35013103313130019CA4F58AC8CA0E0002830800002C4200008AC200EBF7D9D4090127BB010000E3 // diff --git a/test.taf b/test.taf index cc45a4b..5bd8c48 100644 --- a/test.taf +++ b/test.taf @@ -1,6 +1,1377 @@ -{"test": - {repo: - url = "http://svn.xagasoft.com/libbu++" - name = libbu++ - } +{"newVTR": + //FONT DEFINITIONS + "basefontsize"="6pt" + {"font": + "name"="form_info" + "face"="Times New Roman" + "face"="Times" + "face"="serif" + "size"="{=basefontsize}" + } + {"font": + "name"="big_form_info" + "face"="Times New Roman" + "face"="Times" + "face"="serif" + "size"="{=basefontsize}+2pt" + "style"="bold" + } + {"font": + "name"="main_title" + "face"="Times New Roman" + "face"="Times" + "face"="serif" + "size"="{=basefontsize}+3.5pt" + "style"="bold" + } + {"font": + "name"="plain_title" + "face"="Times New Roman" + "face"="Times" + "face"="serif" + "size"="{=basefontsize}+3.5pt" + } + {"font": + "name"="italic_title" + "face"="Times New Roman" + "face"="Times" + "face"="serif" + "size"="{=basefontsize}+2pt" + "style"="italic" + } + {"font": + "name"="small_title" + "face"="Times New Roman" + "face"="Times" + "face"="serif" + "size"="{=basefontsize}-2pt" + } + {"font": + "name"="main_font" + "face"="Times New Roman" + "face"="Times" + "face"="serif" + "size"="{=basefontsize}" + "style"="bold" + } + {"font": + "name"="main_font_plain" + "face"="Times New Roman" + "face"="Times" + "face"="serif" + "size"="{=basefontsize}" + } + {"font": + "name"="big_font_bold" + "face"="Times New Roman" + "face"="Times" + "face"="serif" + "size"="{=basefontsize}+3.5pt" + "style"="bold" + } + {"font": + "name"="fill_in" + "face"="Courier New" + "face"="monospace" + "size"="{=basefontsize}+4pt" + "style"="bold" + } + {"font": + "name"="fill_in_med" + "face"="Courier New" + "face"="monospace" + "size"="{=basefontsize}+1pt" + "style"="bold" + } + {"font": + "name"="fill_in_sm" + "face"="Courier New" + "face"="monospace" + "size"="{=basefontsize}-0pt" + "style"="bold" + } + //DEFAULTS + {"default": + {"text": + "font"="main_font" + "alignment"="top" + } + } + //THE ACTUAL PAGE + {"page": + "name"="vtr_page" + "width"="8.5in" + "height"="11in" + "padding-left"=".3125in" + "padding-right"=".25in" + "padding-top"=".125in" + "padding-bottom"=".125in" + //FORM TITLE + {"box": + "name"="doc_header" + "width"="100%" + "height"=".3in" + {"text": + "string"="FISHING VESSEL TRIP REPORT" + "top"=".06in" + "font"="main_title" + "left"="2.8in" + } + } + //DID NOT FISH BOX + {"box": + "name"="did_not_fish" + "top"="doc_header::bottom" + "width"="3.2in" + "height"=".85in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="5pt" + "left"="1in" + "string"="DID NOT FISH" + "font"="plain_title" + } + {"box": + "name"="dnf_start" + "top"=".3in" + "width"="1.6in" + {"text": + "string"="Start Date" + "left"=".6in" + } + {"text": + "top"="14pt" + "left"=".35in" + "string"="______/______/______" + } + {"text": + "top"="24pt" + "left"=".35in" + "string"=" MM DD YY" + } + } + {"box": + "left"="dnf_start::right" + "top"=".3in" + {"text": + "string"="End Date" + "left"=".6in" + } + {"text": + "top"="14pt" + "left"=".35in" + "string"="______/______/______" + } + {"text": + "top"="24pt" + "left"=".35in" + "string"=" MM DD YY" + } + } + } + //FORM INFO (NUMBERS AND PERMIT, ETC) + {"box": + "name"="form_info" + "top"="doc_header::bottom" + "left"="did_not_fish::right" + "height"=".85in" + {"text": + "string"="NOAA Form No. 88-30" + "left"="3.6in" + "font"="form_info" + } + {"text": + "string"="OMB No. 0648-0212" + "top"="10pt" + "left"="3.71in" + "font"="form_info" + } + {"text": + "string"="Expires 1/31/2013" + "top"="20pt" + "left"="3.83in" + "font"="form_info" + } + {"text": + "top"=".6in" + "left"=".2in" + "src"="page_num" + "font"="main_title" + } + {"box": + "name"="permit" + "top"=".4in" + "left"="1.6in" + "width"="1in" + {"text": + "top"="5pt" + "string"="__________" + "font"="big_font_bold" + } + {"text": + "top"="19pt" + "string"=" PERMIT" + "font"="big_form_info" + } + //VESSEL PERMIT + {"text": + "top"="4pt" + "string"="FIXME" + "font"="fill_in" + "src"="rpt_permit" + } + } + {"box": + "name"="permit_year" + "top"=".4in" + "left"="permit::right" + "width"=".5in" + {"text": + "top"="5pt" + "string"="____" + "font"="big_font_bold" + } + {"text": + "top"="19pt" + "string"=" YY" + "font"="big_form_info" + } + //YEAR + {"text": + "top"="4pt" + "string"="FIXME" + "font"="fill_in" + "src"="rpt_year" + } + } + {"box": + "name"="permit_month" + "top"=".4in" + "left"="permit_year::right" + "width"=".5in" + {"text": + "top"="5pt" + "string"="____" + "font"="big_font_bold" + } + {"text": + "top"="19pt" + "string"=" MM" + "font"="big_form_info" + } + //MONTH + {"text": + "top"="4pt" + "string"="FIXME" + "font"="fill_in" + "src"="rpt_month" + } + } + {"box": + "name"="permit_day" + "top"=".4in" + "left"="permit_month::right" + "width"=".5in" + {"text": + "top"="5pt" + "string"="____" + "font"="big_font_bold" + } + {"text": + "top"="19pt" + "string"=" DD" + "font"="big_form_info" + } + //DAY + {"text": + "top"="4pt" + "string"="FIXME" + "font"="fill_in" + "src"="rpt_day" + } + } + {"box": + "name"="permit_hour" + "top"=".4in" + "left"="permit_day::right" + "width"=".5in" + {"text": + "top"="5pt" + "string"="____" + "font"="big_font_bold" + } + {"text": + "top"="19pt" + "string"=" HH" + "font"="big_form_info" + } + //HOUR + {"text": + "top"="4pt" + "string"="FIXME" + "font"="fill_in" + "src"="rpt_hour" + } + } + } + //HEADER LINE ONE + {"box": + "src"="trip_info" + "name"="header_line_1" + "top"="form_info::bottom+.2in" + "height"=".55in" + {"box": + "name"="vessel_name" + "width"="3in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="1. Vessel Name" + } + //VESSEL NAME + {"text": + "top"="16pt" + "left"=".2in" + "src"="vessel_name" + "font"="fill_in" + } + } + {"box": + "name"="doc_reg" + "left"="vessel_name::right" + "width"="2.5in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="2. USCG Documentation or State Registration" + } + //DOC REG + {"text": + "top"="16pt" + "left"=".2in" + "src"="doc_reg" + "font"="fill_in" + } + } + {"box": + "name"="permit" + "left"="doc_reg::right" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="3. NMFS Vessel Permit Number" + } + //VESSEL PERMIT + {"text": + "top"="16pt" + "left"=".2in" + "src"="vessel_permit" + "font"="fill_in" + } + } + } + //HEADER LINE TWO + {"box": + "name"="header_line_2" + "top"="header_line_1::bottom" + "height"=".65in" + {"box": + "name"="date_sailed" + "width"="4in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="4. Date and Time Sailed" + } + {"text": + "top"=".36in" + "left"="5pt" + "string"="Date: ________/________/________" + "font"="main_font_plain" + } + //SAILED MM + {"text": + "top"=".28in" + "left"=".4in" + "string"="FIXME" + "font"="fill_in" + "src"="sailed_month" + } + //SAILED DD + {"text": + "top"=".28in" + "left"=".9in" + "string"="FIXME" + "font"="fill_in" + "src"="sailed_day" + } + //SAILED YY + {"text": + "top"=".28in" + "left"="1.4in" + "string"="FIXME" + "font"="fill_in" + "src"="sailed_year" + } + {"text": + "top"=".38in+8pt" + "left"="5pt+.4in" + "string"="MM DD YY" + "font"="main_font_plain" + } + {"text": + "top"=".36in" + "left"="2in+5pt" + "string"="Military Time: ________ : ________" + "font"="main_font_plain" + } + //SAILED TIME HH + {"text": + "top"=".28in" + "left"="2.9in" + "string"="FIXME" + "font"="fill_in" + "src"="sailed_hour" + } + //SAILED TIME MM + {"text": + "top"=".28in" + "left"="3.4in" + "string"="FIXME" + "font"="fill_in" + "src"="sailed_min" + } + {"text": + "top"=".38in+8pt" + "left"="2.4in+7pt+.4in" + "string"="HH MM" + "font"="main_font_plain" + } + } + {"box": + "name"="date_landed" + "left"="date_sailed::right" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="5. Date and Time Landed" + } + {"text": + "top"=".36in" + "left"="5pt" + "string"="Date: ________/________/________" + "font"="main_font_plain" + } + //LANDED MM + {"text": + "top"=".28in" + "left"=".4in" + "string"="FIXME" + "font"="fill_in" + "src"="landed_month" + } + //LANDED DD + {"text": + "top"=".28in" + "left"=".9in" + "string"="FIXME" + "font"="fill_in" + "src"="landed_day" + } + //LANDED YY + {"text": + "top"=".28in" + "left"="1.4in" + "string"="FIXME" + "font"="fill_in" + "src"="landed_year" + } + {"text": + "top"=".38in+8pt" + "left"="5pt+.4in" + "string"="MM DD YY" + "font"="main_font_plain" + } + {"text": + "top"=".36in" + "left"="2in+5pt" + "string"="Military Time: ________ : ________" + "font"="main_font_plain" + } + //LANDED TIME HH + {"text": + "top"=".28in" + "left"="2.9in" + "string"="FIXME" + "font"="fill_in" + "src"="landed_hour" + } + //LANDED TIME MM + {"text": + "top"=".28in" + "left"="3.4in" + "string"="FIXME" + "font"="fill_in" + "src"="landed_min" + } + {"text": + "top"=".38in+8pt" + "left"="2.4in+7pt+.4in" + "string"="HH MM" + "font"="main_font_plain" + } + } + } + //HEADER LINE THREE + {"box": + "src"="trip_info" + "name"="header_line_3" + "top"="header_line_2::bottom" + "height"=".65in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="6. Trip Type - check one box and record the number of crew including the captain. Party/Charter must also include the number of anglers." + } + //COMERCIAL + {"box": + "name"="commercial" + "top"="14pt" + "left"="7pt" + "width"="2.2in" + {"box": + "name"="commercial_check" + "top"=".12in" + "height"=".2in" + "width"=".3in" + "thickness"="1pt" + "style"="solid" + //COMM CHECK + {"text": + "top"="1pt" + "left"=".1in" + "src"="tt_commercial" + "font"="fill_in" + } + } + {"text": + "top"="commercial_check::top+2pt" + "left"="commercial_check::right+2pt" + "string"="Commercial: # of Crew ________" + "font"="main_font_plain" + } + //COMM CrewNum + {"text": + "top"="commercial_check::top-3pt" + "left"="commercial_check::right+1.2in" + "src"="crew_no" + "font"="fill_in" + } + } + //RSAEFP + {"box": + "name"="rsaefp" + "top"="14pt" + "left"="commercial::right" + "width"="2.1in" + {"box": + "name"="rsaefp_check" + "top"=".12in" + "height"=".2in" + "width"=".3in" + "thickness"="1pt" + "style"="solid" + //rsaefp CHECK + {"text": + "top"="1pt" + "left"=".1in" + "string"="" + "font"="fill_in" + } + } + {"text": + "top"="rsaefp_check::top+2pt" + "left"="rsaefp_check::right+2pt" + "string"="RSA/EFP: # of Crew ________" + "font"="main_font_plain" + } + //RSAEFP CrewNum + {"text": + "top"="rsaefp_check::top-3pt" + "left"="rsaefp_check::right+1.1in" + "string"="" + // src="crew_no" + "font"="fill_in" + } + } + //PARTY + {"box": + "name"="party" + "top"="14pt" + "left"="rsaefp::right" + "width"="1.8in" + {"box": + "name"="party_check" + "top"=".12in" + "height"=".2in" + "width"=".3in" + "thickness"="1pt" + "style"="solid" + //party CHECK + {"text": + "top"="1pt" + "left"=".1in" + "src"="tt_party" + "font"="fill_in" + } + } + {"text": + "top"="party_check::top+2pt" + "left"="party_check::right+2pt" + "string"="Party:" + "font"="main_font_plain" + } + {"text": + "top"="5pt" + "left"="party_check::right+.3in" + "string"="# of Crew ______" + "font"="main_font_plain" + } + //Party CrewNum + {"text": + "top"="-1pt" + "left"="party_check::right+.9in" + "string"="" + // src="crew_no" + "font"="fill_in" + } + {"text": + "top"=".25in" + "left"="party_check::right+.3in" + "string"="# of Anglers ______" + "font"="main_font_plain" + } + //Party Anglers + {"text": + "top"=".24in-3pt" + "left"="party_check::right+.9in" + "string"="" + // src="angler_no" + "font"="fill_in" + } + } + //CHARTER + {"box": + "name"="charter" + "top"="14pt" + "left"="party::right" + //width=2.2in + {"box": + "name"="charter_check" + "top"=".12in" + "height"=".2in" + "width"=".3in" + "thickness"="1pt" + "style"="solid" + //charter CHECK + {"text": + "top"="1pt" + "left"=".1in" + "src"="tt_charter" + "font"="fill_in" + } + } + {"text": + "top"="charter_check::top+2pt" + "left"="charter_check::right+2pt" + "string"="Charter:" + "font"="main_font_plain" + } + {"text": + "top"="5pt" + "left"="charter_check::right+.3in" + "string"="# of Crew ______" + "font"="main_font_plain" + } + //Party CrewNum + {"text": + "top"="-1pt" + "left"="charter_check::right+.9in" + "string"="" + // src="crew_no" + "font"="fill_in" + } + {"text": + "top"=".25in" + "left"="charter_check::right+.3in" + "string"="# of Anglers ______" + "font"="main_font_plain" + } + //Party Anglers + {"text": + "top"=".24in-3pt" + "left"="charter_check::right+.9in" + "string"="" + // src="angler_no" + "font"="fill_in" + } + } + } + //INSTRUCTIONS + {"box": + "name"="instructions" + "top"="header_line_3::bottom" + "height"=".5in" + {"text": + "top"=".15in" + "left"=".1in" + "string"="COMPLETE A NEW FORM FOR EACH DIFFERENT CHART AREA, GEAR TYPE OR MESH/RING SIZE USED ON A TRIP." + "font"="italic_title" + } + } + //DATA_LINE_1 + {"box": + "src"="setup_info" + "name"="data_line_1" + "top"="instructions::bottom" + "height"=".55in" + {"box": + "name"="gear_code" + "width"="1.3in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="7. Gear Code" + } + //GEAR CODE + {"text": + "top"="16pt" + "left"=".2in" + "src"="gear" + "font"="fill_in" + } + } + {"box": + "name"="meshring_size" + "left"="gear_code::right" + "width"="1.25in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="8. Mesh/Ring Size" + } + //MESHRING SIZE + {"text": + "top"="16pt" + "left"=".2in" + "src"="mesh_ring_size" + "font"="fill_in" + } + } + {"box": + "name"="quantity" + "left"="meshring_size::right" + "width"="1.25in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="9. Gear Quantity" + } + //GEAR QUANTITY + {"text": + "top"="16pt" + "left"=".2in" + "src"="gear_num" + "font"="fill_in" + } + } + {"box": + "name"="size" + "left"="quantity::right" + "width"="1.25in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="10. Gear Size" + } + //GEAR SIZE + {"text": + "top"="16pt" + "left"=".2in" + "src"="gear_size" + "font"="fill_in" + } + } + {"box": + "name"="depth" + "left"="size::right" + "width"="1.5in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="11. Fishing Depth (Fathoms)" + } + //FISHING DEPTH + {"text": + "top"="16pt" + "left"=".2in" + "src"="depth" + "font"="fill_in" + } + } + {"box": + "name"="hauls" + "left"="depth::right" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="12. Number of Hauls" + } + //HAUL NO + {"text": + "top"="16pt" + "left"=".2in" + "src"="haul_no" + "font"="fill_in" + } + } + } + //DATA_LINE_2 + {"box": + "src"="setup_info" + "name"="data_line_2" + "top"="data_line_1::bottom" + "height"=".55in" + {"box": + "name"="chart_area" + "width"="1.2in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="13. Chart Area" + } + //CHART AREA + {"text": + "top"="16pt" + "left"=".2in" + "src"="chart_area" + "font"="fill_in" + } + } + {"box": + "name"="latitude" + "left"="chart_area::right" + "width"="2.2in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="14. Latitude" + } + {"text": + "top"=".25in" + "left"=".4in" + "string"="_____________:_____________" + "font"="main_font_plain" + } + //LAT DEG + {"text": + "top"="12pt" + "left"=".6in" + "string"="FIXME" + "font"="fill_in" + "src"="lat_hour" + } + //LAT MIN + {"text": + "top"="12pt" + "left"="1.4in" + "string"="FIXME" + "font"="fill_in" + "src"="lat_min" + } + {"text": + "top"=".25in+10pt" + "left"=".5in" + "string"="DEGREES MINUTES" + "font"="main_font_plain" + } + } + {"box": + "name"="longitude" + "left"="latitude::right" + "width"="2.2in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="15. Longitude" + } + {"text": + "top"=".25in" + "left"=".4in" + "string"="_____________:_____________" + "font"="main_font_plain" + } + //LON DEG + {"text": + "top"="12pt" + "left"=".6in" + "string"="FIXME" + "font"="fill_in" + "src"="lon_hour" + } + //LON MIN + {"text": + "top"="12pt" + "left"="1.4in" + "string"="FIXME" + "font"="fill_in" + "src"="lon_min" + } + {"text": + "top"=".25in+10pt" + "left"=".5in" + "string"="DEGREES MINUTES" + "font"="main_font_plain" + } + } + {"box": + "name"="towsoak_time" + "left"="longitude::right" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="16. Tow / Soak Time" + } + {"text": + "top"=".25in" + "left"=".4in" + "string"="_____________:_____________" + "font"="main_font_plain" + } + //SOAK HR + {"text": + "top"="12pt" + "left"=".6in" + "src"="tow_soak_time_hrs" + "font"="fill_in" + } + //SOAK MIN + {"text": + "top"="12pt" + "left"="1.4in" + "src"="tow_soak_time_mins" + "font"="fill_in" + } + {"text": + "top"=".25in+10pt" + "left"=".5in" + "string"="HOURS MINUTES" + "font"="main_font_plain" + } + } + } + //DATA_LINE_3 + {"box": + "name"="data_line_3" + "top"="data_line_2::bottom" + "height"=".4in" + {"box": + "name"="species" + "width"=".9in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"=".45in" + "string"="17." + } + {"text": + "top"="11pt" + "left"="15pt" + "string"="Species Code" + } + } + {"box": + "name"="kept" + "left"="species::right" + "width"=".9in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"=".45in" + "string"="18." + } + {"text": + "top"="11pt" + "left"=".3in" + "string"="Kept" + } + } + {"box": + "name"="discarded" + "left"="kept::right" + "width"=".9in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="19. Discarded" + } + } + {"box": + "name"="dealer_permit" + "left"="discarded::right" + "width"=".7in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="8pt" + "string"="20. Dealer" + } + {"text": + "top"="10pt" + "left"="12pt" + "string"="Permit" + } + {"text": + "top"="18pt" + "left"="10pt" + "string"="Number" + } + } + {"box": + "name"="dealer_name" + "left"="dealer_permit::right" + "width"="1.8in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"=".7in" + "string"="21." + } + {"text": + "top"="11pt" + "left"=".5in" + "string"="Dealer Name" + } + } + {"box": + "name"="date_sold" + "left"="dealer_name::right" + "width"=".75in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"=".3in" + "string"="22." + } + {"text": + "top"="10pt" + "left"="10pt" + "string"="Date Sold" + } + {"text": + "top"="18pt" + "left"="7pt" + "string"="MM/DD/YY" + } + } + {"box": + "name"="offload_port" + "left"="date_sold::right" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="1pt" + "left"="5pt" + "string"="23. Offloading Port for each species" + } + {"line": + "top"="11pt" + "bottom"="11pt" + "thickness"="1pt" + "style"="solid" + } + {"text": + "top"="12pt" + "left"=".6in" + "string"="City" + } + {"line": + "top"="11pt" + "left"="1.5in" + "right"="1.5in" + } + {"text": + "top"="12pt" + "left"="1.6in" + "string"="State" + } + } + } + //DATA_GRID + {"box": + "name"="data_grid" + "top"="data_line_3::bottom" + "height"="4.25in" + "src"="setup_info" + {"box": + "src"="catch_data" + "repeat"="tile-ttb-ltr" + "height"=".3in" + {"box": + "name"="data_species" + "width"=".9in" + "thickness"="1pt" + "style"="solid" + //SPECIES + {"text": + "top"="2pt" + "left"=".1in" + "src"="species_code" + "font"="fill_in" + } + } + {"box": + "name"="data_kept" + "left"="data_species::right" + "width"=".9in" + "thickness"="1pt" + "style"="solid" + //KEPT + {"text": + "top"="2pt" + "left"=".1in" + "src"="kept_pounds" + "font"="fill_in" + } + } + {"box": + "name"="data_discarded" + "left"="data_kept::right" + "width"=".9in" + "thickness"="1pt" + "style"="solid" + //DISC + {"text": + "top"="2pt" + "left"=".1in" + "src"="disc_pounds" + "font"="fill_in" + } + } + {"box": + "name"="data_dealer_permit" + "left"="data_discarded::right" + "width"=".7in" + "thickness"="1pt" + "style"="solid" + //DEALER_NUM + {"text": + "top"="5pt" + "left"="5pt" + "src"="dealer_no" + "font"="fill_in_med" + } + } + {"box": + "name"="data_dealer_name" + "left"="data_dealer_permit::right" + "width"="1.8in" + "thickness"="1pt" + "style"="solid" + //DEALER NAME + {"text": + "top"="1pt" + "left"="5pt" + "src"="dealer_name" + "font"="fill_in_sm" + } + } + {"box": + "name"="data_date_sold" + "left"="data_dealer_name::right" + "width"=".75in" + "thickness"="1pt" + "style"="solid" + //DATE SOLD + {"text": + "top"="5pt" + "left"="2pt" + "src"="date_sold" + "font"="fill_in_med" + } + } + {"box": + "name"="data_port_city" + "left"="data_date_sold::right" + "width"="1.5in" + "thickness"="1pt" + "style"="solid" + //PORT CITY + {"text": + "top"="5pt" + "left"="5pt" + "src"="port_city" + "font"="fill_in_med" + } + } + {"box": + "name"="data_port_state" + "left"="data_port_city::right" + "thickness"="1pt" + "style"="solid" + //PORT STATE + {"text": + "top"="2pt" + "left"=".1in" + "src"="port_state" + "font"="fill_in" + } + } + } + } + //WARNING + {"box": + "name"="warning" + "top"="data_grid::bottom" + "height"="14pt" + {"text": + "top"="2pt" + "left"=".5in" + "string"="I certify that the information provided on this form is true, complete and correct to the best of my knowledge, and made in good faith. Making a false statement on this form is punishable by law (18 U.S.C. 1001)." + "font"="small_title" + } + } + //SIGN + {"box": + "name"="sign" + "top"="warning::bottom" + "height"=".5in" + "src"="sign_info" + {"box": + "name"="op_permit" + "width"="1.8in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="24. Operator Permit Number" + } + //OP PERMIT + {"text": + "top"="16pt" + "left"=".1in" + "string"="FIXME" + "font"="fill_in" + "src"="operator_permit" + } + } + {"box": + "name"="op_name" + "left"="op_permit::right" + "width"="2.4in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="25. Operator Name" + } + //OP PERMIT + {"text": + "top"="16pt" + "left"=".1in" + "string"="FIXME" + "font"="fill_in" + "src"="operator_name" + } + } + {"box": + "name"="op_sig" + "left"="op_name::right" + "width"="2.4in" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="26. Operator Signature" + } + } + {"box": + "name"="op_date" + "left"="op_sig::right" + "thickness"="1pt" + "style"="solid" + {"text": + "top"="2pt" + "left"="5pt" + "string"="27. Date Signed" + } + {"text": + "top"="10pt" + "left"=".4in" + "string"="MM/DD/YY" + } + //DATE SIGNED + {"text": + "top"="20pt" + "left"=".1in" + "src"="sig_date" + "font"="fill_in" + } + } + } + //BOTTOM + {"box": + "name"="bottom" + "top"="sign::bottom" + {"text": + "top"=".3in" + "left"="3.5in" + "string"="NMFS COPY" + "font"="main_title" + } + } + } } -- cgit v1.2.3