diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-03-30 22:33:41 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-03-30 22:33:41 +0000 |
commit | 4b9289cfb260f4bcecaf23a810584ef6ef8e8501 (patch) | |
tree | 79136af08c7e42ba3322f0d73e9779e4354b318a /src/unit | |
parent | c7636dc954eddfe58f7959392602fbc9072d77e7 (diff) | |
download | libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.gz libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.bz2 libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.xz libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.zip |
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.
Diffstat (limited to 'src/unit')
-rw-r--r-- | src/unit/string.unit | 159 |
1 files changed, 152 insertions, 7 deletions
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 | |||
174 | unitTest( a == b ); | 174 | unitTest( a == b ); |
175 | } | 175 | } |
176 | 176 | ||
177 | test iterator2 | 177 | test iteratorCompare1 |
178 | { | 178 | { |
179 | Bu::String a("This is a test."); | 179 | Bu::String a("This is a test."); |
180 | Bu::String b("--This is a test."); | 180 | Bu::String b("--This is a test."); |
@@ -185,9 +185,12 @@ suite String | |||
185 | bi++; bi++; | 185 | bi++; bi++; |
186 | unitTest( ai.compare( bi ) == true ); | 186 | unitTest( ai.compare( bi ) == true ); |
187 | unitTest( bi.compare( ai ) == true ); | 187 | unitTest( bi.compare( ai ) == true ); |
188 | b += "hi"; | ||
189 | unitTest( ai.compare( bi ) == false ); | ||
190 | unitTest( bi.compare( ai ) == false ); | ||
188 | } | 191 | } |
189 | 192 | ||
190 | test iterator3 | 193 | test iteratorCompare2 |
191 | { | 194 | { |
192 | Bu::String a("1234honour"); | 195 | Bu::String a("1234honour"); |
193 | Bu::String b("--1234ueje"); | 196 | Bu::String b("--1234ueje"); |
@@ -200,19 +203,33 @@ suite String | |||
200 | unitTest( bi.compare( ai, 4 ) == true ); | 203 | unitTest( bi.compare( ai, 4 ) == true ); |
201 | unitTest( ai.compare( bi, 5 ) == false ); | 204 | unitTest( ai.compare( bi, 5 ) == false ); |
202 | unitTest( bi.compare( ai, 5 ) == false ); | 205 | unitTest( bi.compare( ai, 5 ) == false ); |
203 | 206 | ||
207 | a = "fell"; | ||
208 | b = "-felloo"; | ||
209 | ai = a.begin(); | ||
210 | bi = b.begin()+1; | ||
211 | unitTest( ai.compare( bi, 4 ) == true ); | ||
212 | ai++; | ||
213 | bi++; | ||
214 | unitTest( ai.compare( bi, 4 ) == false ); | ||
204 | } | 215 | } |
205 | 216 | ||
206 | test iterator4 | 217 | test iteratorCompare3 |
207 | { | 218 | { |
208 | Bu::String a("1234aoeu"); | 219 | Bu::String a("1234aoeu"); |
209 | Bu::String::iterator ai = a.begin(); | 220 | Bu::String::iterator ai = a.begin(); |
210 | unitTest( ai.compare("1234") == false ); | 221 | unitTest( ai.compare("1234") == false ); |
211 | unitTest( ai.compare("1234aoeu") == true ); | 222 | unitTest( ai.compare("1234aoeu") == true ); |
212 | unitTest( ai.compare("1234aoeuee") == false ); | 223 | unitTest( ai.compare("1234aoeuee") == false ); |
224 | ai += 4; | ||
225 | unitTest( ai.compare("aoeu") == true ); | ||
226 | unitTest( ai.compare("aoeubo") == false ); | ||
227 | unitTest( ai.compare("aoe") == false ); | ||
228 | unitTest( ai.compare("wrong") == false ); | ||
229 | unitTest( ai.compare("boeu") == false ); | ||
213 | } | 230 | } |
214 | 231 | ||
215 | test iterator5 | 232 | test iteratorCompare4 |
216 | { | 233 | { |
217 | Bu::String a("1234aoeu"); | 234 | Bu::String a("1234aoeu"); |
218 | Bu::String::iterator ai = a.begin(); | 235 | Bu::String::iterator ai = a.begin(); |
@@ -221,7 +238,119 @@ suite String | |||
221 | unitTest( ai.compare("1234aoeuee", 10) == false ); | 238 | unitTest( ai.compare("1234aoeuee", 10) == false ); |
222 | } | 239 | } |
223 | 240 | ||
224 | test iterator6 | 241 | test iteratorCompare5 |
242 | { | ||
243 | Bu::String a("1234aoeu"); | ||
244 | Bu::String b("34ao"); | ||
245 | Bu::String::iterator ai = a.begin(); | ||
246 | unitTest( ai.compare( b ) == false ); | ||
247 | ai += 2; | ||
248 | unitTest( ai.compare( b ) == false ); | ||
249 | b = "oeu"; | ||
250 | ai += 3; | ||
251 | unitTest( ai.compare( b ) == true ); | ||
252 | b += "boo"; | ||
253 | unitTest( ai.compare( b ) == false ); | ||
254 | } | ||
255 | |||
256 | test iteratorCompare6 | ||
257 | { | ||
258 | Bu::String a("1234aoeu"); | ||
259 | Bu::String::iterator ai = a.begin(); | ||
260 | unitTest( ai.compare( Bu::String("1234"), 4) == true ); | ||
261 | unitTest( ai.compare( Bu::String("1234aoeu"), 8) == true ); | ||
262 | unitTest( ai.compare( Bu::String("1234aoeuee"), 10) == false ); | ||
263 | } | ||
264 | |||
265 | test const_iteratorCompare1 | ||
266 | { | ||
267 | Bu::String a("This is a test."); | ||
268 | Bu::String b("--This is a test."); | ||
269 | Bu::String::const_iterator ai = a.begin(); | ||
270 | Bu::String::const_iterator bi = b.begin(); | ||
271 | unitTest( ai.compare( bi ) == false ); | ||
272 | unitTest( bi.compare( ai ) == false ); | ||
273 | bi++; bi++; | ||
274 | unitTest( ai.compare( bi ) == true ); | ||
275 | unitTest( bi.compare( ai ) == true ); | ||
276 | b += "hi"; | ||
277 | unitTest( ai.compare( bi ) == false ); | ||
278 | unitTest( bi.compare( ai ) == false ); | ||
279 | } | ||
280 | |||
281 | test const_iteratorCompare2 | ||
282 | { | ||
283 | Bu::String a("1234honour"); | ||
284 | Bu::String b("--1234ueje"); | ||
285 | Bu::String::const_iterator ai = a.begin(); | ||
286 | Bu::String::const_iterator bi = b.begin(); | ||
287 | unitTest( ai.compare( bi, 4 ) == false ); | ||
288 | unitTest( bi.compare( ai, 4 ) == false ); | ||
289 | bi++; bi++; | ||
290 | unitTest( ai.compare( bi, 4 ) == true ); | ||
291 | unitTest( bi.compare( ai, 4 ) == true ); | ||
292 | unitTest( ai.compare( bi, 5 ) == false ); | ||
293 | unitTest( bi.compare( ai, 5 ) == false ); | ||
294 | |||
295 | a = "fell"; | ||
296 | b = "-felloo"; | ||
297 | ai = a.begin(); | ||
298 | bi = b.begin()+1; | ||
299 | unitTest( ai.compare( bi, 4 ) == true ); | ||
300 | ai++; | ||
301 | bi++; | ||
302 | unitTest( ai.compare( bi, 4 ) == false ); | ||
303 | } | ||
304 | |||
305 | test const_iteratorCompare3 | ||
306 | { | ||
307 | Bu::String a("1234aoeu"); | ||
308 | Bu::String::const_iterator ai = a.begin(); | ||
309 | unitTest( ai.compare("1234") == false ); | ||
310 | unitTest( ai.compare("1234aoeu") == true ); | ||
311 | unitTest( ai.compare("1234aoeuee") == false ); | ||
312 | ai += 4; | ||
313 | unitTest( ai.compare("aoeu") == true ); | ||
314 | unitTest( ai.compare("aoeubo") == false ); | ||
315 | unitTest( ai.compare("aoe") == false ); | ||
316 | unitTest( ai.compare("wrong") == false ); | ||
317 | unitTest( ai.compare("boeu") == false ); | ||
318 | } | ||
319 | |||
320 | test const_iteratorCompare4 | ||
321 | { | ||
322 | Bu::String a("1234aoeu"); | ||
323 | Bu::String::const_iterator ai = a.begin(); | ||
324 | unitTest( ai.compare("1234", 4) == true ); | ||
325 | unitTest( ai.compare("1234aoeu", 8) == true ); | ||
326 | unitTest( ai.compare("1234aoeuee", 10) == false ); | ||
327 | } | ||
328 | |||
329 | test const_iteratorCompare5 | ||
330 | { | ||
331 | Bu::String a("1234aoeu"); | ||
332 | Bu::String b("34ao"); | ||
333 | Bu::String::const_iterator ai = a.begin(); | ||
334 | unitTest( ai.compare( b ) == false ); | ||
335 | ai += 2; | ||
336 | unitTest( ai.compare( b ) == false ); | ||
337 | b = "oeu"; | ||
338 | ai += 3; | ||
339 | unitTest( ai.compare( b ) == true ); | ||
340 | b += "boo"; | ||
341 | unitTest( ai.compare( b ) == false ); | ||
342 | } | ||
343 | |||
344 | test const_iteratorCompare6 | ||
345 | { | ||
346 | Bu::String a("1234aoeu"); | ||
347 | Bu::String::const_iterator ai = a.begin(); | ||
348 | unitTest( ai.compare( Bu::String("1234"), 4) == true ); | ||
349 | unitTest( ai.compare( Bu::String("1234aoeu"), 8) == true ); | ||
350 | unitTest( ai.compare( Bu::String("1234aoeuee"), 10) == false ); | ||
351 | } | ||
352 | |||
353 | test iteratorAppend1 | ||
225 | { | 354 | { |
226 | Bu::String a("just ->this part"); | 355 | Bu::String a("just ->this part"); |
227 | Bu::String b; | 356 | Bu::String b; |
@@ -247,7 +376,7 @@ suite String | |||
247 | unitTest( c == b ); | 376 | unitTest( c == b ); |
248 | } | 377 | } |
249 | 378 | ||
250 | test iterator7 | 379 | test iteratorAppend2 |
251 | { | 380 | { |
252 | Bu::String a("just [this] part"); | 381 | Bu::String a("just [this] part"); |
253 | Bu::String b; | 382 | Bu::String b; |
@@ -428,6 +557,22 @@ suite String | |||
428 | unitTest( s1.toLower() == "hello there, how are you doing?" ); | 557 | unitTest( s1.toLower() == "hello there, how are you doing?" ); |
429 | unitTest( s1 == "HeLlO ThErE, HoW ArE YoU DoInG?" ); | 558 | unitTest( s1 == "HeLlO ThErE, HoW ArE YoU DoInG?" ); |
430 | } | 559 | } |
560 | |||
561 | test trimWhitespace1 | ||
562 | { | ||
563 | unitTest( Bu::String("Hello there").trimWhitespace() | ||
564 | == "Hello there" ); | ||
565 | unitTest( Bu::String(" \t\r\r\nHello there").trimWhitespace() | ||
566 | == "Hello there" ); | ||
567 | unitTest( Bu::String("Hello there \r\n\n\t\t ").trimWhitespace() | ||
568 | == "Hello there" ); | ||
569 | unitTest( Bu::String(" \tHello there\r\n \t").trimWhitespace() | ||
570 | == "Hello there" ); | ||
571 | unitTest( Bu::String(" \t\t\r\n").trimWhitespace() == "" ); | ||
572 | unitTest( Bu::String().trimWhitespace() == "" ); | ||
573 | unitTest( Bu::String(" \tHello \t\t\r\nthere\r\n \t").trimWhitespace() | ||
574 | == "Hello \t\t\r\nthere" ); | ||
575 | } | ||
431 | } | 576 | } |
432 | // 03F09CA4F58AC8CA0E80F0D9D409D0A60700A192270004BC3A99E91D0001034F544603362E35013103313130019CA4F58AC8CA0E0002830800002C4200008AC200EBF7D9D4090127BB010000E3 | 577 | // 03F09CA4F58AC8CA0E80F0D9D409D0A60700A192270004BC3A99E91D0001034F544603362E35013103313130019CA4F58AC8CA0E0002830800002C4200008AC200EBF7D9D4090127BB010000E3 |
433 | // | 578 | // |