IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 27, 2006, 4:53:03 PM (20 years ago)
Author:
drobbin
Message:

Add Length functions/tests. Modified psPixelsAlloc to set n=0.

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

Legend:

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

    r6484 r6500  
    1414 *  @author  Ross Harman, MHPCC
    1515 *
    16  *  @version $Revision: 1.10 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2006-02-24 23:43:16 $
     16 *  @version $Revision: 1.11 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2006-02-28 02:53:03 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3333static psS32 testVectorGetSet(void);
    3434static psS32 testVectorCountPixelMask(void);
     35static psS32 testVectorLength(void);
    3536
    3637testDescription tests[] = {
     
    4445                              {testVectorGetSet,-8,"psVectorGet/Set",0,false},
    4546                              {testVectorCountPixelMask,-9,"psVectorCountPixelMask",0,false},
     47                              {testVectorLength,666,"psVectorLength",0,false},
    4648                              {NULL}
    4749                          };
     
    548550}
    549551
     552psS32 testVectorLength( void )
     553{
     554    psVector *vector = psVectorAlloc(5, PS_TYPE_F32);
     555
     556    if (psVectorLength(vector) != 0) {
     557        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     558                "psVectorLength failed to return the correct length of vector.\n");
     559        return 1;
     560    }
     561    vector->n = 5;
     562    if (psVectorLength(vector) != 5) {
     563        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     564                "psVectorLength failed to return the correct length of vector.\n");
     565        return 2;
     566    }
     567    vector->n++;
     568    if (psVectorLength(vector) != 6) {
     569        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     570                "psVectorLength failed to return the correct length of vector.\n");
     571        return 3;
     572    }
     573    psFree(vector);
     574
     575    psVector *emptyVector = NULL;
     576    psArray *array = psArrayAlloc(5);
     577
     578    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     579    if (psVectorLength(emptyVector) != -1) {
     580        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     581                "psVectorLength failed to return -1 for a NULL input vector.\n");
     582        return 4;
     583    }
     584    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     585    if (psVectorLength((psVector*)array) != -1) {
     586        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     587                "psVectorLength failed to return -1 for an invalid input vector.\n");
     588        return 5;
     589    }
     590    psFree(array);
     591
     592    return 0;
     593}
     594
  • trunk/psLib/test/mathtypes/verified/tst_psVector.stderr

    r6484 r6500  
    108108---> TESTPOINT PASSED (psVector{psVectorCountPixelMask} | tst_psVector.c)
    109109
     110/***************************** TESTPOINT ******************************************\
     111*             TestFile: tst_psVector.c                                             *
     112*            TestPoint: psVector{psVectorLength}                                   *
     113*             TestType: Positive                                                   *
     114\**********************************************************************************/
     115
     116<HOST>|I|testVectorLength
     117    Following should generate error message
     118<HOST>|E|psVectorLength (FILE:LINENO)
     119    Error:  Specified vector is not a valid psVector
     120<HOST>|I|testVectorLength
     121    Following should generate error message
     122<HOST>|E|psVectorLength (FILE:LINENO)
     123    Error:  Specified vector is not a valid psVector
     124
     125---> TESTPOINT PASSED (psVector{psVectorLength} | tst_psVector.c)
     126
Note: See TracChangeset for help on using the changeset viewer.