diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2019-05-25 20:34:29 -0700 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2019-05-25 20:34:29 -0700 |
| commit | 3a27454dca4a16d021a4d418f0725adccc5baabb (patch) | |
| tree | 583e0865283ad29d769c6c646e227c9571c33361 /src/unit | |
| parent | c4c34c1bfe568b653399cb5349ce54b5ee1c519b (diff) | |
| download | libbu++-3a27454dca4a16d021a4d418f0725adccc5baabb.tar.gz libbu++-3a27454dca4a16d021a4d418f0725adccc5baabb.tar.bz2 libbu++-3a27454dca4a16d021a4d418f0725adccc5baabb.tar.xz libbu++-3a27454dca4a16d021a4d418f0725adccc5baabb.zip | |
Just about everything that Blob needs is in.
Diffstat (limited to 'src/unit')
| -rw-r--r-- | src/unit/blob.unit | 63 |
1 files changed, 63 insertions, 0 deletions
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 | |||
| 26 | unitTest( !strcmp( b.getData(), "New string") ); | 26 | unitTest( !strcmp( b.getData(), "New string") ); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | test empty | ||
| 30 | { | ||
| 31 | Bu::Blob n; | ||
| 32 | Bu::Blob e(""); | ||
| 33 | |||
| 34 | unitTest( n.isEmpty() == false ); | ||
| 35 | unitTest( n.isNull() == true ); | ||
| 36 | unitTest( n.isNullOrEmpty() == true ); | ||
| 37 | |||
| 38 | unitTest( e.isEmpty() == true ); | ||
| 39 | unitTest( e.isNull() == false ); | ||
| 40 | unitTest( e.isNullOrEmpty() == true ); | ||
| 41 | |||
| 42 | unitTestCatch( n[0], Bu::ExceptionIndexOutOfBounds ); | ||
| 43 | unitTestCatch( e[0], Bu::ExceptionIndexOutOfBounds ); | ||
| 44 | } | ||
| 45 | |||
| 29 | test index | 46 | test index |
| 30 | { | 47 | { |
| 31 | Bu::Blob a("hello there"); | 48 | Bu::Blob a("hello there"); |
| @@ -87,10 +104,56 @@ suite Blob | |||
| 87 | 104 | ||
| 88 | test iterator | 105 | test iterator |
| 89 | { | 106 | { |
| 107 | const char *sDat = "abcdefghijklmnopqrstuvwxyz"; | ||
| 108 | Bu::Blob bDat( sDat ); | ||
| 109 | |||
| 110 | Bu::Blob::iterator i2; | ||
| 111 | const char *sCmp = sDat; | ||
| 112 | for( Bu::Blob::iterator i = bDat.begin(); i; i++, sCmp++ ) | ||
| 113 | { | ||
| 114 | unitTest( *i == *sCmp ); | ||
| 115 | if( *i == 'k' ) | ||
| 116 | i2 = i; | ||
| 117 | } | ||
| 118 | |||
| 119 | i2++; | ||
| 120 | unitTest( *i2 == 'l' ); | ||
| 121 | unitTest( *(i2 + 3) == 'o' ); | ||
| 122 | unitTest( Bu::Blob( i2 ) == "lmnopqrstuvwxyz" ); | ||
| 123 | unitTest( Bu::Blob( i2, i2+5 ) == "lmnop" ); | ||
| 124 | |||
| 125 | sCmp--; | ||
| 126 | for( Bu::Blob::iterator i = bDat.rbegin(); i; i++, sCmp-- ) | ||
| 127 | { | ||
| 128 | unitTest( *i == *sCmp ); | ||
| 129 | } | ||
| 90 | } | 130 | } |
| 91 | 131 | ||
| 92 | test const_iterator | 132 | test const_iterator |
| 93 | { | 133 | { |
| 134 | const char *sDat = "abcdefghijklmnopqrstuvwxyz"; | ||
| 135 | Bu::Blob bDat( sDat ); | ||
| 136 | |||
| 137 | Bu::Blob::const_iterator i2; | ||
| 138 | const char *sCmp = sDat; | ||
| 139 | for( Bu::Blob::const_iterator i = bDat.begin(); i; i++, sCmp++ ) | ||
| 140 | { | ||
| 141 | unitTest( *i == *sCmp ); | ||
| 142 | if( *i == 'k' ) | ||
| 143 | i2 = i; | ||
| 144 | } | ||
| 145 | |||
| 146 | i2++; | ||
| 147 | unitTest( *i2 == 'l' ); | ||
| 148 | unitTest( *(i2 + 3) == 'o' ); | ||
| 149 | unitTest( Bu::Blob( i2 ) == "lmnopqrstuvwxyz" ); | ||
| 150 | unitTest( Bu::Blob( i2, i2+5 ) == "lmnop" ); | ||
| 151 | |||
| 152 | sCmp--; | ||
| 153 | for( Bu::Blob::const_iterator i = bDat.rbegin(); i; i++, sCmp-- ) | ||
| 154 | { | ||
| 155 | unitTest( *i == *sCmp ); | ||
| 156 | } | ||
| 94 | } | 157 | } |
| 95 | 158 | ||
| 96 | test sort | 159 | test sort |
