Changeset 12781 for trunk/psLib/test/sys/tap_psError.c
- Timestamp:
- Apr 10, 2007, 11:09:31 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/sys/tap_psError.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/sys/tap_psError.c
r12513 r12781 3 3 * @brief Test driver for psError function 4 4 * 5 * This test driver contains the following test points for psError6 * testError00 - psError() (Testpoint #486)7 * testError01 - psErrorMsg(), psErrorStackPrint() (Testpoint #725)8 * testError02 - psErrorStackPrintV() (Testpoint #726)9 * testError03 - psErrorGet(), psErrorLast() (Testpoint #727)10 * testError04 - psErrorClear() (Testpoint #728)11 * testError05 - psErrorCodeString() (Testpoint #729)12 *13 5 * @author Eric Van Alst, MHPCC 14 6 * 15 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $16 * @date $Date: 2007-0 3-20 03:57:25$7 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-04-10 21:09:31 $ 17 9 * 18 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 28 20 29 21 // Function used in testError02 to verify the psErrorStackPrintV function 30 static void myErrorStackPrint(FILE *fd, 31 const char *fmt, 32 ...) 22 static void myErrorStackPrint( 23 FILE *fd, 24 const char *fmt, 25 ...) 33 26 { 34 27 va_list ap; … … 41 34 42 35 43 static psS32 testError00(void)44 {45 // diag("testError00");46 47 psS32 intval=1;48 psS64 longval = 2;49 float floatval = 3.01;50 char charval = 'E';51 char *stringval = "E R R O R";52 53 // Test point #1 Multiple type values placed in the error string54 psError(PS_ERR_UNKNOWN, true,55 "ALL TYPES intval = %d longval = %lld floatval = %f charval = %c strval = %s",56 intval,longval,floatval,charval,stringval);57 58 // Test point #2 String values in error message59 psError(PS_ERR_UNKNOWN, true, "NO VALUES");60 61 // Test point #3 Empty strings in error message62 psError(PS_ERR_UNKNOWN, true, " ");63 64 return 0;65 }66 67 68 static psS32 testError01(void)69 {70 // diag("testError01");71 72 psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE;73 74 // Verify the return value of psErrorMsg is the psErrorCode passed75 ok ( psError(code, true, "Error code = %d", code) == code,76 "Failed return value verify.");77 skip_start ( psError(code, true, "Error code = %d", code) != code,78 4, "Failed return value verify.");79 80 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1A");81 82 // test1B empty string in for name argument83 ok ( psError(code+1, true, "Error code = %d", code+1) == code+1,84 "Failed return with empty string.");85 skip_start ( psError(code+1, true, "Error code = %d", code+1) != code+1,86 3, "Failed return with empty string.");87 88 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B");89 90 // test1D undefined code91 ok ( psError(-1, true, "Error code = %d", -1) == -1,92 "Failed return with undefined code.");93 skip_start ( psError(-1, true, "Error code = %d", -1) != -1,94 2, "Failed return with undefined code.");95 96 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1D");97 98 // test1E set psErrorMsg argument to false99 ok( psError(code, false, "Error code = %d", code) == code,100 "Failed return with false new arg.");101 skip_start( psError(code, false, "Error code = %d", code) != code,102 1, "Failed return with false new arg.");103 104 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1E");105 106 // test1F psErrorMsg with a error code less then PS_ERR_BASE(256)107 ok( psError(9, true, "Errno code = %d", 9) == 9, "Error Code" );108 109 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1F");110 111 skip_end();112 skip_end();113 skip_end();114 skip_end();115 116 return 0;117 }118 119 120 static psS32 testError02(void)121 {122 // diag("testError02");123 124 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;125 126 // Generate error message and verify return value127 ok (psError(code, true, "Error code = %d", code) == code,128 "Failed return value verify.");129 130 myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2);131 132 return 0;133 }134 135 136 static psS32 testError03(void)137 {138 // diag("testError03");139 140 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;141 psErr *last = NULL;142 psErr *getErr = NULL;143 144 // Attempt to get last error message with an empty stack verify psErr with code PS_ERR_NONE145 last = psErrorLast();146 ok(last->code == PS_ERR_NONE,147 "psErrorLast did return PS_ERR_NONE for empty stack (%d)", last->code);148 skip_start(last->code == PS_ERR_NONE,149 9, "psErrorLast did return PS_ERR_NONE for empty stack");150 151 psFree(last);152 153 // HEY154 // Attempt to get specific error message with empty stack verify psErr with code PS_ERR_NONE155 getErr= psErrorGet(2);156 ok(getErr->code == PS_ERR_NONE,157 "psErrorGet did not return PS_ERR_NONE for empty stack (%d)", getErr->code);158 skip_start(getErr->code == PS_ERR_NONE,159 8, "psErrorGet did not return PS_ERR_NONE for empty stack");160 161 psFree(getErr);162 163 // Attempt to get error message with invalid index and an empty stack164 getErr= psErrorGet(-1);165 ok(getErr->code == PS_ERR_NONE,166 "psErrorGet with invalid index/empty stack");167 skip_start(getErr->code != PS_ERR_NONE,168 7, "psErrorGet with invalid index/empty stack");169 170 psFree(getErr);171 172 // Generate three error messages173 ok (psError(code, true, "Error code = %d", code) == code,174 "return value verify-1.");175 skip_start (psError(code, true, "Error code = %d", code != code),176 6, "return value verify-2.");177 178 ok (psError((code+1), false, "Error code = %d", (code+1)) == (code+1),179 "Failed return value verify-3.");180 skip_start (psError((code+1), false, "Error code = %d", (code+1))!=(code+1),181 5, "Failed return value verify-4.");182 183 ok (psError((code+2), false, "Error code = %d", (code+2)) == (code+2),184 "Failed return value verify-5.");185 skip_start (psError((code+2), false, "Error code = %d", (code+2))!=(code+2),186 4, "Failed return value verify-6.");187 188 last = psErrorLast();189 getErr= psErrorGet(0);190 191 // Check that last and get with 0 index are equal192 ok(last == getErr, "psErrorGet(0) equal to psErrorLast");193 skip_start(last != getErr, 3, "psErrorGet(0) equal to psErrorLast");194 195 psFree(last);196 197 // Verify the last error message was returned198 ok ( getErr->code == (code+2),199 "psErrorLast() did not retrieve last error");200 skip_start ( getErr->code != (code+2),201 2, "psErrorLast() did not retrieve last error");202 203 psFree(getErr);204 205 // Verify the middle error message can be retrieved206 getErr= psErrorGet(1);207 ok ( getErr->code == (code+1),208 "psErrorGet() did not retrieve proper error");209 skip_start ( getErr->code != (code+1),210 1, "psErrorGet() did not retrieve proper error");211 212 psFree(getErr);213 214 // Verify the psErrorGet returns NULL if an invalid index is given215 getErr= psErrorGet(-1);216 ok ( getErr->code == PS_ERR_NONE,217 "psErrorGet() did not return PS_ERR_NONE w/ invalid arg");218 219 skip_end();220 skip_end();221 skip_end();222 skip_end();223 skip_end();224 skip_end();225 skip_end();226 skip_end();227 skip_end();228 229 psFree(getErr);230 231 return 0;232 }233 234 235 static psS32 testError04(void)236 {237 //diag("testError04");238 239 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;240 psErr *last = NULL;241 psErr *lastAfterClear = NULL;242 243 // With an attemp error stack call psErrorClear244 psErrorClear();245 246 // Get the last error message and verify PS_ERR_NONE (empty stack)247 lastAfterClear = psErrorLast();248 ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected.");249 skip_start(lastAfterClear->code != PS_ERR_NONE,250 5, "psErrorLast return expected.");251 252 psFree(lastAfterClear);253 254 // Generate three error messages to have messages on error stack255 ok (psError(code, true, "Error code = %d", code) == code,256 "Failed return value verify.");257 skip_start (psError(code, true, "Error code = %d", code) != code,258 4, "Failed return value verify.");259 260 ok (psError((code+1), false, "Error code = %d", (code+1)) == (code+1),261 "Failed return value verify.");262 skip_start (psError((code+1), false, "Error code = %d", (code+1))!=(code+1),263 3, "Failed return value verify.");264 265 ok (psError((code+2), false, "Error code = %d", (code+2)) == (code+2),266 "Failed return value verify.");267 skip_start (psError((code+2), false, "Error code = %d", (code+2))!=(code+2),268 2, "Failed return value verify.");269 270 // Get the last error message and verify it has the expected code271 last = psErrorLast();272 ok(last->code == (code+2), "psErrorLast return expected.");273 skip_start(last->code != (code+2), 1, "psErrorLast return expected.");274 275 psFree(last);276 277 // Clear the error stack278 psErrorClear();279 280 // Get the last error message after clear and verify is has PS_ERR_NONE code281 lastAfterClear = psErrorLast();282 ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected.");283 284 skip_end();285 skip_end();286 skip_end();287 skip_end();288 skip_end();289 290 psFree(lastAfterClear);291 292 return 0;293 }294 295 296 static psS32 testError05(void)297 {298 //diag("testError05");299 300 // Verify the return value of psErrorCodeString301 // psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE;302 // psLogMsg("tst_psError05", PS_LOG_INFO, psErrorCodeString(code));303 304 // Verify the return value of psErrorCodeString if code is negative305 ok( psErrorCodeString(-1) == NULL, "error string with neg. code");306 307 return 0;308 }309 310 311 static psS32 testErrorRegister(void)312 {313 //diag("testErrorRegister");314 315 psS32 numErr = 4;316 psErrorDescription errDesc[] = { {PS_ERR_N_ERR_CLASSES+1,"first"},317 {PS_ERR_N_ERR_CLASSES+2,"second"},318 {PS_ERR_N_ERR_CLASSES+3,"third"},319 {PS_ERR_N_ERR_CLASSES+4,"fourth"} };320 /*321 1. invoke psErrorRegister with a n>1 array of psErrorDescriptions. Verify that:322 a. Each error description given is retrievable with psErrorCodeString.323 */324 psErrorRegister(errDesc,numErr);325 326 for (psS32 i = 0; i < numErr; i++) {327 const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+1+i);328 ok (desc != NULL,329 "psErrorCode didn't find registered error code.");330 331 ok (strcmp(desc,errDesc[i].description) == 0,332 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", desc,errDesc[i].description);333 }334 335 /*336 2. invoke psErrorCodeString with a static/builtin psLib error code. Verify:337 a. the result is correct.338 */339 const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES);340 ok (desc != NULL, "psErrorCode didn't find static error code.");341 ok (strcmp(desc,"error classes end marker") == 0,342 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.",343 desc,"error classes end marker");344 345 desc = psErrorCodeString(PS_ERR_NONE);346 ok (desc != NULL,347 "psErrorCode didn't find static error code.");348 ok (strcmp(desc,"not an error") == 0,349 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.",350 desc,"not an error");351 352 /*353 3. invoke psErrorCodeString with an invalid code. Verify a NULL is returned.354 */355 desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+numErr+1);356 ok (desc == NULL,357 "psErrorCode didn't return a NULL with a bogus input code.");358 359 /*360 4. invoke psErrorRegister with a NULL psErrorDescription. Verify that:361 a. the execution does not cease.362 b. an appropriate error is generated.363 */364 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");365 psErrorClear();366 psErrorRegister(NULL,1);367 psErr* err = psErrorLast();368 ok (err->code == PS_ERR_BAD_PARAMETER_NULL,369 "psErrorCode didn't generate proper error code for NULL input.");370 371 psFree(err);372 373 /*374 5. invoke psErrorRegister with nerror=0. Verify that no error occurs.375 */376 psErrorClear();377 psErrorRegister(errDesc,0);378 err = psErrorLast();379 ok (err->code == PS_ERR_NONE,380 "psErrorCode generated an error for nErrors = 0.");381 382 psFree(err);383 return 0;384 }385 386 387 36 psS32 main( psS32 argc, char* argv[] ) 388 37 { 389 38 psLogSetFormat("HLNM"); 390 plan_tests(38); 391 392 // XXX: testError03() fails if we put it in sequence with the others. 393 testError03(); 394 testError00(); 395 testError01(); 396 testError02(); 397 testError04(); 398 testError05(); 399 testErrorRegister(); 39 plan_tests(60); 40 41 42 //psError() tests 43 { 44 psS32 intval=1; 45 psS64 longval = 2; 46 float floatval = 3.01; 47 char charval = 'E'; 48 char *stringval = "E R R O R"; 49 50 // Multiple type values placed in the error string 51 // XX: The output is never verified 52 { 53 psMemId id = psMemGetId(); 54 psError(PS_ERR_UNKNOWN, true, 55 "ALL TYPES intval = %d longval = %lld floatval = %f charval = %c strval = %s", 56 intval,longval,floatval,charval,stringval); 57 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 58 } 59 60 61 // String values in error message 62 // XX: The output is never verified 63 { 64 psMemId id = psMemGetId(); 65 psError(PS_ERR_UNKNOWN, true, "NO VALUES"); 66 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 67 } 68 69 70 // Empty strings in error message 71 // XX: The output is never verified 72 { 73 psMemId id = psMemGetId(); 74 psError(PS_ERR_UNKNOWN, true, " "); 75 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 76 } 77 78 79 // Verify the return value of psErrorMsg is the psErrorCode passed 80 { 81 psMemId id = psMemGetId(); 82 psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE; 83 ok(psError(code, true, "Error code = %d", code) == code, "Failed return value verify."); 84 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1A"); 85 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 86 } 87 88 89 // test1B empty string in for name argument 90 { 91 psMemId id = psMemGetId(); 92 psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE; 93 ok(psError(code+1, true, "Error code = %d", code+1) == code+1, 94 "Failed return with empty string."); 95 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1B"); 96 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 97 } 98 99 100 // test1D undefined code 101 { 102 psMemId id = psMemGetId(); 103 ok(psError(-1, true, "Error code = %d", -1) == -1, 104 "Failed return with undefined code."); 105 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1D"); 106 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 107 } 108 109 110 // test1E set psErrorMsg argument to false 111 { 112 psMemId id = psMemGetId(); 113 psErrorCode code=PS_ERR_BAD_PARAMETER_VALUE; 114 ok(psError(code, false, "Error code = %d", code) == code, 115 "Failed return with false new arg."); 116 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1E"); 117 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 118 } 119 120 121 // test1F psErrorMsg with a error code less then PS_ERR_BASE(256) 122 { 123 psMemId id = psMemGetId(); 124 ok(psError(9, true, "Errno code = %d", 9) == 9, "Error Code" ); 125 psErrorStackPrint(stderr,"ERROR STACK PRINT Test1F"); 126 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 127 } 128 } 129 130 131 //testError02() 132 { 133 // Generate error message and verify return value 134 { 135 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 136 psMemId id = psMemGetId(); 137 ok(psError(code, true, "Error code = %d", code) == code, 138 "Failed return value verify."); 139 myErrorStackPrint(stderr,"ERROR STACK PRINT Test%dA",2); 140 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 141 } 142 } 143 144 145 //psErrorGet(), psErrorLast() 146 { 147 // Attempt to get last error message with an empty stack verify 148 // psErr with code PS_ERR_NONE 149 { 150 psMemId id = psMemGetId(); 151 psErrorClear(); 152 psErr *last = psErrorLast(); 153 ok(last != NULL, "psErrorLast() returned non-NULL"); 154 skip_start(last == NULL, 1, "Skipping tests because psErrorLast() returned NULL"); 155 ok(last->code == PS_ERR_NONE, 156 "psErrorLast did return PS_ERR_NONE for empty stack(%d)", last->code); 157 skip_end(); 158 psFree(last); 159 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 160 } 161 162 // Attempt to get specific error message with empty stack verify 163 // psErr with code PS_ERR_NONE 164 { 165 psMemId id = psMemGetId(); 166 psErr *getErr= psErrorGet(2); 167 ok(getErr != NULL, "psErrorGet(2) returned non-NULL"); 168 skip_start(getErr == NULL, 1, "Skipping tests because psErrorGet() returned NULL"); 169 ok(getErr->code == PS_ERR_NONE, 170 "psErrorGet(2) did return PS_ERR_NONE for empty stack(%d)", getErr->code); 171 skip_end(); 172 psFree(getErr); 173 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 174 } 175 176 177 // Attempt to get error message with invalid index and an empty stack 178 { 179 psMemId id = psMemGetId(); 180 psErr *getErr= psErrorGet(-1); 181 ok(getErr != NULL, "psErrorGet(-1) returned non-NULL"); 182 skip_start(getErr == NULL, 1, "Skipping tests because psErrorGet(-1) returned NULL"); 183 ok(getErr->code == PS_ERR_NONE, "psErrorGet with invalid index/empty stack"); 184 skip_end(); 185 psFree(getErr); 186 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 187 } 188 189 190 // Generate three error messages, ensure they are correctly returned by psError() 191 { 192 psMemId id = psMemGetId(); 193 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 194 ok(psError(code, true, "Error code = %d", code) == code, 195 "psError() returned correct error code (example 1)"); 196 ok(psError((code+1), false, "Error code = %d", (code+1)) == (code+1), 197 "psError() returned correct error code (example 2)"); 198 ok(psError((code+2), false, "Error code = %d", (code+2)) == (code+2), 199 "psError() returned correct error code (example 3)"); 200 201 psErr *last = psErrorLast(); 202 psErr *getErr= psErrorGet(0); 203 204 // Check that last and get with 0 index are equal 205 ok(last == getErr, "psErrorGet(0) equal to psErrorLast()"); 206 psFree(last); 207 208 // Verify the last error message was returned 209 ok(getErr->code == (code+2), "psErrorLast() did retrieve last error"); 210 psFree(getErr); 211 psErrorClear(); 212 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 213 } 214 215 216 // Verify the middle error message can be retrieved 217 { 218 psMemId id = psMemGetId(); 219 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 220 psError(code, true, "Error code = %d", code); 221 psError((code+1), false, "Error code = %d", (code+1)); 222 psError((code+2), false, "Error code = %d", (code+2)); 223 psErr *getErr= psErrorGet(1); 224 ok(getErr->code == (code+1), "psErrorGet() did not retrieve proper error"); 225 psFree(getErr); 226 psErrorClear(); 227 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 228 } 229 230 // Verify the psErrorGet returns non-NULL PS_ERR_NONE if an invalid index 231 // is given with non-empty error stack 232 { 233 psMemId id = psMemGetId(); 234 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 235 psError(code, true, "Error code = %d", code); 236 psError((code+1), false, "Error code = %d", (code+1)); 237 psError((code+2), false, "Error code = %d", (code+2)); 238 psErr *getErr= psErrorGet(-1); 239 ok(getErr->code == PS_ERR_NONE, "psErrorGet() did not return PS_ERR_NONE w/ invalid arg"); 240 psFree(getErr); 241 psErrorClear(); 242 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 243 } 244 } 245 246 247 // psErrorClear() 248 { 249 // With an attemp error stack call psErrorClear 250 { 251 psMemId id = psMemGetId(); 252 psErrorClear(); 253 // Get the last error message and verify PS_ERR_NONE (empty stack) 254 psErr *lastAfterClear = psErrorLast(); 255 ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected."); 256 psFree(lastAfterClear); 257 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 258 } 259 260 261 // Generate three error messages to have messages on error stack 262 { 263 psMemId id = psMemGetId(); 264 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 265 ok(psError(code, true, "Error code = %d", code) == code, 266 "Failed return value verify."); 267 ok(psError((code+1), false, "Error code = %d", (code+1)) == (code+1), 268 "Failed return value verify."); 269 ok(psError((code+2), false, "Error code = %d", (code+2)) == (code+2), 270 "Failed return value verify."); 271 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 272 } 273 274 // Get the last error message and verify it has the expected code 275 { 276 psMemId id = psMemGetId(); 277 psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 278 psErr *last = psErrorLast(); 279 ok(last->code == (code+2), "psErrorLast return expected."); 280 psFree(last); 281 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 282 } 283 284 // Clear the error stack 285 { 286 psMemId id = psMemGetId(); 287 psErrorClear(); 288 // Get the last error message after clear and verify is has PS_ERR_NONE code 289 psErr *lastAfterClear = psErrorLast(); 290 ok(lastAfterClear->code == PS_ERR_NONE, "psErrorLast return expected."); 291 psFree(lastAfterClear); 292 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 293 } 294 } 295 296 297 // psErrorCodeString() 298 { 299 // Verify the return value of psErrorCodeString 300 // psErrorCode code = PS_ERR_BAD_PARAMETER_VALUE; 301 // psLogMsg("tst_psError05", PS_LOG_INFO, psErrorCodeString(code)); 302 303 // Verify the return value of psErrorCodeString if code is negative 304 ok( psErrorCodeString(-1) == NULL, "error string with neg. code"); 305 } 306 307 308 //testErrorRegister() 309 { 310 psS32 numErr = 4; 311 psErrorDescription errDesc[] = { {PS_ERR_N_ERR_CLASSES+1,"first"}, 312 {PS_ERR_N_ERR_CLASSES+2,"second"}, 313 {PS_ERR_N_ERR_CLASSES+3,"third"}, 314 {PS_ERR_N_ERR_CLASSES+4,"fourth"} }; 315 /* 316 1. invoke psErrorRegister with a n>1 array of psErrorDescriptions. Verify that: 317 a. Each error description given is retrievable with psErrorCodeString. 318 */ 319 psErrorRegister(errDesc,numErr); 320 321 for (psS32 i = 0; i < numErr; i++) { 322 const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+1+i); 323 ok(desc != NULL, 324 "psErrorCode didn't find registered error code."); 325 326 ok(strcmp(desc,errDesc[i].description) == 0, 327 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", desc,errDesc[i].description); 328 } 329 330 /* 331 2. invoke psErrorCodeString with a static/builtin psLib error code. Verify: 332 a. the result is correct. 333 */ 334 const char* desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES); 335 ok(desc != NULL, "psErrorCode didn't find static error code."); 336 ok(strcmp(desc,"error classes end marker") == 0, 337 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", 338 desc,"error classes end marker"); 339 340 desc = psErrorCodeString(PS_ERR_NONE); 341 ok(desc != NULL, 342 "psErrorCode didn't find static error code."); 343 ok(strcmp(desc,"not an error") == 0, 344 "psErrorCode didn't return the proper description. Got '%s', expected '%s'.", 345 desc,"not an error"); 346 347 /* 348 3. invoke psErrorCodeString with an invalid code. Verify a NULL is returned. 349 */ 350 desc = psErrorCodeString(PS_ERR_N_ERR_CLASSES+numErr+1); 351 ok(desc == NULL, 352 "psErrorCode didn't return a NULL with a bogus input code."); 353 354 /* 355 4. invoke psErrorRegister with a NULL psErrorDescription. Verify that: 356 a. the execution does not cease. 357 b. an appropriate error is generated. 358 */ 359 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error."); 360 psErrorClear(); 361 psErrorRegister(NULL,1); 362 psErr* err = psErrorLast(); 363 ok(err->code == PS_ERR_BAD_PARAMETER_NULL, 364 "psErrorCode didn't generate proper error code for NULL input."); 365 366 psFree(err); 367 368 /* 369 5. invoke psErrorRegister with nerror=0. Verify that no error occurs. 370 */ 371 psErrorClear(); 372 psErrorRegister(errDesc,0); 373 err = psErrorLast(); 374 ok(err->code == PS_ERR_NONE, 375 "psErrorCode generated an error for nErrors = 0."); 376 psFree(err); 377 } 400 378 } 401 402 379 //HERE
Note:
See TracChangeset
for help on using the changeset viewer.
