IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2385


Ignore:
Timestamp:
Nov 18, 2004, 2:34:22 PM (22 years ago)
Author:
evanalst
Message:

Add test cases for function psArrayRemove

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

Legend:

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

    r2354 r2385  
    88 *     C)  Reallocate void pointer array bigger
    99 *     D)  Reallocate void pointer array smaller
    10  *     E)  Free void pointer array
     10 *     E)  Reallocate with null pointer
     11 *     F)  Remove item from array
     12 *     G)  Remove invalid item from array
     13 *     H)  Remove item from null array
     14 *     I)  Free void pointer array
    1115 *
    1216 *  @author  Ross Harman, MHPCC
    1317 *
    14  *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
    15  *  @date  $Date: 2004-11-12 22:28:16 $
     18 *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
     19 *  @date  $Date: 2004-11-19 00:34:22 $
    1620 *
    1721 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    138142    printFooter(stdout, "psArray", "Reallocate integer void pointer smaller", true);
    139143
    140     // Test D1 - Reallocate with a null
     144    // Test E - Reallocate with a null
    141145    printNegativeTestHeader(stdout,"psArray","Reallocate with a null array",
    142146                            "Error message generator", 0 );
     
    148152    printFooter(stdout,"psArray","Reallocate with a null array",true);
    149153
    150     // Test E - Free void pointer array
     154
     155    // Test F - Remove item from array
     156    printPositiveTestHeader(stdout, "psArray", "Remove valid item");
     157    if( !psArrayRemove(psArr,mySt[0]) ) {
     158        psError(PS_ERR_UNKNOWN,true,"Unable to remove valid item");
     159        return 100;
     160    }
     161    printf("Array size after removal = %d\n",psArr->n);
     162    if ( psArr->n != 2 ) {
     163        psError(PS_ERR_UNKNOWN, true, "Items in array not decremented after removal");
     164        return 101;
     165    }
     166    for(psS32 i = 0; i < psArr->n; i++) {
     167        testStruct *ts = (testStruct*)psArr->data[i];
     168        printf("ts[%d].x = %d ts[%d].y = %.2f\n", i, ts->x, i, ts->y);
     169        if(fabsf(ts->x - 10*(i+1)) > 0.01f || fabsf(ts->y - 10.1*(i+1)) > 0.01f) {
     170            psError(PS_ERR_UNKNOWN, true, "Elements not as expected after remove.");
     171            return 102;
     172        }
     173    }
     174    psFree(mySt[0]);
     175    printFooter(stdout,"psArray","Remove valid item", true);
     176
     177    // Test G - Remove invalid item from array
     178    printPositiveTestHeader(stdout, "psArray", "Remove invalid item from array");
     179    if( psArrayRemove(psArr,mySt[9]) ) {
     180        psError(PS_ERR_UNKNOWN,true,"Removed invalid item from array");
     181        return 103;
     182    }
     183    printFooter(stdout,"psArray","Remove invalid item from array",true);
     184
     185    // Test H - Remove item from null array
     186    printPositiveTestHeader(stdout, "psArray", "Remove item from null array");
     187    if ( psArrayRemove(NULL,mySt[1]) ) {
     188        psError(PS_ERR_UNKNOWN,true,"Removed valid item from null array");
     189        return 104;
     190    }
     191
     192    // Test I - Free void pointer array
    151193    printPositiveTestHeader(stdout, "psArray", "Free void pointer array");
    152194    psFree(psArr);
     
    154196        psFree(mySt[i]);
    155197    }
    156     psMemCheckLeaks(0, NULL, stdout);
     198    if( psMemCheckLeaks(0, NULL, stdout) != 0) {
     199        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected.");
     200        return 110;
     201    }
    157202    psS32 nBad = psMemCheckCorruption(0);
    158203    if(nBad) {
    159204        printf("ERROR: Found %d bad memory blocks\n", nBad);
     205        return 111;
    160206    }
    161207    printFooter(stdout, "psArray" ,"Free void pointer array", true);
  • trunk/psLib/test/collections/verified/tst_psArray.stdout

    r2354 r2385  
    7373/***************************** TESTPOINT ******************************************\
    7474*             TestFile: tst_psArray.c                                              *
     75*            TestPoint: psArray{Remove valid item}                                 *
     76*             TestType: Positive                                                   *
     77\**********************************************************************************/
     78
     79Array size after removal = 2
     80ts[0].x = 10 ts[0].y = 10.10
     81ts[1].x = 20 ts[1].y = 20.20
     82
     83---> TESTPOINT PASSED (psArray{Remove valid item} | tst_psArray.c)
     84
     85/***************************** TESTPOINT ******************************************\
     86*             TestFile: tst_psArray.c                                              *
     87*            TestPoint: psArray{Remove invalid item from array}                    *
     88*             TestType: Positive                                                   *
     89\**********************************************************************************/
     90
     91
     92---> TESTPOINT PASSED (psArray{Remove invalid item from array} | tst_psArray.c)
     93
     94/***************************** TESTPOINT ******************************************\
     95*             TestFile: tst_psArray.c                                              *
     96*            TestPoint: psArray{Remove item from null array}                       *
     97*             TestType: Positive                                                   *
     98\**********************************************************************************/
     99
     100/***************************** TESTPOINT ******************************************\
     101*             TestFile: tst_psArray.c                                              *
    75102*            TestPoint: psArray{Free void pointer array}                           *
    76103*             TestType: Positive                                                   *
Note: See TracChangeset for help on using the changeset viewer.