Changeset 2129 for trunk/psLib/test/sysUtils/tst_psError.c
- Timestamp:
- Oct 14, 2004, 11:14:58 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/sysUtils/tst_psError.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sysUtils/tst_psError.c
r1884 r2129 13 13 * @author Eric Van Alst, MHPCC 14 14 * 15 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $16 * @date $Date: 2004- 09-24 22:48:59$15 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2004-10-14 21:14:58 $ 17 17 * 18 18 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 32 32 static int testError04(void); 33 33 static int testError05(void); 34 static int testErrorRegister(void); 34 35 35 36 // Function used in testError02 to verify the psErrorStackPrintV function … … 53 54 {testError04, 728, "psErrorClear()", 0, false}, 54 55 {testError05, 729, "psErrorCodeString()", 0, false}, 56 {testErrorRegister, 751, "psErrorRegister()", 0, false}, 55 57 {NULL} 56 58 }; … … 298 300 } 299 301 302 static int testErrorRegister(void) 303 { 304 305 int numErr = 4; 306 psErrorDescription errDesc[] = { {PS_ERR_N_ERR_CLASSES+1,"first"}, 307 {PS_ERR_N_ERR_CLASSES+2,"second"}, 308 {PS_ERR_N_ERR_CLASSES+3,"third"}, 309 {PS_ERR_N_ERR_CLASSES+4,"fourth"} }; 310 /* 311 1. invoke psErrorRegister with a n>1 array of psErrorDescriptions. Verify that: 312 a. Each error description given is retrievable with psErrorCodeString. 313 */ 314 psErrorRegister(errDesc,numErr); 315 316 for (int i = 0; i < numErr; i++) { 317 const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+1+i); 318 if (desc == NULL) { 319 psLogMsg(__func__,PS_LOG_ERROR, 320 "psErrorCode didn't find registered error code."); 321 return 1+i*10; 322 } 323 if (strcmp(desc,errDesc[i].description) != 0) { 324 psLogMsg(__func__,PS_LOG_ERROR, 325 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", 326 desc,errDesc[i].description); 327 return 2+i*10; 328 } 329 } 330 331 /* 332 2. invoke psErrorCodeString with a static/builtin psLib error code. Verify: 333 a. the result is correct. 334 */ 335 const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES); 336 if (desc == NULL) { 337 psLogMsg(__func__,PS_LOG_ERROR, 338 "psErrorCode didn't find static error code."); 339 return 40; 340 } 341 if (strcmp(desc,"error classes end marker") != 0) { 342 psLogMsg(__func__,PS_LOG_ERROR, 343 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", 344 desc,"error classes end marker"); 345 return 41; 346 } 347 348 desc = psErrorCodeString(PS_ERR_NONE); 349 if (desc == NULL) { 350 psLogMsg(__func__,PS_LOG_ERROR, 351 "psErrorCode didn't find static error code."); 352 return 42; 353 } 354 if (strcmp(desc,"not an error") != 0) { 355 psLogMsg(__func__,PS_LOG_ERROR, 356 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", 357 desc,"not an error"); 358 return 43; 359 } 360 361 /* 362 3. invoke psErrorCodeString with an invalid code. Verify a NULL is returned. 363 */ 364 desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+numErr+1); 365 if (desc != NULL) { 366 psLogMsg(__func__,PS_LOG_ERROR, 367 "psErrorCode didn't return a NULL with a bogus input code."); 368 return 44; 369 } 370 371 /* 372 4. invoke psErrorRegister with a NULL psErrorDescription. Verify that: 373 a. the execution does not cease. 374 b. an appropriate error is generated. 375 */ 376 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error."); 377 psErrorClear(); 378 psErrorRegister(NULL,1); 379 psErr* err = psErrorLast(); 380 if (err->code != PS_ERR_BAD_PARAMETER_NULL) { 381 psLogMsg(__func__,PS_LOG_ERROR, 382 "psErrorCode didn't generate proper error code for NULL input."); 383 return 45; 384 } 385 psFree(err); 386 387 /* 388 5. invoke psErrorRegister with nerror=0. Verify that no error occurs. 389 */ 390 psErrorClear(); 391 psErrorRegister(errDesc,0); 392 err = psErrorLast(); 393 if (err->code != PS_ERR_NONE) { 394 psLogMsg(__func__,PS_LOG_ERROR, 395 "psErrorCode generated an error for nErrors = 0."); 396 return 46; 397 } 398 psFree(err); 399 return 0; 400 }
Note:
See TracChangeset
for help on using the changeset viewer.
