IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3112 for trunk/psLib/test


Ignore:
Timestamp:
Feb 2, 2005, 1:59:36 PM (21 years ago)
Author:
evanalst
Message:

Add test case for negative indexes for get and remove.

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

Legend:

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

    r3111 r3112  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-02-02 21:58:48 $
     8 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-02-02 23:59:36 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    460460    psFree(data);
    461461    // verify that the size incremented
    462     if (list->size != 6  || *(psS32 *)list->tail->prev->data != 7) {
     462    if (list->size != 6  || *(psS32 *)list->tail->prev->prev->data != 7) {
    463463        printListInt(list);
    464464        psError(PS_ERR_UNKNOWN, true,"psListAdd didn't insert to position #2.");
     
    597597    }
    598598
     599    data = (psS32*)psListGet(list,-2);
     600    if (data == NULL || *data !=2) {
     601        psError(PS_ERR_UNKNOWN,true,"psListGet failed with location=-2");
     602        return 9;
     603    }
     604
    599605    psFree(list);
    600606
     
    682688    }
    683689
     690    data = psListGet(list,-2);
     691    // Test requirement SDR-173
     692    if ( (! psListRemove(list,-2)) ||
     693            (psListGet(list,-2) == data) ) {
     694        printListInt(list);
     695        psError(PS_ERR_UNKNOWN, true,"Failed to remove from location -2");
     696        return 11;
     697    }
     698
     699    if (list->size != --items) {
     700        printListInt(list);
     701        psError(PS_ERR_UNKNOWN, true,"Didn't decrement size properly to %d.",items);
     702        return 1;
     703    }
     704
    684705    // 6. psListRemoveData where data=NULL (error)
    685706    psLogMsg(__func__,PS_LOG_INFO,"Next message should be an error");
  • trunk/psLib/test/collections/verified/tst_psList.stderr

    r3111 r3112  
    2929    Following should error with invalid insert location
    3030<DATE><TIME>|<HOST>|E|psListIteratorSet (psList.c:<LINENO>)
    31     Specified location, -6, is invalid.
     31    Specified location, -7, is invalid.
    3232<DATE><TIME>|<HOST>|I|testListAdd
    3333    Following should be a warning.
Note: See TracChangeset for help on using the changeset viewer.