Changeset 3996 for trunk/psLib/test/sysUtils/tst_psString.c
- Timestamp:
- May 19, 2005, 3:40:40 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/sysUtils/tst_psString.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sysUtils/tst_psString.c
r3994 r3996 1 1 /** @file tst_psString.c 2 * 3 * -*- mode: C; c-basic-indent: 4; tab-width: 8; indent-tabs-mode: nil -*- 4 * vim: set cindent ts=8 sw=4 expandtab: 2 5 * 3 6 * @brief Test driver for psString functions … … 17 20 * @author Eric Van Alst, MHPCC 18 21 * 19 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $20 * @date $Date: 2005-05-20 0 0:44:55$22 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 23 * @date $Date: 2005-05-20 01:40:40 $ 21 24 * 22 25 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 27 30 #include "pslib_strict.h" 28 31 #include "psTest.h" 32 33 #define STR_0 "binky had a leeeetle lamb" 29 34 30 35 static psS32 testStringCopy00(void); … … 35 40 static psS32 testStringCopy05(void); 36 41 static psS32 testStringCopy06(void); 42 43 static psS32 testStrAppend00(void); 44 static psS32 testStrAppend01(void); 45 static psS32 testStrAppend02(void); 46 static psS32 testStrAppend03(void); 47 48 static psS32 testStrPrepend00(void); 49 static psS32 testStrPrepend01(void); 50 static psS32 testStrPrepend02(void); 51 static psS32 testStrPrepend03(void); 37 52 38 53 testDescription tests[] = { … … 44 59 {testStringCopy05, 5, "Copy string with negative size", 0, false}, 45 60 {testStringCopy06, 6, "Verify creation of string literal", 0, false}, 61 62 {testStrAppend00, 7, "Verify generic string append", 0, false}, 63 {testStrAppend01, 8, "Test append NULL handling", 0, false}, 64 {testStrAppend02, 9, "Verify append string creation", 0, false}, 65 {testStrAppend03, 10, "Test append null-op", 0, false}, 66 67 {testStrPrepend00,11, "Verify generic string prepend", 0, false}, 68 {testStrPrepend01,12, "Test prepend NULL handling", 0, false}, 69 {testStrPrepend02,13, "Verify prepend string creation", 0, false}, 70 {testStrPrepend03,14, "Test prepend null-op", 0, false}, 46 71 {NULL} 47 72 }; … … 249 274 return 0; 250 275 } 276 277 static psS32 testStrAppend00(void) 278 { 279 char *str=NULL; 280 int result = 0; 281 282 str = psStringCopy("3.14159"); 283 284 psStringAppend(&str, "%d%s", 2653589, "79323846"); 285 286 // Test point: Verify string append 287 result = strcmp(str, "3.14159265358979323846"); 288 if ( result != 0 ) { 289 fprintf(stderr,"%s","Failed test point\n"); 290 return 1; 291 } 292 293 psFree(str); 294 295 return 0; 296 } 297 298 static psS32 testStrAppend01(void) 299 { 300 ssize_t sz; 301 char *str=NULL; 302 303 // test nonsensical invocations ... 304 sz = psStringAppend(NULL, NULL); 305 if ( sz != 0 ) { 306 fprintf(stderr,"%s","Failed test point\n"); 307 return 1; 308 } 309 sz = psStringAppend(&str, NULL); 310 if ( sz != 0 ) { 311 fprintf(stderr,"%s","Failed test point\n"); 312 return 1; 313 } 314 315 return 0; 316 } 317 318 static psS32 testStrAppend02(void) 319 { 320 char *str=NULL; 321 int result; 322 323 // test string creation 324 psStringAppend(&str, "%s", "fubar"); 325 result = strcmp(str, "fubar"); 326 if ( result != 0 ) { 327 fprintf(stderr,"%s","Failed test point\n"); 328 return 1; 329 } 330 331 psFree(str); 332 333 return 0; 334 } 335 336 static psS32 testStrAppend03(void) 337 { 338 char *str=NULL; 339 int result; 340 341 str = psStringCopy(STR_0); 342 343 // test null-op 344 psStringAppend(&str, ""); 345 result = strcmp(str, STR_0); 346 if ( result != 0 ) { 347 fprintf(stderr,"Failed test point str=[%s]\n", str); 348 return 1; 349 } 350 351 psFree(str); 352 353 return 0; 354 } 355 356 static psS32 testStrPrepend00(void) 357 { 358 char *str=NULL; 359 int result = 0; 360 361 str = psStringCopy("79323846"); 362 363 psStringPrepend(&str, "%s%d","3.14159", 2653589 ); 364 365 // Test point: Verify string append 366 result = strcmp(str, "3.14159265358979323846"); 367 if ( result != 0 ) { 368 fprintf(stderr,"%s","Failed test point\n"); 369 return 1; 370 } 371 372 psFree(str); 373 374 return 0; 375 } 376 377 static psS32 testStrPrepend01(void) 378 { 379 ssize_t sz; 380 char *str=NULL; 381 382 // test nonsensical invocations ... 383 sz = psStringPrepend(NULL, NULL); 384 if ( sz != 0 ) { 385 fprintf(stderr,"%s","Failed test point\n"); 386 return 1; 387 } 388 sz = psStringPrepend(&str, NULL); 389 if ( sz != 0 ) { 390 fprintf(stderr,"%s","Failed test point\n"); 391 return 1; 392 } 393 394 return 0; 395 } 396 397 static psS32 testStrPrepend02(void) 398 { 399 char *str=NULL; 400 int result; 401 402 // test string creation 403 psStringPrepend(&str, "%s", "fubar"); 404 result = strcmp(str, "fubar"); 405 if ( result != 0 ) { 406 fprintf(stderr,"%s","Failed test point\n"); 407 return 1; 408 } 409 410 psFree(str); 411 412 return 0; 413 } 414 415 static psS32 testStrPrepend03(void) 416 { 417 char *str=NULL; 418 int result; 419 420 str = psStringCopy(STR_0); 421 422 // test null-op 423 psStringPrepend(&str, ""); 424 result = strcmp(str, STR_0); 425 if ( result != 0 ) { 426 fprintf(stderr,"Failed test point str=[%s]\n", str); 427 return 1; 428 } 429 430 psFree(str); 431 432 return 0; 433 }
Note:
See TracChangeset
for help on using the changeset viewer.
