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/types
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/types/tst_psArray.c

    r6445 r6500  
    1717 *  @author  Ross Harman, MHPCC
    1818 *
    19  *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
    20  *  @date  $Date: 2006-02-17 03:24:46 $
     19 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
     20 *  @date  $Date: 2006-02-28 02:53:03 $
    2121 *
    2222 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5353static psS32 testArrayAdd( void );
    5454static psS32 testArrayGetSet( void );
    55 
     55static psS32 testArrayLength( void );
    5656
    5757testDescription tests[] = {
     
    6060                              {testArrayAdd, 667, "psArrayAdd", 0, false},
    6161                              {testArrayGetSet, 668, "psArrayGetSet", 0, false},
     62                              {testArrayLength, 669, "psArrayLength", 0, false},
    6263                              {NULL}
    6364                          };
     
    464465    if ( !psArraySet(test, 0, p1) )
    465466        fprintf(stderr, "ArraySet failed to set S32 at position 0\n");
     467    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    466468    if ( psArraySet(test, 10, p1) )
    467469        fprintf(stderr, "ArraySet Improperly set S32 at out of range position\n");
     
    475477    psFree(p2); // free ref from psArrayGet
    476478
     479    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    477480    if ( psArraySet(test, -6, p3) )
    478481        fprintf(stderr, "ArraySet failed to fail using an out of range negative number\n");
     
    485488    return 0;
    486489}
     490
     491psS32 testArrayLength( void )
     492{
     493    psArray *array = psArrayAlloc(5);
     494
     495    if (psArrayLength(array) != 0) {
     496        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     497                "psArrayLength failed to return the correct length of array.\n");
     498        return 1;
     499    }
     500    array->n = 5;
     501    if (psArrayLength(array) != 5) {
     502        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     503                "psArrayLength failed to return the correct length of array.\n");
     504        return 2;
     505    }
     506    array->n++;
     507    if (psArrayLength(array) != 6) {
     508        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     509                "psArrayLength failed to return the correct length of array.\n");
     510        return 3;
     511    }
     512    psFree(array);
     513
     514    psArray *emptyArray = NULL;
     515    psVector *vector = psVectorAlloc(5, PS_TYPE_F32);
     516
     517    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     518    if (psArrayLength(emptyArray) != -1) {
     519        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     520                "psArrayLength failed to return -1 for a NULL input array.\n");
     521        return 4;
     522    }
     523    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     524    if (psArrayLength((psArray*)vector) != -1) {
     525        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     526                "psArrayLength failed to return -1 for an invalid input array.\n");
     527        return 5;
     528    }
     529    psFree(vector);
     530
     531    return 0;
     532}
     533
  • trunk/psLib/test/types/tst_psList.c

    r4547 r6500  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-07-13 02:47:01 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-02-28 02:53:03 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2828static psS32 testListAddAfter(void);
    2929static psS32 testListAddBefore(void);
     30static psS32 testListLength(void);
    3031
    3132testDescription tests[] = {
     
    4041                              {testListAddAfter,811,"psListAddAfter",0,false},
    4142                              {testListAddBefore,811,"psListAddBefore",0,false},
     43                              {testListLength,666,"testListLength",0,false},
    4244                              {NULL}
    4345                          };
     
    12711273    return 0;
    12721274}
     1275
     1276psS32 testListLength( void )
     1277{
     1278    psArray *temp = psArrayAlloc(5);
     1279    psList *list = psListAlloc(temp);
     1280
     1281    if (psListLength(list) != 1) {
     1282        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     1283                "psListLength failed to return the correct length of list.\n");
     1284        return 1;
     1285    }
     1286    list->n = 5;
     1287    if (psListLength(list) != 5) {
     1288        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     1289                "psListLength failed to return the correct length of list.\n");
     1290        return 2;
     1291    }
     1292    list->n++;
     1293    if (psListLength(list) != 6) {
     1294        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     1295                "psListLength failed to return the correct length of list.\n");
     1296        return 3;
     1297    }
     1298    psFree(temp);
     1299    psFree(list);
     1300
     1301    psList *emptyList = NULL;
     1302    psVector *vector = psVectorAlloc(5, PS_TYPE_F32);
     1303
     1304    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     1305    if (psListLength(emptyList) != -1) {
     1306        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     1307                "psListLength failed to return -1 for a NULL input list.\n");
     1308        return 4;
     1309    }
     1310    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     1311    if (psListLength((psList*)vector) != -1) {
     1312        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     1313                "psListLength failed to return -1 for an invalid input list.\n");
     1314        return 5;
     1315    }
     1316    psFree(vector);
     1317
     1318    return 0;
     1319}
     1320
  • trunk/psLib/test/types/tst_psPixels.c

    r5214 r6500  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.3 $
     7 *  @version $Revision: 1.4 $
    88 *           $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-10-01 00:14:17 $
     9 *  @date $Date: 2006-02-28 02:53:03 $
    1010 *
    1111 *  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    2222static int testPixelsConcatenate(void);
    2323static psS32 testPixelsGetSet(void);
     24static psS32 testPixelsLength( void );
    2425
    2526testDescription tests[] = {
     
    3132                              {testPixelsConcatenate,866,"psPixelsConcatenate",0,false},
    3233                              {testPixelsGetSet,867,"psPixelsGet/Set",0,false},
     34                              {testPixelsLength,666,"psPixelsLength",0,false},
    3335                              {NULL}
    3436                          };
     
    8587    p1->data[0].x = 1;
    8688    p1->data[0].y = 2;
    87 
     89    p1->n++;
    8890    if (p1->n != p1->nalloc) {
    8991        psError(PS_ERR_UNKNOWN, true,
     
    113115        p2->data[i].x = i;
    114116        p2->data[i].y = 100+i;
     117        p2->n++;
    115118    }
    116119
     
    140143    // first, tests that reallocing a NULL just allocates
    141144    psPixels* p0 = psPixelsRealloc(NULL,10);
     145    p0->n = 10;
    142146
    143147    if (p0 == NULL) {
     
    168172
    169173    psPixels* p1 = psPixelsRealloc(p0, 20);
     174    //    p1->n = 20;
    170175
    171176    if (p1 != p0) {
     
    205210
    206211    psPixels* p2 = psPixelsRealloc(p1,5);
    207 
     212    p2->n = 5;
    208213    if (p2 != p1) {
    209214        psError(PS_ERR_UNKNOWN, true,
     
    546551}
    547552
     553psS32 testPixelsLength( void )
     554{
     555    psPixels *pixels = psPixelsAlloc(5);
     556
     557    if (psPixelsLength(pixels) != 0) {
     558        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     559                "psPixelsLength failed to return the correct length of pixels.\n");
     560        return 1;
     561    }
     562    pixels->n = 5;
     563    if (psPixelsLength(pixels) != 5) {
     564        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     565                "psPixelsLength failed to return the correct length of pixels.\n");
     566        return 2;
     567    }
     568    pixels->n++;
     569    if (psPixelsLength(pixels) != 6) {
     570        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     571                "psPixelsLength failed to return the correct length of pixels.\n");
     572        return 3;
     573    }
     574    psFree(pixels);
     575
     576    psPixels *emptyPixels = NULL;
     577    psVector *vector = psVectorAlloc(5, PS_TYPE_F32);
     578
     579    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     580    if (psPixelsLength(emptyPixels) != -1) {
     581        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     582                "psPixelsLength failed to return -1 for a NULL input pixels.\n");
     583        return 4;
     584    }
     585    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     586    if (psPixelsLength((psPixels*)vector) != -1) {
     587        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     588                "psPixelsLength failed to return -1 for an invalid input pixels.\n");
     589        return 5;
     590    }
     591    psFree(vector);
     592
     593    return 0;
     594}
     595
  • trunk/psLib/test/types/verified/tst_psArray.stderr

    r6445 r6500  
    225225\**********************************************************************************/
    226226
     227<DATE><TIME>|<HOST>|I|testArrayGetSet
     228    Following should generate error message
    227229<DATE><TIME>|<HOST>|E|psArraySet (FILE:LINENO)
    228230    Specified position, 10, is greater than n+1 of the array, 1.
     231<DATE><TIME>|<HOST>|I|testArrayGetSet
     232    Following should generate error message
    229233<DATE><TIME>|<HOST>|E|psArraySet (FILE:LINENO)
    230234    Invalid position.  Negative number too large
     
    232236---> TESTPOINT PASSED (psArray{psArrayGetSet} | tst_psArray.c)
    233237
     238/***************************** TESTPOINT ******************************************\
     239*             TestFile: tst_psArray.c                                              *
     240*            TestPoint: psArray{psArrayLength}                                     *
     241*             TestType: Positive                                                   *
     242\**********************************************************************************/
     243
     244<DATE><TIME>|<HOST>|I|testArrayLength
     245    Following should generate error message
     246<DATE><TIME>|<HOST>|E|psArrayLength (FILE:LINENO)
     247    Error:  Specified array is not a valid psArray
     248<DATE><TIME>|<HOST>|I|testArrayLength
     249    Following should generate error message
     250<DATE><TIME>|<HOST>|E|psArrayLength (FILE:LINENO)
     251    Error:  Specified array is not a valid psArray
     252
     253---> TESTPOINT PASSED (psArray{psArrayLength} | tst_psArray.c)
     254
  • trunk/psLib/test/types/verified/tst_psList.stderr

    r4547 r6500  
    165165---> TESTPOINT PASSED (psList{psListAddBefore} | tst_psList.c)
    166166
     167/***************************** TESTPOINT ******************************************\
     168*             TestFile: tst_psList.c                                               *
     169*            TestPoint: psList{testListLength}                                     *
     170*             TestType: Positive                                                   *
     171\**********************************************************************************/
     172
     173<DATE><TIME>|<HOST>|I|testListLength
     174    Following should generate error message
     175<DATE><TIME>|<HOST>|E|psListLength (FILE:LINENO)
     176    Error:  Specified list is not a valid psList
     177<DATE><TIME>|<HOST>|I|testListLength
     178    Following should generate error message
     179<DATE><TIME>|<HOST>|E|psListLength (FILE:LINENO)
     180    Error:  Specified list is not a valid psList
     181
     182---> TESTPOINT PASSED (psList{testListLength} | tst_psList.c)
     183
  • trunk/psLib/test/types/verified/tst_psPixels.stderr

    r5114 r6500  
    8484---> TESTPOINT PASSED (psPixels{psPixelsGet/Set} | tst_psPixels.c)
    8585
     86/***************************** TESTPOINT ******************************************\
     87*             TestFile: tst_psPixels.c                                             *
     88*            TestPoint: psPixels{psPixelsLength}                                   *
     89*             TestType: Positive                                                   *
     90\**********************************************************************************/
     91
     92<DATE><TIME>|<HOST>|I|testPixelsLength
     93    Following should generate error message
     94<DATE><TIME>|<HOST>|E|psPixelsLength (FILE:LINENO)
     95    Error:  Specified pixels is not a valid psPixels
     96<DATE><TIME>|<HOST>|I|testPixelsLength
     97    Following should generate error message
     98<DATE><TIME>|<HOST>|E|psPixelsLength (FILE:LINENO)
     99    Error:  Specified pixels is not a valid psPixels
     100
     101---> TESTPOINT PASSED (psPixels{psPixelsLength} | tst_psPixels.c)
     102
Note: See TracChangeset for help on using the changeset viewer.