Changeset 3976 for trunk/psLib/test/image/tst_psImage.c
- Timestamp:
- May 18, 2005, 7:03:48 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImage.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImage.c
r3973 r3976 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-05-19 0 2:49:40$8 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-05-19 05:03:48 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 22 22 23 23 static psS32 testImageAlloc(void); 24 static psS32 testImageCopy(void);25 24 static psS32 testRegion(void); 26 25 … … 28 27 {testImageAlloc,546,"psImageAlloc",0,false}, 29 28 {testImageAlloc,548,"psImageFree",0,true}, 30 {testImageCopy,551,"psImageCopy",0,false}, 31 {testRegion,790,"psRegionAlloc",0,false}, 29 {testRegion,790,"psRegionSet",0,false}, 32 30 {testRegion,791,"psRegionFromString",0,true}, 33 31 {NULL} … … 237 235 } 238 236 239 psS32 testImageCopy(void)240 {241 psImage* img = NULL;242 psImage* img2 = NULL;243 psImage* img3 = NULL;244 psImage* img4 = NULL;245 psU32 c = 128;246 psU32 r = 256;247 248 img = psImageAlloc(c,r,PS_TYPE_F32);249 for (unsigned row=0;row<r;row++) {250 psF32* imgRow = img->data.F32[row];251 for (unsigned col=0;col<c;col++) {252 imgRow[col] = (psF32)(row+col);253 }254 }255 img2 = psImageAlloc(c,r,PS_TYPE_F32);256 for (unsigned row=0;row<r;row++) {257 psF32* img2Row = img2->data.F32[row];258 for (unsigned col=0;col<c;col++) {259 img2Row[col] = 0.0f;260 }261 }262 263 img3 = psImageCopy(img2,img,PS_TYPE_F32);264 265 // Verify the returned psImage structure pointer is equal to the input parameter output.266 if (img2 != img3) {267 psError(PS_ERR_UNKNOWN, true,"the image given for recycled wasn't");268 return 1;269 }270 271 // Verify the returned psImage structure is the same type as the input image structure272 // if the specified output argument is NULL.273 img4 = psImageCopy(NULL,img,PS_TYPE_F32);274 if (img4 == NULL) {275 psError(PS_ERR_UNKNOWN, true,"output image doesn't exist");276 return 4;277 }278 if (img4->type.type != img->type.type) {279 psError(PS_ERR_UNKNOWN, true,"output image is not the same type as input image");280 return 4;281 }282 for (psU32 row=0;row<r;row++) {283 psF32* imgInRow = img->data.F32[row];284 psF32* imgOutRow = img4->data.F32[row];285 for (unsigned col=0;col<c;col++) {286 if( imgInRow[col] != imgOutRow[col] ) {287 psError(PS_ERR_UNKNOWN, true,"Input image not equal to output image at %d,%d!",288 col, row);289 return 4;290 }291 }292 }293 294 // Verify the returned psImage structure member are equal to the values in295 // the input psImage structure input.296 297 #define testImageCopyType(IN,OUT) \298 img = psImageRecycle(img,c,r,PS_TYPE_##IN); \299 for (unsigned row=0;row<r;row++) { \300 ps##IN* imgRow = img->data.IN[row]; \301 for (unsigned col=0;col<c;col++) { \302 imgRow[col] = (ps##IN)(row+col); \303 } \304 } \305 img2 = psImageCopy(img2,img,PS_TYPE_##OUT); \306 if (img2 == NULL) { \307 psError(PS_ERR_UNKNOWN, true,"psImageCopy failed to copy U8."); \308 return 2; \309 } \310 for (psU32 row=0;row<r;row++) { \311 ps##IN* imgRow = img->data.IN[row]; \312 ps##OUT* img2Row = img2->data.OUT[row]; \313 for (psU32 col=0;col<c;col++) { \314 if (abs(imgRow[col] - (ps##IN)(row+col)) > 0.5) { \315 psError(PS_ERR_UNKNOWN, true,"Input image was changed at %d,%d!", \316 col,row); \317 return 2; \318 } \319 if (abs(img2Row[col] - (ps##OUT)(imgRow[col])) > 0.5) { \320 psError(PS_ERR_UNKNOWN, true,"returned psImage values after copy don't match at %d,%d " \321 "(%d vs %d)",\322 col,row,img2Row[col], (ps##OUT)(imgRow[col])); \323 return 2; \324 } \325 } \326 }327 328 #define testImageCopyTypes(IN) \329 printf("to psF32\n"); \330 testImageCopyType(IN,F32);\331 printf("to psF64\n"); \332 testImageCopyType(IN,F64); \333 printf("to psU8\n"); \334 testImageCopyType(IN,U8); \335 printf("to psU16\n"); \336 testImageCopyType(IN,U16); \337 printf("to psU32\n"); \338 testImageCopyType(IN,U32); \339 printf("to psS8\n"); \340 testImageCopyType(IN,S8);\341 printf("to psS16\n"); \342 testImageCopyType(IN,S16);\343 printf("to psS32\n"); \344 testImageCopyType(IN,S32);345 346 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU8");347 testImageCopyTypes(U8);348 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU16");349 testImageCopyTypes(U16);350 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU32");351 testImageCopyTypes(U32);352 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS8");353 testImageCopyTypes(S8);354 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS16");355 testImageCopyTypes(S16);356 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS32");357 testImageCopyTypes(S32);358 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psF32");359 testImageCopyTypes(F32);360 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psF64");361 testImageCopyTypes(F64);362 363 // Verify the returned psImage structure pointer is null and program364 // execution doesn't stop, if the input parameter input is null.365 psLogMsg(__func__,PS_LOG_INFO,"An error should follow...");366 img3 = psImageCopy(NULL,NULL,PS_TYPE_F32);367 if (img3 != NULL) {368 psError(PS_ERR_UNKNOWN, true,"psImageCopy didn't return NULL when input image was NULL.");369 return 3;370 }371 372 psFree(img);373 psFree(img2);374 psFree(img3);375 psFree(img4);376 377 return 0;378 }379 380 237 static psS32 testRegion(void) 381 238 { … … 385 242 // Testpoint #790 386 243 387 psRegion * region = psRegionAlloc(1,2,3,4);244 psRegion region = psRegionSet(1,2,3,4); 388 245 389 246 testNum++; 390 if (region == NULL) { 391 psError(PS_ERR_UNKNOWN, false, 392 "psRegionAlloc returned a NULL pointer."); 393 return testNum; 394 } 395 396 testNum++; 397 if (region->x0 != 1 || region->x1 != 2 || region->y0 != 3 || region->y1 != 4) { 247 if (region.x0 != 1 || region.x1 != 2 || region.y0 != 3 || region.y1 != 4) { 398 248 psError(PS_ERR_UNKNOWN, false, 399 249 "The region attributes are not set properly (%s)", … … 402 252 } 403 253 404 psFree(region);405 406 254 // Testpoint #791 407 255 … … 409 257 410 258 testNum++; 411 if (region == NULL) { 412 psError(PS_ERR_UNKNOWN, false, 413 "psRegionFromString returned a NULL pointer."); 414 return testNum; 415 } 416 417 testNum++; 418 if (region->x0 != 1 || region->x1 != 2 || region->y0 != 3 || region->y1 != 4) { 259 if (region.x0 != 1 || region.x1 != 2 || region.y0 != 3 || region.y1 != 4) { 419 260 psError(PS_ERR_UNKNOWN, false, 420 261 "The region attributes are not set properly (%s)", … … 423 264 } 424 265 425 psFree(region);426 266 region = psRegionFromString("[1:2,3:]"); 427 267 428 268 testNum++; 429 if ( region != NULL) {269 if (! isnan(region.x0)) { 430 270 psError(PS_ERR_UNKNOWN, false, 431 271 "psRegionFromString returned a non-NULL pointer given a malformed string.");
Note:
See TracChangeset
for help on using the changeset viewer.
