Changeset 6574
- Timestamp:
- Mar 13, 2006, 4:22:55 PM (20 years ago)
- Location:
- trunk/psLib
- Files:
-
- 3 edited
-
src/mathtypes/psImage.c (modified) (2 diffs)
-
test/mathtypes/tst_psImage.c (modified) (2 diffs)
-
test/mathtypes/verified/tst_psImage.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psImage.c
r6331 r6574 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.9 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-0 2-06 22:19:28$11 * @version $Revision: 1.96 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-03-14 02:22:55 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 291 291 double complex value) 292 292 { 293 if (image == NULL) { 294 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL); 293 /* if (image == NULL) { 294 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL); 295 return false; 296 } 297 if (x >= image->numRows || y >= image->numCols) { 298 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 299 "Invalid position %d. Position out of range (%d-%d)\n", x, ); 300 return false; 301 } 302 303 if(x < 0) 304 x += image->numRows; 305 if(x < 0) { 306 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x. Negative number too large\n"); 307 return false; 308 } 309 310 if(y < 0) 311 y += image->numCols; 312 if(y < 0) { 313 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y. Negative number too large\n"); 314 return false; 315 } 316 317 */ 318 PS_ASSERT_IMAGE_NON_NULL(image, false); 319 PS_ASSERT_INT_NONNEGATIVE(image->col0, false); 320 PS_ASSERT_INT_NONNEGATIVE(image->row0, false); 321 PS_ASSERT_INT_NONNEGATIVE(image->numCols, false); 322 PS_ASSERT_INT_NONNEGATIVE(image->numRows, false); 323 if ( x >= (image->col0 + image->numCols) ) { 324 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 325 "Invalid x-position %d. Position out of range (%d-%d)\n", 326 x, image->col0, image->numCols+image->col0-1 ); 295 327 return false; 296 } 297 if (x >= image->numRows || y >= image->numCols) { 298 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position. Position too large\n"); 328 } else if ( y >= (image->row0 + image->numRows) ) { 329 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 330 "Invalid y-position %d. Position out of range (%d-%d)\n", 331 y, image->row0, image->numRows+image->row0-1 ); 299 332 return false; 300 } 301 302 if(x < 0) 303 x += image->numRows; 304 if(x < 0) { 305 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x. Negative number too large\n"); 333 } else if (x < image->col0 && x >= 0) { 334 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 335 "Invalid x-position %d. Position out of range (%d-%d)\n", 336 x, image->col0, image->numCols+image->col0-1 ); 306 337 return false; 307 } 308 309 if(y < 0) 310 y += image->numCols; 311 if(y < 0) { 312 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y. Negative number too large\n"); 338 } else if (y < image->row0 && y >= 0) { 339 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 340 "Invalid y-position %d. Position out of range (%d-%d)\n", 341 y, image->row0, image->numRows+image->row0-1 ); 313 342 return false; 343 } else if (x < 0 || y < 0) { 344 if (x < 0) { 345 x += image->numCols; 346 } 347 if (x < 0) { 348 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 349 "Invalid x-position %d. Position out of range (%d-%d)\n", 350 (x+image->col0), image->col0, image->numCols+image->col0-1 ); 351 return false; 352 } 353 if (y < 0) { 354 y += image->numRows; 355 } 356 if (y < 0) { 357 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 358 "Invalid y-position %d. Position out of range (%d-%d)\n", 359 (y+image->row0), image->row0, image->numRows+image->row0-1 ); 360 return false; 361 } 362 } else { 363 x -= image->col0; 364 y -= image->row0; 314 365 } 315 366 -
trunk/psLib/test/mathtypes/tst_psImage.c
r5174 r6574 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $9 * @date $Date: 200 5-09-29 01:15:38$8 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-03-14 02:22:55 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 361 361 image = psImageAlloc(5, 5, PS_TYPE_S32); 362 362 363 if ( !psImageSet(image, 0, 0, 10) ) 364 fprintf(stderr, "ImageSet failed to set S32 at position 0\n"); 365 if ( psImageSet(image, 10, 10, 100) ) 366 fprintf(stderr, "ImageSet Improperly set S32 at out of range position\n"); 367 if ( !psImageSet(image, -1, -1, 4) ) 368 fprintf(stderr, "ImageSet Failed to set S32 at position 4,4\n"); 369 if ( (psS32)psImageGet(image, 0, 0) != 10 ) 370 fprintf(stderr, "ImageGet Failed to return the correct S32 from position 0,0\n"); 371 if ( (psS32)psImageGet(image, -1, -1) != 4 ) 372 fprintf(stderr, "ImageGet Failed to return the correct S32 from tail using -1,-1\n"); 363 //Set the position of the subimage relative to the parent. 364 image->col0 = 10; 365 image->row0 = 10; 366 for (int i = 0; i < 5; i++) { 367 for (int j = 0; j < 5; j++) { 368 image->data.S32[i][j] = i+j; 369 } 370 } 371 372 //Attempt to set a position in a NULL psImage* 373 psImage *none = NULL; 374 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 375 if ( psImageSet(none, 1, 1, 1) ) { 376 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 377 "psImageSet failed to return false when passed a NULL image.\n"); 378 return 1; 379 } 380 381 //Attempt to set a position in a psImage* with negative numCols, numRows 382 none = psImageAlloc(2, 2, PS_TYPE_S32); 383 *(int*)&none->numCols = -1; 384 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 385 if ( psImageSet(none, 1, 1, 1) ) { 386 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 387 "psImageSet failed to return false when passed an image with negative numCols.\n"); 388 return 2; 389 } 390 *(int*)&none->numCols = 2; 391 *(int*)&none->numRows = -1; 392 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 393 if ( psImageSet(none, 1, 1, 1) ) { 394 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 395 "psImageSet failed to return false when passed an image with negative numRows.\n"); 396 return 3; 397 } 398 399 //Attempt to set a position in a psImage* with negative col0, row0 400 *(int*)&none->numRows = 2; 401 none->row0 = -1; 402 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 403 if ( psImageSet(none, 1, 1, 1) ) { 404 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 405 "psImageSet failed to return false when passed an image with negative col0.\n"); 406 return 4; 407 } 408 none->row0 = 0; 409 none->col0 = -1; 410 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 411 if ( psImageSet(none, 1, 1, 1) ) { 412 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 413 "psImageSet failed to return false when passed an image with negative col0.\n"); 414 return 5; 415 } 416 psFree(none); 417 418 //Try to set a position inside of the subimage. 419 if ( !psImageSet(image, 13, 14, 666) ) { 420 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 421 "psImageSet failed to return true when passed valid parameters.\n"); 422 return 6; 423 } else if (image->data.S32[3][4] != 666) { 424 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 425 "psImageSet failed to set the data values correctly.\n"); 426 return 7; 427 } 428 //Try to set a position inside of the subimage from the tail. 429 if ( !psImageSet(image, -1, -1, 666) ) { 430 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 431 "psImageSet failed to return true when passed valid parameters.\n"); 432 return 8; 433 } else if (image->data.S32[4][4] != 666) { 434 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 435 "psImageSet failed to set (from the tail) the data values correctly.\n"); 436 printf("\n value at 14,14 is %d\n", image->data.S32[4][4]); 437 return 9; 438 } 439 440 //Try to set a position outside of the subimage but inside of the parent image. 441 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 442 if ( psImageSet(image, 0, 0, 666) ) { 443 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 444 "psImageSet failed to return false when passed an invalid location.\n"); 445 return 10; 446 } 447 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 448 if ( psImageSet(image, 9, 10, 666) ) { 449 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 450 "psImageSet failed to return false when passed an invalid location.\n"); 451 return 11; 452 } 453 454 //Try to set a position outside of the subimage. 455 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 456 if ( psImageSet(image, 15, 14, 666) ) { 457 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 458 "psImageSet failed to return false when passed an invalid location.\n"); 459 return 12; 460 } 461 //Try to set a position outside of the subimage, indexing from the tail. 462 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 463 if ( psImageSet(image, -6, -1, 666) ) { 464 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 465 "psImageSet failed to return false when passed an invalid location.\n"); 466 return 13; 467 } 468 373 469 374 470 psFree(image); -
trunk/psLib/test/mathtypes/verified/tst_psImage.stderr
r5572 r6574 134 134 \**********************************************************************************/ 135 135 136 <DATE><TIME>|<HOST>|I|testImageGetSet 137 Following should generate error message 136 138 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 137 Invalid position. Position too large 139 Unallowable operation: psImage image or its data is NULL. 140 <DATE><TIME>|<HOST>|I|testImageGetSet 141 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|testImageGetSet 145 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|testImageGetSet 149 Following should generate error message 150 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 151 Error: image->row0 is less than 0. 152 <DATE><TIME>|<HOST>|I|testImageGetSet 153 Following should generate error message 154 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 155 Error: image->col0 is less than 0. 156 <DATE><TIME>|<HOST>|I|testImageGetSet 157 Following should generate error message 158 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 159 Invalid x-position 0. Position out of range (10-14) 160 <DATE><TIME>|<HOST>|I|testImageGetSet 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|testImageGetSet 165 Following should generate error message 166 <DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO) 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) 138 172 139 173 ---> TESTPOINT PASSED (psImage{psImageGetSet} | tst_psImage.c)
Note:
See TracChangeset
for help on using the changeset viewer.
