IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

modified tests to match new psRegion functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.");
Note: See TracChangeset for help on using the changeset viewer.