IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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/src/mathtypes
Files:
3 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.
Note: See TracChangeset for help on using the changeset viewer.