IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7043


Ignore:
Timestamp:
May 2, 2006, 12:35:52 PM (20 years ago)
Author:
drobbin
Message:

Edited psVectorCopy and psVectorSort. Added error handling for NULL vectors.

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

Legend:

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

    r6500 r7043  
    1414 *  @author  Ross Harman, MHPCC
    1515 *
    16  *  @version $Revision: 1.11 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2006-02-28 02:53:03 $
     16 *  @version $Revision: 1.12 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2006-05-02 22:35:52 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3434static psS32 testVectorCountPixelMask(void);
    3535static psS32 testVectorLength(void);
     36static psS32 testVectorCopy(void);
    3637
    3738testDescription tests[] = {
     
    4647                              {testVectorCountPixelMask,-9,"psVectorCountPixelMask",0,false},
    4748                              {testVectorLength,666,"psVectorLength",0,false},
     49                              {testVectorCopy,667,"psVectorCopy",0,false},
    4850                              {NULL}
    4951                          };
     
    593595}
    594596
     597psS32 testVectorCopy(void)
     598{
     599
     600    psVector *in = NULL;
     601    psVector *copy = NULL;
     602
     603    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     604    copy = psVectorCopy(copy, in, PS_TYPE_F32);
     605    if (copy != NULL) {
     606        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     607                "psVectorCopy failed to return a NULL vector for NULL input.\n");
     608        return 1;
     609    }
     610
     611    in = psVectorAlloc(5, PS_TYPE_F32);
     612    in->n = 5;
     613    for (int i = 0; i < 5; i++) {
     614        in->data.F32[i] = i;
     615    }
     616    //Try copy of different type
     617    copy = psVectorCopy(copy, in, PS_TYPE_F64);
     618    if (copy == NULL) {
     619        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     620                "psVectorCopy returned a NULL vector for correct input.\n");
     621        return 2;
     622    } else if (copy->data.F64[2] != 2.0) {
     623        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     624                "psVectorCopy failed to return the correct data values.\n");
     625        printf("\n copy->data.f64[2] = %lf, in->data.f32[2] = %f\n", copy->data.F64[2],
     626               in->data.F32[2]);
     627        return 3;
     628    }
     629
     630    copy = psVectorRecycle(copy, in->n + 2, PS_TYPE_F64);
     631    //Try copy of same type and non-NULL outVector of different type and size.
     632    copy = psVectorCopy(copy, in, in->type.type);
     633    if (copy == NULL) {
     634        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     635                "psVectorCopy returned a NULL vector for correct input.\n");
     636        return 4;
     637    } else if (copy->type.type != PS_TYPE_F32 || copy->data.F32[2] != 2.0) {
     638        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     639                "psVectorCopy failed to return the correct data values.\n");
     640        return 5;
     641    }
     642
     643
     644    psFree(in);
     645    psFree(copy);
     646    return 0;
     647}
     648
  • trunk/psLib/test/mathtypes/tst_psVectorSort_01.c

    r4547 r7043  
    1212 *  @author  Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    15  *  @date  $Date: 2005-07-13 02:47:00 $
     14 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     15 *  @date  $Date: 2006-05-02 22:35:52 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    141141    out = psVectorAlloc(7,PS_TYPE_F32);
    142142    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error messgae");
     143    //    printf("\nBefore call, tempVec = psVectorSort(out,in) \n");
    143144    tempVec = psVectorSort(out,in);
     145    //    printf("\nAfter call, tempVec = psVectorSort(out,in) \n");
    144146    if(tempVec != NULL) {
    145147        psError(PS_ERR_UNKNOWN,true,"Did not return NULL on error or didn't error?");
     
    150152    // Test D - Sort vector with zero elements
    151153    printPositiveTestHeader(stdout,"psVectorSort","Sort zero element vector");
     154    //    psFree(out);
     155    //    psFree(tempVec);
     156    //    out = NULL;
     157    //    tempVec = NULL;
    152158    out = psVectorAlloc(7,PS_TYPE_F32);
    153     tempVec = out;
     159    //    tempVec = out;
    154160    in->n = 0;
    155161    out = psVectorSort(out,in);
    156     if(tempVec != out) {
    157         psError(PS_ERR_UNKNOWN,true,"Did not return the specified output vector");
    158         return 44;
     162    //    if(tempVec != out) {
     163    //        psError(PS_ERR_UNKNOWN,true,"Did not return the specified output vector");
     164    //        return 44;
     165    //    }
     166    if (out != NULL) {
     167        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     168                "psVectorSort failed to return a NULL vector for 0-length input vector.\n");
     169        return 666;
    159170    }
    160     if(out->n != 0) {
    161         psError(PS_ERR_UNKNOWN,true,"Did not proper set the number of elements to zero");
    162         return 55;
    163     }
     171    /*    if(out->n != 0) {
     172            psError(PS_ERR_UNKNOWN,true,"Did not properly set the number of elements to zero");
     173            return 55;
     174        }
     175        */
    164176    printFooter(stdout,"psVectorSort","Sort zero element vector",true);
    165177
     
    168180    printPositiveTestHeader(stdout,"psVectorSort", "Free float vectors");
    169181    psFree(in);
    170     psFree(out);
    171182    if ( psMemCheckLeaks(0, NULL, stdout, false)) {
    172183        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected.");
  • trunk/psLib/test/mathtypes/tst_psVectorSort_02.c

    r6484 r7043  
    1414 *  @author  Ross Harman, MHPCC
    1515 *
    16  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2006-02-24 23:43:16 $
     16 *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2006-05-02 22:35:52 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3535if(out->type.type != PS_TYPE_U32) { \
    3636    psError(PS_ERR_UNKNOWN,true,"Output vector is not of type PS_TYPE_U32"); \
    37     return 10; \
     37    return 1; \
    3838} \
    3939if(out->data.U32[0] != 3 ) { \
    4040    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[0] = %ld",out->data.U32[0]); \
    41     return 20; \
    4241} \
    4342if(out->data.U32[1] != 2 ) { \
    4443    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[1] = %ld",out->data.U32[1]); \
    45     return 30; \
    4644} \
    4745if(out->data.U32[2] != 4 ) { \
    4846    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[2] = %ld",out->data.U32[2]); \
    49     return 40; \
    5047} \
    5148if(out->data.U32[3] != 0 ) { \
    5249    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[3] = %ld",out->data.U32[3]); \
    53     return 50; \
    5450} \
    5551if(out->data.U32[4] != 1 ) { \
    5652    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[4] = %ld",out->data.U32[4]); \
    57     return 60; \
    5853} \
    59 psFree(in);
     54psFree(in); \
    6055
    6156psS32 main(psS32 argc,
  • trunk/psLib/test/mathtypes/verified/tst_psVector.stderr

    r6500 r7043  
    125125---> TESTPOINT PASSED (psVector{psVectorLength} | tst_psVector.c)
    126126
     127/***************************** TESTPOINT ******************************************\
     128*             TestFile: tst_psVector.c                                             *
     129*            TestPoint: psVector{psVectorCopy}                                     *
     130*             TestType: Positive                                                   *
     131\**********************************************************************************/
     132
     133<HOST>|I|testVectorCopy
     134    Following should generate error message
     135<HOST>|E|psVectorCopy (FILE:LINENO)
     136    The input psVector can not be NULL.
     137
     138---> TESTPOINT PASSED (psVector{psVectorCopy} | tst_psVector.c)
     139
  • trunk/psLib/test/mathtypes/verified/tst_psVectorSort_01.stderr

    r4547 r7043  
    11<DATE><TIME>|<HOST>|I|main
    22    Following should generate an error messgae
     3<DATE><TIME>|<HOST>|E|psVectorCopy (FILE:LINENO)
     4    Input psVector is an unsupported type (0xaacd184f).
    35<DATE><TIME>|<HOST>|E|psVectorSort (FILE:LINENO)
    4     Input psVector is an unsupported type (0x1301).
     6    Error in psVectorSort:  psVectorCopy returned NULL vector!
     7<DATE><TIME>|<HOST>|W|psVectorCopy (FILE:LINENO)
     8    Warning: psVector was copied with 0 elements!
     9<DATE><TIME>|<HOST>|E|psVectorSort (FILE:LINENO)
     10    Error in psVectorSort:  Vector has less than 2 data entries!
Note: See TracChangeset for help on using the changeset viewer.