Changeset 3976
- Timestamp:
- May 18, 2005, 7:03:48 PM (21 years ago)
- Location:
- trunk/psLib/test
- Files:
-
- 4 added
- 4 edited
-
astronomy/tst_psAstrometry01.c (modified) (7 diffs)
-
image/tst_psImage.c (modified) (8 diffs)
-
image/tst_psImageStructManip.c (modified) (24 diffs)
-
image/verified/tst_psImage.stderr (modified) (3 diffs)
-
image/verified/tst_psImageGeomManip.stderr (added)
-
image/verified/tst_psImagePixelExtract.stderr (added)
-
image/verified/tst_psImagePixelManip.stderr (added)
-
image/verified/tst_psImageStructManip.stderr (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astronomy/tst_psAstrometry01.c
r3883 r3976 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-05-1 1 22:00:35$7 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-05-19 05:03:48 $ 9 9 * 10 10 * XXX: Must test … … 719 719 psPlaneTransform *trans3 = NULL; 720 720 setCoeffs(trans1, trans2); 721 trans3 = psPlaneTransformCombine(NULL, trans1, trans2); 721 trans3 = psPlaneTransformCombine(NULL, trans1, trans2,psRegionSet(NAN,NAN,NAN,NAN),0); 722 //XXX: the last two parameters are bogus. Needs to change. -rdd 722 723 723 724 if (trans3 == NULL) { … … 749 750 printf("----------------------------------------------------------------------------------\n"); 750 751 printf("Calling psPlaneTransformCombine with NULL trans1. Should generate error and return NULL.\n"); 751 trans3 = psPlaneTransformCombine(NULL, NULL, trans2 );752 trans3 = psPlaneTransformCombine(NULL, NULL, trans2, psRegionSet(0,0,0,0), 10); 752 753 if (trans3 != NULL) { 753 754 printf("TEST ERROR: psPlaneTransformCombine() returned a non-NULL psPlaneTransform.\n"); … … 758 759 printf("----------------------------------------------------------------------------------\n"); 759 760 printf("Calling psPlaneTransformCombine with NULL trans2. Should generate error and return NULL.\n"); 760 trans3 = psPlaneTransformCombine(NULL, trans1, NULL );761 trans3 = psPlaneTransformCombine(NULL, trans1, NULL, psRegionSet(0,0,0,0), 10); 761 762 if (trans3 != NULL) { 762 763 printf("TEST ERROR: psPlaneTransformCombine() returned a non-NULL psPlaneTransform.\n"); … … 908 909 psPlaneTransform *trans = psPlaneTransformAlloc(2, 2); 909 910 psPlaneTransform *transOut = NULL; 910 psRegion *myRegion = psRegionAlloc(1.0, 5.0, 1.0, 5.0);911 psRegion myRegion = psRegionSet(1.0, 5.0, 1.0, 5.0); 911 912 912 913 // … … 931 932 } 932 933 933 printf("----------------------------------------------------------------------------------\n");934 printf("Calling psPlaneTransformInvert with NULL psRegion. Should generate error and return NULL.\n");935 transOut = psPlaneTransformInvert(NULL, trans, NULL, 10);936 if (transOut != NULL) {937 printf("TEST ERROR: psPlaneTransformInvert() returned a non-NULL psPlaneTransform.\n");938 testStatus = false;939 psFree(transOut);940 }941 934 printf("----------------------------------------------------------------------------------\n"); 942 935 printf("Calling psPlaneTransformInvert with zero nSamples. Should generate error and return NULL.\n"); … … 988 981 989 982 psFree(trans); 990 psFree(myRegion);991 983 992 984 fflush(stdout); -
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."); -
trunk/psLib/test/image/tst_psImageStructManip.c
r3973 r3976 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-05-19 0 2:49:40$8 * @version $Revision: 1.2 $ $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 … … 19 19 20 20 static psS32 testImageSubset(void); 21 static psS32 testImage Subsection(void);21 static psS32 testImageCopy(void); 22 22 static psS32 testImageTrim(void); 23 23 … … 26 26 {testImageSubset,547,"psImageSubset",0,false}, 27 27 {testImageSubset,550,"psImageSubset",0,true}, 28 {testImage Subsection,730,"psImageSubsection",0,false},28 {testImageCopy,551,"psImageCopy",0,false}, 29 29 {testImageTrim, 744, "psImageTrim", 0, false}, 30 30 {NULL} … … 46 46 psS32 c = 128; 47 47 psS32 r = 256; 48 psRegion region1 = {0,0,c/2,r/2};49 psRegion region2 = {c/4,r/4,c/4+c/2,r/4+r/2};48 psRegion region1 = psRegionSet(0,c/2,0,r/2); 49 psRegion region2 = psRegionSet(c/4,c/4+c/2,r/4,r/4+r/2); 50 50 51 51 original = psImageAlloc(c,r,PS_TYPE_U32); … … 168 168 memcpy(&preSubsetStruct,original,sizeof(psImage)); 169 169 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 170 subset1 = psImageSubset(original,(psRegion) { 171 0,r/2,c/2,r/2 172 } 173 ); 170 subset1 = psImageSubset(original, psRegionSet(0,c/2,r/2,r/2)); 174 171 if (subset1 != NULL) { 175 172 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when numRows=0."); … … 177 174 } 178 175 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 179 subset1 = psImageSubset(original,(psRegion) { 180 c/2,0,c/2,r/2 181 } 182 ); 176 subset1 = psImageSubset(original,psRegionSet(c/2,c/2,0,r/2)); 183 177 if (subset1 != NULL) { 184 178 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when numCols=0."); … … 196 190 197 191 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 198 subset1 = psImageSubset(original,(psRegion) { 199 0,0,c/2,r*2 200 } 201 ); 192 subset1 = psImageSubset(original, psRegionSet(0,c/2, 0,r*2)); 202 193 if (subset1 != NULL) { 203 194 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of " … … 206 197 } 207 198 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 208 subset1 = psImageSubset(original,(psRegion) { 209 0,0,c*2,r/2 210 } 211 ); 199 subset1 = psImageSubset(original,psRegionSet(0,c*2,0,r/2)); 212 200 if (subset1 != NULL) { 213 201 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of " … … 216 204 } 217 205 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 218 subset1 = psImageSubset(original,(psRegion) { 219 -1,0,c/2,r/2 220 } 221 ); 206 subset1 = psImageSubset(original, psRegionSet(-1,c/2,0,r/2)); 222 207 if (subset1 != NULL) { 223 208 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of " … … 226 211 } 227 212 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 228 subset1 = psImageSubset(original,(psRegion) { 229 0,-1,c/2,r/2 230 } 231 ); 213 subset1 = psImageSubset(original, psRegionSet(0,c/2,-1,r/2)); 232 214 if (subset1 != NULL) { 233 215 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of " … … 242 224 243 225 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 244 subset1 = psImageSubset(original,(psRegion) { 245 0,0,c/2,r+1 246 } 247 ); 226 subset1 = psImageSubset(original,psRegionSet(0,c/2,0,r+1)); 248 227 if (subset1 != NULL) { 249 228 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via rows)."); … … 251 230 } 252 231 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 253 subset1 = psImageSubset(original,(psRegion) { 254 0,0,c+1,r/2 255 } 256 ); 232 subset1 = psImageSubset(original, psRegionSet(0,c+1,0,r/2)); 257 233 if (subset1 != NULL) { 258 234 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via cols)."); … … 260 236 } 261 237 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 262 subset1 = psImageSubset(original,(psRegion) { 263 0,0,c+1,r+1 264 } 265 ); 238 subset1 = psImageSubset(original,psRegionSet(0,c+1,0,r+1)); 266 239 if (subset1 != NULL) { 267 240 psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via row+cols)."); … … 298 271 } 299 272 300 // #730: psImageSubsection shall create child image of a specified size from a parent psImage structure 301 psS32 testImageSubsection(void) 273 psS32 testImageCopy(void) 302 274 { 303 psImage* original; 304 psImage* subset; 305 psS32 c = 128; 306 psS32 r = 256; 307 psS32 i; 308 psS32 numRegions = 4; 309 psS32 x1[] = { 0, 32, 64, 32}; 310 psS32 x2[] = { 32, 64,127, 64}; 311 psS32 y1[] = { 0, 32, 32,128}; 312 psS32 y2[] = { 32, 64, 64,255}; 313 314 original = psImageAlloc(c,r,PS_TYPE_U32); 315 for (psS32 row=0;row<r;row++) { 316 for (psS32 col=0;col<c;col++) { 317 original->data.F32[row][col] = row*1000+col; 318 } 319 } 320 321 for (i=0; i<numRegions; i++) { 322 char sectionStr[64]; 323 sprintf(sectionStr,"[%d:%d,%d:%d]",x1[i],x2[i],y1[i],y2[i]); 324 325 psLogMsg(__func__,PS_LOG_INFO,"Testing subsection %s.", 326 sectionStr); 327 328 subset = psImageSubsection(original,sectionStr); 329 330 if (subset == NULL) { 331 psError(PS_ERR_UNKNOWN,true,"psImageSubsection returned a NULL with a subset of %s.", 332 sectionStr); 333 return 10*i+1; 334 } 335 336 if (subset->type.type != PS_TYPE_U32) { 337 psError(PS_ERR_UNKNOWN,true,"psImageSubsection output type was not proper(%d, should be %d).", 338 subset->type.type, PS_TYPE_U32); 339 return 10*i+2; 340 } 341 342 if (subset->col0 != x1[i] || subset->row0 != y1[i]) { 343 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set properly col0/row0 (%d/%d, should be %d/%d).", 344 subset->col0,subset->row0,x1[i],y1[i]); 345 return 10*i+3; 346 } 347 348 if (subset->parent != original) { 349 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set parent."); 350 return 10*i+4; 351 } 352 353 if (subset->children != NULL) { 354 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't set children to NULL."); 355 return 10*i+5; 356 } 357 358 if (original->children == NULL || original->children->n != i+1) { 359 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't increment number of children by one per subset."); 360 return 10*i+6; 361 } 362 363 364 if (original->children->data[i] != subset) { 365 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't properly store the children pointer."); 366 return 10*i+7; 367 } 368 369 psS32 numCols = x2[i]-x1[i]+1; 370 psS32 numRows = y2[i]-y1[i]+1; 371 if (subset->numCols != numCols || subset->numRows != numRows) { 372 psError(PS_ERR_UNKNOWN,true,"psImageSubsection output size was not proper(%dx%d, should be %dx%d).", 373 subset->numCols, subset->numRows, numCols, numRows); 374 return 10*i+8; 375 } 376 377 for (psS32 row=0;row<numRows;row++) { 378 for (psS32 col=0;col<numCols;col++) { 379 if (subset->data.U32[row][col] != original->data.U32[row+y1[i]][col+x1[i]]) { 380 psError(PS_ERR_UNKNOWN,true,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).", 381 row,col,subset->data.U32[row][col], original->data.U32[row+y1[i]][col+x1[i]]); 382 return 10*i+9; 383 } 275 psImage* img = NULL; 276 psImage* img2 = NULL; 277 psImage* img3 = NULL; 278 psImage* img4 = NULL; 279 psU32 c = 128; 280 psU32 r = 256; 281 282 img = psImageAlloc(c,r,PS_TYPE_F32); 283 for (unsigned row=0;row<r;row++) { 284 psF32* imgRow = img->data.F32[row]; 285 for (unsigned col=0;col<c;col++) { 286 imgRow[col] = (psF32)(row+col); 287 } 288 } 289 img2 = psImageAlloc(c,r,PS_TYPE_F32); 290 for (unsigned row=0;row<r;row++) { 291 psF32* img2Row = img2->data.F32[row]; 292 for (unsigned col=0;col<c;col++) { 293 img2Row[col] = 0.0f; 294 } 295 } 296 297 img3 = psImageCopy(img2,img,PS_TYPE_F32); 298 299 // Verify the returned psImage structure pointer is equal to the input parameter output. 300 if (img2 != img3) { 301 psError(PS_ERR_UNKNOWN, true,"the image given for recycled wasn't"); 302 return 1; 303 } 304 305 // Verify the returned psImage structure is the same type as the input image structure 306 // if the specified output argument is NULL. 307 img4 = psImageCopy(NULL,img,PS_TYPE_F32); 308 if (img4 == NULL) { 309 psError(PS_ERR_UNKNOWN, true,"output image doesn't exist"); 310 return 4; 311 } 312 if (img4->type.type != img->type.type) { 313 psError(PS_ERR_UNKNOWN, true,"output image is not the same type as input image"); 314 return 4; 315 } 316 for (psU32 row=0;row<r;row++) { 317 psF32* imgInRow = img->data.F32[row]; 318 psF32* imgOutRow = img4->data.F32[row]; 319 for (unsigned col=0;col<c;col++) { 320 if( imgInRow[col] != imgOutRow[col] ) { 321 psError(PS_ERR_UNKNOWN, true,"Input image not equal to output image at %d,%d!", 322 col, row); 323 return 4; 384 324 } 385 325 } 386 326 } 387 327 388 psLogMsg(__func__,PS_LOG_INFO,"An error should follow (x1>x2)"); 389 subset = psImageSubsection(original,"[64:32,32:64]"); 390 if (subset != NULL) { 391 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't return NULL when x1 > x2."); 392 return 10*i+10; 393 } 394 395 psLogMsg(__func__,PS_LOG_INFO,"An error should follow (y1>y2)"); 396 subset = psImageSubsection(original,"[32:64,64:32]"); 397 if (subset != NULL) { 398 psError(PS_ERR_UNKNOWN,true,"psImageSubsection didn't return NULL when y1 > y2."); 399 return 10*i+11; 400 } 401 402 psLogMsg(__func__,PS_LOG_INFO,"An error should follow (x2>nCols)"); 403 subset = psImageSubsection(original,"[64:256,32:64]"); // assumes c<256 404 if (subset != NULL) { 405 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when x2 > c."); 406 return 10*i+12; 407 } 408 409 psLogMsg(__func__,PS_LOG_INFO,"An error should follow (y2>=nRows)"); 410 subset = psImageSubsection(original,"[32:64,64:256]"); // assumes r==256 411 if (subset != NULL) { 412 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when y2 > r."); 413 return 10*i+13; 414 } 415 416 psLogMsg(__func__,PS_LOG_INFO,"An error should follow (malformed string - no brackets)"); 417 subset = psImageSubsection(original,"32:64,32:64"); 418 if (subset != NULL) { 419 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was '32:64,32:64'."); 420 return 10*i+14; 421 } 422 423 psLogMsg(__func__,PS_LOG_INFO,"An error should follow (malformed string - no colons)"); 424 subset = psImageSubsection(original,"[32-64,32-64]"); 425 if (subset != NULL) { 426 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was '[32-64,32-64]'."); 427 return 10*i+15; 428 } 429 430 psLogMsg(__func__,PS_LOG_INFO,"An error should follow (malformed string - not four numbers)"); 431 subset = psImageSubsection(original,"[32:64,32]"); 432 if (subset != NULL) { 433 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was '[32:64,32]'."); 434 return 10*i+16; 435 } 436 437 psLogMsg(__func__,PS_LOG_INFO,"An error should follow (image is NULL)"); 438 subset = psImageSubsection(NULL,"[32:64,32:64]"); 439 if (subset != NULL) { 440 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when image was NULL."); 441 return 10*i+17; 442 } 443 444 psLogMsg(__func__,PS_LOG_INFO,"An error should follow (subsection string is NULL)"); 445 subset = psImageSubsection(original,NULL); 446 if (subset != NULL) { 447 psError(PS_ERR_UNKNOWN, true,"psImageSubsection didn't return NULL when subsection was NULL."); 448 return 10*i+18; 449 } 450 451 psFree(original); 328 // Verify the returned psImage structure member are equal to the values in 329 // the input psImage structure input. 330 331 #define testImageCopyType(IN,OUT) \ 332 img = psImageRecycle(img,c,r,PS_TYPE_##IN); \ 333 for (unsigned row=0;row<r;row++) { \ 334 ps##IN* imgRow = img->data.IN[row]; \ 335 for (unsigned col=0;col<c;col++) { \ 336 imgRow[col] = (ps##IN)(row+col); \ 337 } \ 338 } \ 339 img2 = psImageCopy(img2,img,PS_TYPE_##OUT); \ 340 if (img2 == NULL) { \ 341 psError(PS_ERR_UNKNOWN, true,"psImageCopy failed to copy U8."); \ 342 return 2; \ 343 } \ 344 for (psU32 row=0;row<r;row++) { \ 345 ps##IN* imgRow = img->data.IN[row]; \ 346 ps##OUT* img2Row = img2->data.OUT[row]; \ 347 for (psU32 col=0;col<c;col++) { \ 348 if (abs(imgRow[col] - (ps##IN)(row+col)) > 0.5) { \ 349 psError(PS_ERR_UNKNOWN, true,"Input image was changed at %d,%d!", \ 350 col,row); \ 351 return 2; \ 352 } \ 353 if (abs(img2Row[col] - (ps##OUT)(imgRow[col])) > 0.5) { \ 354 psError(PS_ERR_UNKNOWN, true,"returned psImage values after copy don't match at %d,%d " \ 355 "(%d vs %d)",\ 356 col,row,img2Row[col], (ps##OUT)(imgRow[col])); \ 357 return 2; \ 358 } \ 359 } \ 360 } 361 362 #define testImageCopyTypes(IN) \ 363 printf("to psF32\n"); \ 364 testImageCopyType(IN,F32);\ 365 printf("to psF64\n"); \ 366 testImageCopyType(IN,F64); \ 367 printf("to psU8\n"); \ 368 testImageCopyType(IN,U8); \ 369 printf("to psU16\n"); \ 370 testImageCopyType(IN,U16); \ 371 printf("to psU32\n"); \ 372 testImageCopyType(IN,U32); \ 373 printf("to psS8\n"); \ 374 testImageCopyType(IN,S8);\ 375 printf("to psS16\n"); \ 376 testImageCopyType(IN,S16);\ 377 printf("to psS32\n"); \ 378 testImageCopyType(IN,S32); 379 380 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU8"); 381 testImageCopyTypes(U8); 382 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU16"); 383 testImageCopyTypes(U16); 384 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psU32"); 385 testImageCopyTypes(U32); 386 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS8"); 387 testImageCopyTypes(S8); 388 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS16"); 389 testImageCopyTypes(S16); 390 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psS32"); 391 testImageCopyTypes(S32); 392 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psF32"); 393 testImageCopyTypes(F32); 394 psLogMsg(__func__,PS_LOG_INFO,"Image Copy Test for psF64"); 395 testImageCopyTypes(F64); 396 397 // Verify the returned psImage structure pointer is null and program 398 // execution doesn't stop, if the input parameter input is null. 399 psLogMsg(__func__,PS_LOG_INFO,"An error should follow..."); 400 img3 = psImageCopy(NULL,NULL,PS_TYPE_F32); 401 if (img3 != NULL) { 402 psError(PS_ERR_UNKNOWN, true,"psImageCopy didn't return NULL when input image was NULL."); 403 return 3; 404 } 405 406 psFree(img); 407 psFree(img2); 408 psFree(img3); 409 psFree(img4); 452 410 453 411 return 0; … … 462 420 psS32 halfR = r/2; 463 421 psS32 halfC = c/2; 464 psRegion centerHalf = {qtrC,qtr R,qtrC+halfC,qtrR+halfR};422 psRegion centerHalf = {qtrC,qtrC+halfC,qtrR,qtrR+halfR}; 465 423 466 424 psImage* image = psImageAlloc(c,r,PS_TYPE_F32); … … 517 475 */ 518 476 image1 = psImageCopy(image1,image,PS_TYPE_F32); 519 image2 = psImageTrim(image1,(psRegion) { 520 qtrC,qtrR,0,0 521 } 522 ); 477 image2 = psImageTrim(image1,psRegionSet(qtrC,0,qtrR,0)); 523 478 524 479 if (image1 != image2) { … … 559 514 */ 560 515 image1 = psImageCopy(image1,image,PS_TYPE_F32); 561 image2 = psImageTrim(image1,(psRegion) { 562 qtrC,qtrR,-qtrC,-qtrR 563 } 564 ); 516 image2 = psImageTrim(image1,psRegionSet(qtrC,-qtrC, qtrR,-qtrR)); 565 517 566 518 if (image1 != image2) { … … 602 554 */ 603 555 604 image2 = psImageTrim(NULL,(psRegion) { 605 qtrC,qtrR,0,0 606 } 607 ); 556 image2 = psImageTrim(NULL, psRegionSet(qtrC,0,qtrR,0)); 608 557 609 558 if (image2 != NULL) { … … 622 571 623 572 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 624 image2 = psImageTrim(image1,(psRegion) { 625 -1,0,0,0 626 } 627 ); 573 image2 = psImageTrim(image1, psRegionSet(-1,0,0,0)); 628 574 629 575 if (image2 != NULL) { … … 642 588 643 589 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 644 image2 = psImageTrim(image1,(psRegion) { 645 0,-1,0,0 646 } 647 ); 590 image2 = psImageTrim(image1, psRegionSet(0,0,-1,0)); 648 591 649 592 if (image2 != NULL) { … … 662 605 663 606 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 664 image2 = psImageTrim(image1,(psRegion) { 665 0,0,image->numCols+1,0 666 } 667 ); 607 image2 = psImageTrim(image1, psRegionSet(0,image->numCols+1,0,0)); 668 608 669 609 if (image2 != NULL) { … … 682 622 683 623 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 684 image2 = psImageTrim(image1,(psRegion) { 685 0,0,0,image->numRows+1 686 } 687 ); 624 image2 = psImageTrim(image1, psRegionSet(0,0,0,image->numRows+1)); 688 625 689 626 if (image2 != NULL) { … … 702 639 703 640 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 704 image2 = psImageTrim(image1,(psRegion) { 705 0,0,-image->numCols,0 706 } 707 ); 641 image2 = psImageTrim(image1, psRegionSet(0,-image->numCols,0,0)); 708 642 709 643 if (image2 != NULL) { … … 722 656 723 657 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 724 image2 = psImageTrim(image1,(psRegion) { 725 0,0,0,-image->numRows 726 } 727 ); 658 image2 = psImageTrim(image1, psRegionSet(0,0,0,-image->numRows)); 728 659 729 660 if (image2 != NULL) { -
trunk/psLib/test/image/verified/tst_psImage.stderr
r3682 r3976 79 79 <DATE><TIME>|<HOST>|E|psImageAlloc (FILE:LINENO) 80 80 Specified number of rows (0) or columns (0) is invalid. 81 <DATE><TIME>|<HOST>|E|imageSubset (FILE:LINENO) 82 Specified subset range, [50:99,70:19], is invalid or outside input psImage's boundaries, [0:99,0:99]. 83 <DATE><TIME>|<HOST>|E|imageSubset (FILE:LINENO) 84 Specified subset range, [70:19,90:39], is invalid or outside input psImage's boundaries, [0:99,0:99]. 81 85 82 86 ---> TESTPOINT PASSED (psImage{psImageAlloc} | tst_psImage.c) … … 84 88 /***************************** TESTPOINT ******************************************\ 85 89 * TestFile: tst_psImage.c * 86 * TestPoint: psImage{psImageCopy} * 87 * TestType: Positive * 88 \**********************************************************************************/ 89 90 <DATE><TIME>|<HOST>|I|testImageCopy 91 Image Copy Test for psU8 92 <DATE><TIME>|<HOST>|I|testImageCopy 93 Image Copy Test for psU16 94 <DATE><TIME>|<HOST>|I|testImageCopy 95 Image Copy Test for psU32 96 <DATE><TIME>|<HOST>|I|testImageCopy 97 Image Copy Test for psS8 98 <DATE><TIME>|<HOST>|I|testImageCopy 99 Image Copy Test for psS16 100 <DATE><TIME>|<HOST>|I|testImageCopy 101 Image Copy Test for psS32 102 <DATE><TIME>|<HOST>|I|testImageCopy 103 Image Copy Test for psF32 104 <DATE><TIME>|<HOST>|I|testImageCopy 105 Image Copy Test for psF64 106 <DATE><TIME>|<HOST>|I|testImageCopy 107 An error should follow... 108 <DATE><TIME>|<HOST>|E|psImageCopy (FILE:LINENO) 109 Can not operate on a NULL psImage. 110 111 ---> TESTPOINT PASSED (psImage{psImageCopy} | tst_psImage.c) 112 113 /***************************** TESTPOINT ******************************************\ 114 * TestFile: tst_psImage.c * 115 * TestPoint: psImage{psRegionAlloc} * 90 * TestPoint: psImage{psRegionSet} * 116 91 * TestType: Positive * 117 92 \**********************************************************************************/ … … 120 95 Specified subsection string, '[1:2,3:]', can not be parsed. Must be in the form '[x1:x2,y1:y2]'. 121 96 122 ---> TESTPOINT PASSED (psImage{psRegion Alloc} | tst_psImage.c)97 ---> TESTPOINT PASSED (psImage{psRegionSet} | tst_psImage.c) 123 98
Note:
See TracChangeset
for help on using the changeset viewer.
