IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 13, 2006, 4:22:55 PM (20 years ago)
Author:
drobbin
Message:

Changed psImageSet to coincide with new stipulations concerning sub-images.

Location:
trunk/psLib/test/mathtypes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/mathtypes/tst_psImage.c

    r5174 r6574  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-09-29 01:15:38 $
     8 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-03-14 02:22:55 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    361361    image = psImageAlloc(5, 5, PS_TYPE_S32);
    362362
    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
    373469
    374470    psFree(image);
  • trunk/psLib/test/mathtypes/verified/tst_psImage.stderr

    r5572 r6574  
    134134\**********************************************************************************/
    135135
     136<DATE><TIME>|<HOST>|I|testImageGetSet
     137    Following should generate error message
    136138<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)
    138172
    139173---> TESTPOINT PASSED (psImage{psImageGetSet} | tst_psImage.c)
Note: See TracChangeset for help on using the changeset viewer.