Changeset 6578
- Timestamp:
- Mar 13, 2006, 5:25:48 PM (20 years ago)
- Location:
- trunk/psLib
- Files:
-
- 3 edited
-
src/mathtypes/psImage.c (modified) (3 diffs)
-
test/mathtypes/tst_psImage.c (modified) (5 diffs)
-
test/mathtypes/verified/tst_psImage.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psImage.c
r6574 r6578 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.9 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-03-14 0 2:22:55$11 * @version $Revision: 1.97 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-03-14 03:25:48 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 319 319 PS_ASSERT_INT_NONNEGATIVE(image->col0, false); 320 320 PS_ASSERT_INT_NONNEGATIVE(image->row0, false); 321 PS_ASSERT_INT_ NONNEGATIVE(image->numCols, false);322 PS_ASSERT_INT_ NONNEGATIVE(image->numRows, false);321 PS_ASSERT_INT_POSITIVE(image->numCols, false); 322 PS_ASSERT_INT_POSITIVE(image->numRows, false); 323 323 if ( x >= (image->col0 + image->numCols) ) { 324 324 psError(PS_ERR_BAD_PARAMETER_SIZE, true, … … 414 414 int y) 415 415 { 416 if (image == NULL) { 417 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL); 418 return NAN; 419 } 420 if (x >= image->numRows || y >= image->numCols) { 421 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position. Position too large\n"); 422 return NAN; 423 } 424 425 if(x < 0) 426 x += image->numRows; 427 if(x < 0) { 428 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x. Negative number too large\n"); 429 return NAN; 430 } 431 432 if(y < 0) 433 y += image->numCols; 434 if(y < 0) { 435 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y. Negative number too large\n"); 436 return NAN; 437 } 416 /* if (image == NULL) { 417 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL); 418 return NAN; 419 } 420 if (x >= image->numRows || y >= image->numCols) { 421 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position. Position too large\n"); 422 return NAN; 423 } 424 425 if(x < 0) 426 x += image->numRows; 427 if(x < 0) { 428 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x. Negative number too large\n"); 429 return NAN; 430 } 431 432 if(y < 0) 433 y += image->numCols; 434 if(y < 0) { 435 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y. Negative number too large\n"); 436 return NAN; 437 } 438 */ 439 PS_ASSERT_IMAGE_NON_NULL(image, NAN); 440 PS_ASSERT_INT_NONNEGATIVE(image->col0, NAN); 441 PS_ASSERT_INT_NONNEGATIVE(image->row0, NAN); 442 PS_ASSERT_INT_POSITIVE(image->numCols, NAN); 443 PS_ASSERT_INT_POSITIVE(image->numRows, NAN); 444 if ( x >= (image->col0 + image->numCols) ) { 445 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 446 "Invalid x-position %d. Position out of range (%d-%d)\n", 447 x, image->col0, image->numCols+image->col0-1 ); 448 return false; 449 } else if ( y >= (image->row0 + image->numRows) ) { 450 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 451 "Invalid y-position %d. Position out of range (%d-%d)\n", 452 y, image->row0, image->numRows+image->row0-1 ); 453 return false; 454 } else if (x < image->col0 && x >= 0) { 455 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 456 "Invalid x-position %d. Position out of range (%d-%d)\n", 457 x, image->col0, image->numCols+image->col0-1 ); 458 return false; 459 } else if (y < image->row0 && y >= 0) { 460 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 461 "Invalid y-position %d. Position out of range (%d-%d)\n", 462 y, image->row0, image->numRows+image->row0-1 ); 463 return false; 464 } else if (x < 0 || y < 0) { 465 if (x < 0) { 466 x += image->numCols; 467 } 468 if (x < 0) { 469 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 470 "Invalid x-position %d. Position out of range (%d-%d)\n", 471 (x+image->col0), image->col0, image->numCols+image->col0-1 ); 472 return false; 473 } 474 if (y < 0) { 475 y += image->numRows; 476 } 477 if (y < 0) { 478 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 479 "Invalid y-position %d. Position out of range (%d-%d)\n", 480 (y+image->row0), image->row0, image->numRows+image->row0-1 ); 481 return false; 482 } 483 } else { 484 x -= image->col0; 485 y -= image->row0; 486 } 487 438 488 439 489 switch (image->type.type) { -
trunk/psLib/test/mathtypes/tst_psImage.c
r6574 r6578 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-03-14 0 2:22:55$8 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-03-14 03:25:48 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 26 26 static psS32 testRegion3(void); 27 27 static psS32 testImageInit(void); 28 static psS32 testImageGetSet(void); 28 static psS32 testImageSet(void); 29 static psS32 testImageGet(void); 29 30 30 31 testDescription tests[] = { … … 36 37 {testRegion3,793,"psRegionForSquare",0,false}, 37 38 {testImageInit,794,"psImageInit",0,false}, 38 {testImageGetSet,795,"psImageGetSet",0,false}, 39 {testImageSet,795,"psImageSet",0,false}, 40 {testImageGet,666,"psImageGet",0,false}, 39 41 {NULL} 40 42 }; … … 356 358 } 357 359 358 static psS32 testImage GetSet(void)360 static psS32 testImageSet(void) 359 361 { 360 362 psImage *image = NULL; … … 471 473 return 0; 472 474 } 475 476 static psS32 testImageGet(void) 477 { 478 psImage *image = NULL; 479 image = psImageAlloc(5, 5, PS_TYPE_S32); 480 481 //Set the position of the subimage relative to the parent. 482 image->col0 = 10; 483 image->row0 = 10; 484 for (int i = 0; i < 5; i++) { 485 for (int j = 0; j < 5; j++) { 486 image->data.S32[i][j] = i+j; 487 } 488 } 489 490 //Attempt to get a position in a NULL psImage* 491 psImage *none = NULL; 492 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 493 if ( !isnan( psImageGet(none, 1, 1) ) ) { 494 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 495 "psImageGet failed to return false when passed a NULL image.\n"); 496 return 1; 497 } 498 499 //Attempt to get a position in a psImage* with negative numCols, numRows 500 none = psImageAlloc(2, 2, PS_TYPE_S32); 501 *(int*)&none->numCols = -1; 502 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 503 if ( !isnan( psImageGet(none, 1, 1) ) ) { 504 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 505 "psImageGet failed to return false when passed an image with negative numCols.\n"); 506 return 2; 507 } 508 *(int*)&none->numCols = 2; 509 *(int*)&none->numRows = -1; 510 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 511 if ( !isnan( psImageGet(none, 1, 1) ) ) { 512 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 513 "psImageGet failed to return false when passed an image with negative numRows.\n"); 514 return 3; 515 } 516 517 //Attempt to get a position in a psImage* with negative col0, row0 518 *(int*)&none->numRows = 2; 519 none->row0 = -1; 520 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 521 if ( !isnan( psImageGet(none, 1, 1) ) ) { 522 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 523 "psImageGet failed to return false when passed an image with negative col0.\n"); 524 return 4; 525 } 526 none->row0 = 0; 527 none->col0 = -1; 528 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 529 if ( !isnan( psImageGet(none, 1, 1) ) ) { 530 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 531 "psImageGet failed to return false when passed an image with negative col0.\n"); 532 return 5; 533 } 534 psFree(none); 535 536 //Try to get a position inside of the subimage. 537 if ( psImageGet(image, 13, 14) != 7 ) { 538 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 539 "psImageGet failed to return the correct value.\n"); 540 return 6; 541 } 542 //Try to get a position inside of the subimage from the tail. 543 if ( psImageGet(image, -1, -1) != 8 ) { 544 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 545 "psImageGet failed to return the correct value.\n"); 546 return 8; 547 } 548 549 //Try to get a position outside of the subimage but inside of the parent image. 550 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 551 if ( isnan( psImageGet(image, 1, 1) ) ) { 552 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 553 "psImageGet failed to return NAN when passed an invalid location.\n"); 554 return 10; 555 } 556 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 557 if ( isnan( psImageGet(image, 9, 10) ) ) { 558 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 559 "psImageGet failed to return NAN when passed an invalid location.\n"); 560 return 11; 561 } 562 563 //Try to set a position outside of the subimage. 564 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 565 if ( isnan( psImageGet(image, 15, 14) ) ) { 566 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 567 "psImageGet failed to return NAN when passed an invalid location.\n"); 568 return 12; 569 } 570 //Try to set a position outside of the subimage, indexing from the tail. 571 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 572 if ( isnan( psImageGet(image, -6, -1) ) ) { 573 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 574 "psImageGet failed to return NAN when passed an invalid location.\n"); 575 return 13; 576 } 577 578 579 psFree(image); 580 return 0; 581 } 582 -
trunk/psLib/test/mathtypes/verified/tst_psImage.stderr
r6574 r6578 130 130 /***************************** TESTPOINT ******************************************\ 131 131 * TestFile: tst_psImage.c * 132 * TestPoint: psImage{psImage GetSet}*133 * TestType: Positive * 134 \**********************************************************************************/ 135 136 <DATE><TIME>|<HOST>|I|testImage GetSet132 * TestPoint: psImage{psImageSet} * 133 * TestType: Positive * 134 \**********************************************************************************/ 135 136 <DATE><TIME>|<HOST>|I|testImageSet 137 137 Following should generate error message 138 138 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 139 139 Unallowable operation: psImage image or its data is NULL. 140 <DATE><TIME>|<HOST>|I|testImage GetSet141 Following should generate error message 142 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 143 Error: image->numCols is less than 0.144 <DATE><TIME>|<HOST>|I|testImage GetSet145 Following should generate error message 146 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 147 Error: image->numRows is less than 0.148 <DATE><TIME>|<HOST>|I|testImage GetSet140 <DATE><TIME>|<HOST>|I|testImageSet 141 Following should generate error message 142 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 143 Error: image->numCols is 0 or less. 144 <DATE><TIME>|<HOST>|I|testImageSet 145 Following should generate error message 146 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 147 Error: image->numRows is 0 or less. 148 <DATE><TIME>|<HOST>|I|testImageSet 149 149 Following should generate error message 150 150 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 151 151 Error: image->row0 is less than 0. 152 <DATE><TIME>|<HOST>|I|testImage GetSet152 <DATE><TIME>|<HOST>|I|testImageSet 153 153 Following should generate error message 154 154 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 155 155 Error: image->col0 is less than 0. 156 <DATE><TIME>|<HOST>|I|testImage GetSet156 <DATE><TIME>|<HOST>|I|testImageSet 157 157 Following should generate error message 158 158 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 159 159 Invalid x-position 0. Position out of range (10-14) 160 <DATE><TIME>|<HOST>|I|testImage GetSet161 Following should generate error message 162 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 163 Invalid x-position 9. Position out of range (10-14) 164 <DATE><TIME>|<HOST>|I|testImage GetSet160 <DATE><TIME>|<HOST>|I|testImageSet 161 Following should generate error message 162 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 163 Invalid x-position 9. Position out of range (10-14) 164 <DATE><TIME>|<HOST>|I|testImageSet 165 165 Following should generate error message 166 166 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 167 167 Invalid x-position 15. Position out of range (10-14) 168 <DATE><TIME>|<HOST>|I|testImageGetSet 169 Following should generate error message 170 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 171 Invalid x-position 9. Position out of range (10-14) 172 173 ---> TESTPOINT PASSED (psImage{psImageGetSet} | tst_psImage.c) 174 168 <DATE><TIME>|<HOST>|I|testImageSet 169 Following should generate error message 170 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 171 Invalid x-position 9. Position out of range (10-14) 172 173 ---> TESTPOINT PASSED (psImage{psImageSet} | tst_psImage.c) 174 175 /***************************** TESTPOINT ******************************************\ 176 * TestFile: tst_psImage.c * 177 * TestPoint: psImage{psImageGet} * 178 * TestType: Positive * 179 \**********************************************************************************/ 180 181 <DATE><TIME>|<HOST>|I|testImageGet 182 Following should generate error message 183 <DATE><TIME>|<HOST>|E|psImageGet (FILE:LINENO) 184 Unallowable operation: psImage image or its data is NULL. 185 <DATE><TIME>|<HOST>|I|testImageGet 186 Following should generate error message 187 <DATE><TIME>|<HOST>|E|psImageGet (FILE:LINENO) 188 Error: image->numCols is 0 or less. 189 <DATE><TIME>|<HOST>|I|testImageGet 190 Following should generate error message 191 <DATE><TIME>|<HOST>|E|psImageGet (FILE:LINENO) 192 Error: image->numRows is 0 or less. 193 <DATE><TIME>|<HOST>|I|testImageGet 194 Following should generate error message 195 <DATE><TIME>|<HOST>|E|psImageGet (FILE:LINENO) 196 Error: image->row0 is less than 0. 197 <DATE><TIME>|<HOST>|I|testImageGet 198 Following should generate error message 199 <DATE><TIME>|<HOST>|E|psImageGet (FILE:LINENO) 200 Error: image->col0 is less than 0. 201 <DATE><TIME>|<HOST>|I|testImageGet 202 Following should generate error message 203 <DATE><TIME>|<HOST>|E|psImageGet (FILE:LINENO) 204 Invalid x-position 1. Position out of range (10-14) 205 <DATE><TIME>|<HOST>|I|testImageGet 206 Following should generate error message 207 <DATE><TIME>|<HOST>|E|psImageGet (FILE:LINENO) 208 Invalid x-position 9. Position out of range (10-14) 209 <DATE><TIME>|<HOST>|I|testImageGet 210 Following should generate error message 211 <DATE><TIME>|<HOST>|E|psImageGet (FILE:LINENO) 212 Invalid x-position 15. Position out of range (10-14) 213 <DATE><TIME>|<HOST>|I|testImageGet 214 Following should generate error message 215 <DATE><TIME>|<HOST>|E|psImageGet (FILE:LINENO) 216 Invalid x-position 9. Position out of range (10-14) 217 218 ---> TESTPOINT PASSED (psImage{psImageGet} | tst_psImage.c) 219
Note:
See TracChangeset
for help on using the changeset viewer.
