IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 15, 2004, 12:17:03 PM (22 years ago)
Author:
desonia
Message:

test changes cooresponding to psVector of Pointers being extracted to a
new object, psArray.

Location:
trunk/psLib/test/collections
Files:
6 added
3 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/collections/Makefile

    r1212 r1227  
    33##  Makefile:   test/collections
    44##
    5 ##  $Revision: 1.18 $  $Name: not supported by cvs2svn $
    6 ##  $Date: 2004-07-13 01:37:58 $
     5##  $Revision: 1.19 $  $Name: not supported by cvs2svn $
     6##  $Date: 2004-07-15 22:17:03 $
    77##
    88##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1919LDFLAGS := -L../../lib -lpslib -lpstest $(LDFLAGS)
    2020
    21 TARGET = tst_psVector_01 \
    22          tst_psVector_02 \
    23          tst_psVector_03 \
     21TARGET = tst_psVector \
     22         tst_psArray \
    2423         tst_psBitSet_01 \
    2524         tst_psBitSet_02 \
  • trunk/psLib/test/collections/tst_psList.c

    r1193 r1227  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-07-08 01:05:01 $
     8 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-07-15 22:17:03 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    686686
    687687    psList* list = NULL;
    688     psVector* vec = NULL;
     688    psArray* arr = NULL;
    689689    int* data;
    690690
     
    695695    */
    696696
    697     // test dlist -> vector
     697    // test dlist -> array
    698698
    699699    // create a list
     
    706706    }
    707707
    708     vec = psListToVector(list);
    709 
    710     if (vec->n != 15 || list->size != 15) {
    711         psError(__func__,"The created vector didn't have the proper size");
    712         return 1;
    713     }
    714     for (int i=0;i<vec->n;i++) {
    715         if (i != *(int*)vec->data.PTR[i]) {
    716             psError(__func__,"Element %d of vector is incorrect (%d).",
    717                     i,*(int*)vec->data.PTR[i]);
     708    arr = psListToArray(list);
     709
     710    if (arr->n != 15 || list->size != 15) {
     711        psError(__func__,"The created array didn't have the proper size");
     712        return 1;
     713    }
     714    for (int i=0;i<arr->n;i++) {
     715        if (i != *(int*)arr->data[i]) {
     716            psError(__func__,"Element %d of array is incorrect (%d).",
     717                    i,*(int*)arr->data[i]);
    718718            return 1;
    719719        }
    720720        if (i != *(int*)psListGet(list,i)) {
    721721            psError(__func__,"Element %d of list is incorrect (%d).",
    722                     i,*(int*)vec->data.PTR[i]);
     722                    i,*(int*)arr->data[i]);
    723723            return 1;
    724724        }
    725         if (psMemGetRefCounter(vec->data.PTR[i]) != 2) {
     725        if (psMemGetRefCounter(arr->data[i]) != 2) {
    726726            psError(__func__,"Element %d had wrong reference count (%d).",
    727                     i,psMemGetRefCounter(vec->data.PTR[i]));
     727                    i,psMemGetRefCounter(arr->data[i]));
    728728            return 1;
    729729        }
    730730    }
    731731
    732     psFree(vec);
    733     psFree(list);
    734 
    735     // test vector -> dlist
    736 
    737     // create a vector
    738     vec = psVectorAlloc(15,PS_TYPE_PTR);
    739     vec->n = vec->nalloc;
     732    psFree(arr);
     733    psFree(list);
     734
     735    // test array -> dlist
     736
     737    // create an array
     738    arr = psArrayAlloc(15);
     739    arr->n = arr->nalloc;
    740740    for (int lcv=0;lcv<15;lcv++) {
    741741        data = psAlloc(sizeof(int));
    742742        *data = lcv;
    743         vec->data.PTR[lcv] = data;
    744     }
    745 
    746     list = psVectorToList(vec);
    747 
    748     if (vec->n != 15 || list->size != 15) {
    749         psError(__func__,"The created vector didn't have the proper size");
    750         return 1;
    751     }
    752     for (int i=0;i<vec->n;i++) {
    753         if (i != *(int*)vec->data.PTR[i]) {
    754             psError(__func__,"Element %d of vector is incorrect (%d).",
    755                     i,*(int*)vec->data.PTR[i]);
     743        arr->data[lcv] = data;
     744    }
     745
     746    list = psArrayToList(arr);
     747
     748    if (arr->n != 15 || list->size != 15) {
     749        psError(__func__,"The created array didn't have the proper size");
     750        return 1;
     751    }
     752    for (int i=0;i<arr->n;i++) {
     753        if (i != *(int*)arr->data[i]) {
     754            psError(__func__,"Element %d of array is incorrect (%d).",
     755                    i,*(int*)arr->data[i]);
    756756            return 1;
    757757        }
    758758        if (i != *(int*)psListGet(list,i)) {
    759759            psError(__func__,"Element %d of list is incorrect (%d).",
    760                     i,*(int*)vec->data.PTR[i]);
     760                    i,*(int*)arr->data[i]);
    761761            return 1;
    762762        }
    763         if (psMemGetRefCounter(vec->data.PTR[i]) != 2) {
     763        if (psMemGetRefCounter(arr->data[i]) != 2) {
    764764            psError(__func__,"Element %d had wrong reference count (%d).",
    765                     i,psMemGetRefCounter(vec->data.PTR[i]));
     765                    i,psMemGetRefCounter(arr->data[i]));
    766766            return 1;
    767767        }
    768768    }
    769769
    770     psFree(vec);
    771     psFree(list);
    772 
    773     // now, make sure if input vector/list is NULL, output is NULL
    774 
    775     vec = psListToVector(NULL);
    776     if (vec != NULL) {
    777         psError(__func__,"psListToVector didn't return NULL when given NULL");
    778         return 1;
    779     }
    780 
    781     list = psVectorToList(NULL);
     770    psFree(arr);
     771    psFree(list);
     772
     773    // now, make sure if input array/list is NULL, output is NULL
     774
     775    arr = psListToArray(NULL);
     776    if (arr != NULL) {
     777        psError(__func__,"psListToArray didn't return NULL when given NULL");
     778        return 1;
     779    }
     780
     781    list = psArrayToList(NULL);
    782782    if (list != NULL) {
    783         psError(__func__,"psVectorToList didn't return NULL when given NULL");
    784         return 1;
    785     }
    786 
    787     // now, see what happens with a zero-size vector/list
    788     vec = psVectorAlloc(1,PS_TYPE_PTR);
    789     vec->n = 0;
    790     list = psVectorToList(vec);
     783        psError(__func__,"psArrayToList didn't return NULL when given NULL");
     784        return 1;
     785    }
     786
     787    // now, see what happens with a zero-size array/list
     788    arr = psArrayAlloc(1);
     789    arr->n = 0;
     790    list = psArrayToList(arr);
    791791    if (list == NULL) {
    792         psError(__func__,"psVectorToList didn't create an empty list from an "
    793                 "empty vector.");
    794         return 1;
    795     }
    796     psFree(vec);
     792        psError(__func__,"psArrayToList didn't create an empty list from an "
     793                "empty array.");
     794        return 1;
     795    }
     796    psFree(arr);
    797797    psFree(list);
    798798
    799799    list = psListAlloc(NULL);
    800     vec = psListToVector(list);
    801     if (vec == NULL) {
    802         psError(__func__,"psVectorToList didn't create an empty vector from an "
     800    arr = psListToArray(list);
     801    if (arr == NULL) {
     802        psError(__func__,"psArrayToList didn't create an empty array from an "
    803803                "empty list.");
    804804        return 1;
    805805    }
    806     psFree(vec);
     806    psFree(arr);
    807807    psFree(list);
    808808
Note: See TracChangeset for help on using the changeset viewer.