IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3976


Ignore:
Timestamp:
May 18, 2005, 7:03:48 PM (21 years ago)
Author:
desonia
Message:

modified tests to match new psRegion functions.

Location:
trunk/psLib/test
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astronomy/tst_psAstrometry01.c

    r3883 r3976  
    55*  @author GLG, MHPCC
    66*
    7 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2005-05-11 22:00:35 $
     7*  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2005-05-19 05:03:48 $
    99*
    1010* XXX: Must test
     
    719719                                    psPlaneTransform *trans3 = NULL;
    720720                                    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
    722723
    723724                                    if (trans3 == NULL) {
     
    749750    printf("----------------------------------------------------------------------------------\n");
    750751    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);
    752753    if (trans3 != NULL) {
    753754        printf("TEST ERROR: psPlaneTransformCombine() returned a non-NULL psPlaneTransform.\n");
     
    758759    printf("----------------------------------------------------------------------------------\n");
    759760    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);
    761762    if (trans3 != NULL) {
    762763        printf("TEST ERROR: psPlaneTransformCombine() returned a non-NULL psPlaneTransform.\n");
     
    908909    psPlaneTransform *trans = psPlaneTransformAlloc(2, 2);
    909910    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);
    911912
    912913    //
     
    931932    }
    932933
    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     }
    941934    printf("----------------------------------------------------------------------------------\n");
    942935    printf("Calling psPlaneTransformInvert with zero nSamples.  Should generate error and return NULL.\n");
     
    988981
    989982    psFree(trans);
    990     psFree(myRegion);
    991983
    992984    fflush(stdout);
  • trunk/psLib/test/image/tst_psImage.c

    r3973 r3976  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-05-19 02:49:40 $
     8 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-05-19 05:03:48 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2222
    2323static psS32 testImageAlloc(void);
    24 static psS32 testImageCopy(void);
    2524static psS32 testRegion(void);
    2625
     
    2827                              {testImageAlloc,546,"psImageAlloc",0,false},
    2928                              {testImageAlloc,548,"psImageFree",0,true},
    30                               {testImageCopy,551,"psImageCopy",0,false},
    31                               {testRegion,790,"psRegionAlloc",0,false},
     29                              {testRegion,790,"psRegionSet",0,false},
    3230                              {testRegion,791,"psRegionFromString",0,true},
    3331                              {NULL}
     
    237235}
    238236
    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 structure
    272     // 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 in
    295     // 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 program
    364     // 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 
    380237static psS32 testRegion(void)
    381238{
     
    385242    // Testpoint #790
    386243
    387     psRegion* region = psRegionAlloc(1,2,3,4);
     244    psRegion region = psRegionSet(1,2,3,4);
    388245
    389246    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) {
    398248        psError(PS_ERR_UNKNOWN, false,
    399249                "The region attributes are not set properly (%s)",
     
    402252    }
    403253
    404     psFree(region);
    405 
    406254    // Testpoint #791
    407255
     
    409257
    410258    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) {
    419260        psError(PS_ERR_UNKNOWN, false,
    420261                "The region attributes are not set properly (%s)",
     
    423264    }
    424265
    425     psFree(region);
    426266    region = psRegionFromString("[1:2,3:]");
    427267
    428268    testNum++;
    429     if (region != NULL) {
     269    if (! isnan(region.x0)) {
    430270        psError(PS_ERR_UNKNOWN, false,
    431271                "psRegionFromString returned a non-NULL pointer given a malformed string.");
  • trunk/psLib/test/image/tst_psImageStructManip.c

    r3973 r3976  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-05-19 02:49:40 $
     8*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-05-19 05:03:48 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1919
    2020static psS32 testImageSubset(void);
    21 static psS32 testImageSubsection(void);
     21static psS32 testImageCopy(void);
    2222static psS32 testImageTrim(void);
    2323
     
    2626                              {testImageSubset,547,"psImageSubset",0,false},
    2727                              {testImageSubset,550,"psImageSubset",0,true},
    28                               {testImageSubsection,730,"psImageSubsection",0,false},
     28                              {testImageCopy,551,"psImageCopy",0,false},
    2929                              {testImageTrim, 744, "psImageTrim", 0, false},
    3030                              {NULL}
     
    4646    psS32 c = 128;
    4747    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);
    5050
    5151    original = psImageAlloc(c,r,PS_TYPE_U32);
     
    168168    memcpy(&preSubsetStruct,original,sizeof(psImage));
    169169    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));
    174171    if (subset1 != NULL) {
    175172        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when numRows=0.");
     
    177174    }
    178175    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));
    183177    if (subset1 != NULL) {
    184178        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when numCols=0.");
     
    196190
    197191    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));
    202193    if (subset1 != NULL) {
    203194        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of "
     
    206197    }
    207198    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));
    212200    if (subset1 != NULL) {
    213201        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of "
     
    216204    }
    217205    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));
    222207    if (subset1 != NULL) {
    223208        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of "
     
    226211    }
    227212    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));
    232214    if (subset1 != NULL) {
    233215        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset origin was outside of "
     
    242224
    243225    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));
    248227    if (subset1 != NULL) {
    249228        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via rows).");
     
    251230    }
    252231    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));
    257233    if (subset1 != NULL) {
    258234        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via cols).");
     
    260236    }
    261237    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));
    266239    if (subset1 != NULL) {
    267240        psError(PS_ERR_UNKNOWN,true,"psImageSubset didn't return NULL when subset was outside of image (via row+cols).");
     
    298271}
    299272
    300 // #730: psImageSubsection shall create child image of a specified size from a parent psImage structure
    301 psS32 testImageSubsection(void)
     273psS32 testImageCopy(void)
    302274{
    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;
    384324            }
    385325        }
    386326    }
    387327
    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);
    452410
    453411    return 0;
     
    462420    psS32 halfR = r/2;
    463421    psS32 halfC = c/2;
    464     psRegion centerHalf = {qtrC,qtrR,qtrC+halfC,qtrR+halfR};
     422    psRegion centerHalf = {qtrC,qtrC+halfC,qtrR,qtrR+halfR};
    465423
    466424    psImage* image = psImageAlloc(c,r,PS_TYPE_F32);
     
    517475    */
    518476    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));
    523478
    524479    if (image1 != image2) {
     
    559514    */
    560515    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));
    565517
    566518    if (image1 != image2) {
     
    602554    */
    603555
    604     image2 = psImageTrim(NULL,(psRegion) {
    605                              qtrC,qtrR,0,0
    606                          }
    607                         );
     556    image2 = psImageTrim(NULL, psRegionSet(qtrC,0,qtrR,0));
    608557
    609558    if (image2 != NULL) {
     
    622571
    623572    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));
    628574
    629575    if (image2 != NULL) {
     
    642588
    643589    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));
    648591
    649592    if (image2 != NULL) {
     
    662605
    663606    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));
    668608
    669609    if (image2 != NULL) {
     
    682622
    683623    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));
    688625
    689626    if (image2 != NULL) {
     
    702639
    703640    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));
    708642
    709643    if (image2 != NULL) {
     
    722656
    723657    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));
    728659
    729660    if (image2 != NULL) {
  • trunk/psLib/test/image/verified/tst_psImage.stderr

    r3682 r3976  
    7979<DATE><TIME>|<HOST>|E|psImageAlloc (FILE:LINENO)
    8080    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].
    8185
    8286---> TESTPOINT PASSED (psImage{psImageAlloc} | tst_psImage.c)
     
    8488/***************************** TESTPOINT ******************************************\
    8589*             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}                                       *
    11691*             TestType: Positive                                                   *
    11792\**********************************************************************************/
     
    12095    Specified subsection string, '[1:2,3:]', can not be parsed.  Must be in the form '[x1:x2,y1:y2]'.
    12196
    122 ---> TESTPOINT PASSED (psImage{psRegionAlloc} | tst_psImage.c)
     97---> TESTPOINT PASSED (psImage{psRegionSet} | tst_psImage.c)
    12398
Note: See TracChangeset for help on using the changeset viewer.