IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5114


Ignore:
Timestamp:
Sep 23, 2005, 2:17:44 PM (21 years ago)
Author:
drobbin
Message:

Updated, fixed, and added error tests to the Set/Get functions & tests

Location:
trunk/psLib
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/mathtypes/psImage.c

    r5101 r5114  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-09-23 00:04:36 $
     11 *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-09-24 00:17:44 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    272272                complex value)
    273273{
    274     if (image == NULL)
     274    if (image == NULL) {
     275        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
    275276        return false;
    276     if (x >= image->numRows || y >= image->numCols)
     277    }
     278    if (x >= image->numRows || y >= image->numCols) {
     279        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Position too large\n");
    277280        return false;
     281    }
     282
    278283    if(x < 0)
    279284        x += image->numRows;
     285    if(x < 0) {
     286        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x.  Negative number too large\n");
     287        return false;
     288    }
     289
    280290    if(y < 0)
    281291        y += image->numCols;
     292    if(y < 0) {
     293        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y.  Negative number too large\n");
     294        return false;
     295    }
    282296
    283297    switch (image->type.type) {
     
    330344                   int y)
    331345{
    332     if (image == NULL)
     346    if (image == NULL) {
     347        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
    333348        return NAN;
    334     if (x >= image->numRows || y >= image->numCols)
     349    }
     350    if (x >= image->numRows || y >= image->numCols) {
     351        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Position too large\n");
    335352        return NAN;
     353    }
     354
    336355    if(x < 0)
    337356        x += image->numRows;
     357    if(x < 0) {
     358        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x.  Negative number too large\n");
     359        return NAN;
     360    }
     361
    338362    if(y < 0)
    339363        y += image->numCols;
     364    if(y < 0) {
     365        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y.  Negative number too large\n");
     366        return NAN;
     367    }
    340368
    341369    switch (image->type.type) {
     
    377405        break;
    378406    default:
     407        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psImage Data Type\n");
    379408        return NAN;
    380409    }
  • trunk/psLib/src/mathtypes/psVector.c

    r5101 r5114  
    99*  @author Robert DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-09-23 00:04:36 $
     11*  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-09-24 00:17:44 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    817817                 complex value)
    818818{
    819     if (input == NULL)
     819    if (input == NULL) {
     820        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psVector_NULL);
    820821        return false;
    821     if (position >= input->n)
     822    }
     823    if (position > input->n) {
     824        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
    822825        return false;
    823     if(position < 0)
     826    }
     827    if (position < 0)
    824828        position += input->n;
     829    if (position < 0) {
     830        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     831        return false;
     832    }
     833
     834    if (position == input->n) {
     835        if (position >= input->nalloc) {
     836            psError(PS_ERR_BAD_PARAMETER_NULL, true,
     837                    "Specified position, %ld, is greater than n+1 of the vector, %ld.",
     838                    position, input->nalloc);
     839            return false;
     840        }
     841        (*(psVector**)&input)->n++;
     842    }
    825843
    826844    switch (input->type.type) {
     
    872890                    long position)
    873891{
    874     if (input == NULL)
     892    if (input == NULL) {
     893        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psVector_NULL);
    875894        return NAN;
     895    }
    876896    if (position >= input->n) {
     897        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
    877898        return NAN;
    878899    }
    879900    if(position < 0)
    880901        position += input->n;
    881 
     902    if (position < 0) {
     903        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     904        return NAN;
     905    }
    882906    switch (input->type.type) {
    883907    case PS_TYPE_U8:
     
    918942        break;
    919943    default:
     944        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psVector Data Type\n");
    920945        return NAN;
    921946    }
  • trunk/psLib/src/mathtypes/psVector.h

    r5089 r5114  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-09-22 02:32:00 $
     13 *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-09-24 00:17:44 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3434typedef struct
    3535{
    36     psMathType type;                       ///< Type of data.
     36    psMathType type;                   ///< Type of data.
    3737    long n;                            ///< Number of elements in use.
    3838    const long nalloc;                 ///< Total number of elements available.
  • trunk/psLib/src/types/psArray.c

    r4898 r5114  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-08-30 01:14:13 $
     11 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-09-24 00:17:44 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    178178    }
    179179
    180     if (position >= array->nalloc)
    181     {
    182         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    183                 PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
    184                 position, array->nalloc);
    185         return false;
    186     }
    187 
     180    if (position > array->n)
     181    {
     182        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     183                "Specified position, %ld, is greater than n+1 of the array, %ld.",
     184                position, array->n);
     185        return false;
     186    }
     187
     188    if (position < 0)
     189        position += array->n;
     190    if (position < 0)
     191    {
     192        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     193        return false;
     194    }
     195
     196    if (position == array->n)
     197    {
     198        if (position >= array->nalloc) {
     199            psError(PS_ERR_BAD_PARAMETER_NULL, true,
     200                    PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     201                    position, array->nalloc);
     202            return false;
     203        }
     204        array->n++;
     205    }
    188206    psFree(array->data[position]);
    189207    array->data[position] = data;
     
    202220    }
    203221
    204     if (position >= array->nalloc) {
    205         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    206                 PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
    207                 position, array->nalloc);
    208         return NULL;
    209     }
    210 
     222    if (position >= array->n) {
     223        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     224                "Specified position, %ld, is greater than n+1 of the array, %ld.",
     225                position, array->n);
     226        return NULL;
     227    }
     228    if (position < 0)
     229        position += array->n;
     230    if (position < 0) {
     231        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     232        return NULL;
     233    }
    211234    return array->data[position];
    212235}
  • trunk/psLib/src/types/psArray.h

    r4898 r5114  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-08-30 01:14:13 $
     14 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-09-24 00:17:44 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/src/types/psPixels.c

    r5101 r5114  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-09-23 00:04:36 $
     9 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-24 00:17:44 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    337337                 psPixelCoord value)
    338338{
    339     if (pixels == NULL)
     339    if (pixels == NULL) {
     340        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psPixels_NULL);
    340341        return false;
    341     if (position > pixels->n)
     342    }
     343    if (position > pixels->n) {
     344        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
    342345        return false;
     346    }
    343347    if(position < 0)
    344348        position += pixels->n;
     349    if(position < 0) {
     350        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     351        return false;
     352    }
    345353    if (position == pixels->n) {
    346         if (position >= pixels->nalloc)
     354        if (position >= pixels->nalloc) {
     355            psError(PS_ERR_BAD_PARAMETER_NULL, true,
     356                    "Specified position, %ld, is greater than n+1 of the pixels, %ld.",
     357                    position, pixels->nalloc);
    347358            return false;
     359        }
    348360        pixels->n++;
    349361    }
     
    359371    psPixelCoord out;
    360372    if (pixels == NULL) {
     373        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psPixels_NULL);
    361374        out.x = 0; //XXX: should be NAN when changed to float
    362375        out.y = 0; //XXX: should be NAN when changed to float
     
    364377    }
    365378    if (position >= pixels->n) {
     379        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Number too large\n");
    366380        out.x = 0; //XXX: should be NAN when changed to float
    367381        out.y = 0; //XXX: should be NAN when changed to float
     
    370384    if (position < 0)
    371385        position += pixels->n;
     386    if (position < 0) {
     387        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Negative number too large\n");
     388        out.x = 0; //XXX: should be NAN when changed to float
     389        out.y = 0; //XXX: should be NAN when changed to float
     390        return out;
     391    }
    372392    out.x = pixels->data[position].x;
    373393    out.y = pixels->data[position].y;
  • trunk/psLib/src/types/psPixels.h

    r5101 r5114  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-09-23 00:04:36 $
     9 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-24 00:17:44 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/test/mathtypes/tst_psVector.c

    r5089 r5114  
    1414 *  @author  Ross Harman, MHPCC
    1515 *
    16  *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2005-09-22 02:32:00 $
     16 *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2005-09-24 00:17:44 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    391391    psVector *vec = NULL;
    392392    vec = psVectorAlloc(5, PS_TYPE_S32);
     393    vec->n = 0;
    393394
    394395    if ( !psVectorSet(vec, 0, 10) )
     
    396397    if ( psVectorSet(vec, 10, 10) )
    397398        fprintf(stderr, "VectorSet Improperly set S32 at out of range position\n");
    398     if ( !psVectorSet(vec, -1, 4) )
    399         fprintf(stderr, "VectorSet Failed to set S32 at position 4\n");
     399    if ( !psVectorSet(vec, 1, 4) )
     400        fprintf(stderr, "VectorSet Failed to set S32 at position 1\n");
    400401    if ( (psS32)psVectorGet(vec, 0) != 10 )
    401402        fprintf(stderr, "VectorGet Failed to return the correct S32 from position 0\n");
  • trunk/psLib/test/mathtypes/verified/tst_psImage.stderr

    r5101 r5114  
    138138\**********************************************************************************/
    139139
     140<DATE><TIME>|<HOST>|E|psImageSet (FILE:LINENO)
     141    Invalid position.  Position too large
    140142
    141143---> TESTPOINT PASSED (psImage{psImageInit} | tst_psImage.c)
  • trunk/psLib/test/mathtypes/verified/tst_psVector.stderr

    r5089 r5114  
    6464\**********************************************************************************/
    6565
     66<DATE><TIME>|<HOST>|E|psVectorSet (FILE:LINENO)
     67    Invalid position.  Number too large
    6668
    6769---> TESTPOINT PASSED (psVector{psVectorGet/Set} | tst_psVector.c)
  • trunk/psLib/test/types/tst_psArray.c

    r4898 r5114  
    1717 *  @author  Ross Harman, MHPCC
    1818 *
    19  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    20  *  @date  $Date: 2005-08-30 01:14:13 $
     19 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     20 *  @date  $Date: 2005-09-24 00:17:44 $
    2121 *
    2222 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5252static psS32 testArray01( void );
    5353static psS32 testArrayAdd( void );
     54static psS32 testArrayGetSet( void );
    5455
    5556
     
    5859                              {testArray01, -2, "psArray", 0, false},
    5960                              {testArrayAdd, 788, "psArrayAdd", 0, false},
     61                              {testArrayGetSet, -3, "psArrayGetSet", 0, false},
    6062                              {NULL}
    6163                          };
     
    440442    return 0;  // the value that indicates success is part of the testDescription
    441443}
     444
     445psS32 testArrayGetSet( void )
     446{
     447    psArray *test;
     448    int *p1 = psAlloc(sizeof(int));
     449    int *p2 = psAlloc(sizeof(int));
     450    int *p3 = psAlloc(sizeof(int));
     451    test = psArrayAlloc(5);
     452    test->n = 0;
     453    *p1 = 10;
     454    *p2 = 4;
     455    *p3 = 666;
     456
     457    if ( !psArraySet(test, 0, p1) )
     458        fprintf(stderr, "ArraySet failed to set S32 at position 0\n");
     459    if ( psArraySet(test, 10, p1) )
     460        fprintf(stderr, "ArraySet Improperly set S32 at out of range position\n");
     461    if ( !psArraySet(test, 1, p2) )
     462        fprintf(stderr, "ArraySet Failed to set S32 at position 1\n");
     463    if ( psArrayGet(test, 0) != p1 )
     464        fprintf(stderr, "ArrayGet Failed to return the correct S32 from position 0\n");
     465    if ( psArrayGet(test, -1) != p2)
     466        fprintf(stderr, "ArrayGet Failed to return the correct S32 from tail using -1\n");
     467
     468    if ( psArraySet(test, -6, p3) )
     469        fprintf(stderr, "ArraySet failed to fail using an out of range negative number\n");
     470
     471    psFree(test);
     472    psFree(p3);
     473
     474    return 0;
     475}
  • trunk/psLib/test/types/verified/tst_psArray.stderr

    r4547 r5114  
    219219---> TESTPOINT PASSED (psArray{psArrayAdd} | tst_psArray.c)
    220220
     221/***************************** TESTPOINT ******************************************\
     222*             TestFile: tst_psArray.c                                              *
     223*            TestPoint: psArray{psArrayGetSet}                                     *
     224*             TestType: Positive                                                   *
     225\**********************************************************************************/
     226
     227<DATE><TIME>|<HOST>|E|psArraySet (FILE:LINENO)
     228    Specified position, 10, is greater than n+1 of the array, 1.
     229<DATE><TIME>|<HOST>|E|psArraySet (FILE:LINENO)
     230    Invalid position.  Negative number too large
     231
     232---> TESTPOINT PASSED (psArray{psArrayGetSet} | tst_psArray.c)
     233
  • trunk/psLib/test/types/verified/tst_psPixels.stderr

    r5101 r5114  
    7979\**********************************************************************************/
    8080
     81<DATE><TIME>|<HOST>|E|psPixelsSet (FILE:LINENO)
     82    Invalid position.  Number too large
    8183
    8284---> TESTPOINT PASSED (psPixels{psPixelsGet/Set} | tst_psPixels.c)
Note: See TracChangeset for help on using the changeset viewer.