From 3a27454dca4a16d021a4d418f0725adccc5baabb Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 25 May 2019 20:34:29 -0700 Subject: Just about everything that Blob needs is in. --- src/unit/blob.unit | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/unit') diff --git a/src/unit/blob.unit b/src/unit/blob.unit index 645052b..6f98cfc 100644 --- a/src/unit/blob.unit +++ b/src/unit/blob.unit @@ -26,6 +26,23 @@ suite Blob unitTest( !strcmp( b.getData(), "New string") ); } + test empty + { + Bu::Blob n; + Bu::Blob e(""); + + unitTest( n.isEmpty() == false ); + unitTest( n.isNull() == true ); + unitTest( n.isNullOrEmpty() == true ); + + unitTest( e.isEmpty() == true ); + unitTest( e.isNull() == false ); + unitTest( e.isNullOrEmpty() == true ); + + unitTestCatch( n[0], Bu::ExceptionIndexOutOfBounds ); + unitTestCatch( e[0], Bu::ExceptionIndexOutOfBounds ); + } + test index { Bu::Blob a("hello there"); @@ -87,10 +104,56 @@ suite Blob test iterator { + const char *sDat = "abcdefghijklmnopqrstuvwxyz"; + Bu::Blob bDat( sDat ); + + Bu::Blob::iterator i2; + const char *sCmp = sDat; + for( Bu::Blob::iterator i = bDat.begin(); i; i++, sCmp++ ) + { + unitTest( *i == *sCmp ); + if( *i == 'k' ) + i2 = i; + } + + i2++; + unitTest( *i2 == 'l' ); + unitTest( *(i2 + 3) == 'o' ); + unitTest( Bu::Blob( i2 ) == "lmnopqrstuvwxyz" ); + unitTest( Bu::Blob( i2, i2+5 ) == "lmnop" ); + + sCmp--; + for( Bu::Blob::iterator i = bDat.rbegin(); i; i++, sCmp-- ) + { + unitTest( *i == *sCmp ); + } } test const_iterator { + const char *sDat = "abcdefghijklmnopqrstuvwxyz"; + Bu::Blob bDat( sDat ); + + Bu::Blob::const_iterator i2; + const char *sCmp = sDat; + for( Bu::Blob::const_iterator i = bDat.begin(); i; i++, sCmp++ ) + { + unitTest( *i == *sCmp ); + if( *i == 'k' ) + i2 = i; + } + + i2++; + unitTest( *i2 == 'l' ); + unitTest( *(i2 + 3) == 'o' ); + unitTest( Bu::Blob( i2 ) == "lmnopqrstuvwxyz" ); + unitTest( Bu::Blob( i2, i2+5 ) == "lmnop" ); + + sCmp--; + for( Bu::Blob::const_iterator i = bDat.rbegin(); i; i++, sCmp-- ) + { + unitTest( *i == *sCmp ); + } } test sort -- cgit v1.2.3