Index: unk/psLib/test/collections/tst_psDlist.c
===================================================================
--- /trunk/psLib/test/collections/tst_psDlist.c	(revision 920)
+++ 	(revision )
@@ -1,770 +1,0 @@
-/** @file  tst_psList.c
- *
- *  @brief Contains the tests for psList.[ch]
- *
- *
- *  @author Robert DeSonia, MHPCC
- *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-08 19:09:33 $
- *
- *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
- */
-
-#include "psTest.h"
-#include "pslib.h"
-
-void printListInt(psList* list);
-
-
-static int testListAlloc(void);
-static int testListAdd(void);
-static int testListGet(void);
-static int testListRemove(void);
-static int testListConvert(void);
-static int testListIterator(void);
-
-testDescription tests[] = {
-                              {testListAlloc,"487-testListAlloc",0},
-                              {testListAdd,"488-testListAdd",0},
-                              {testListGet,"489-testListGet",0},
-                              {testListRemove,"490-testListRemove",0},
-                              {testListConvert,"491-testListConvert",0},
-                              {testListIterator,"494-testListIterator",0},
-                              {NULL}
-                          };
-
-int main()
-{
-    psSetLogLevel(PS_LOG_INFO);
-
-    if (! runTestSuite(stderr,"psList",tests)) {
-        psAbort(__FILE__,"One or more tests failed");
-    }
-    return 0;
-}
-
-int testListAlloc(void)
-{
-    int currentId = psMemGetId();
-    psList* list;
-    int ref;
-    float* data;
-
-    psLogMsg(__func__,PS_LOG_INFO,"psListAlloc shall create a psList with either 0 or 1 element.");
-
-    data = psAlloc(sizeof(float));
-
-    // if psListAlloc is invoked with a NULL parameter, it shall return an
-    // empty psList struct with head=tail=NULL and n=0. Otherwise, it shall
-    // return a psList of one element (head=tail=data, n=1).
-
-    list = psListAlloc(NULL);
-    if (list == NULL) {
-        psError(__func__,"psListAlloc failed to return a list.");
-        return 1;
-    }
-
-    if (list->head != NULL || list->tail != NULL) {
-        psError(__func__,"head and/or tail was not NULL for empty list.");
-        return 2;
-    }
-
-    if (list->size != 0) {
-        psError(__func__,"size of list wasn't zero for empty list.");
-        return 3;
-    }
-
-    psListFree(list,NULL);
-
-    list = psListAlloc(data);
-    if (list == NULL) {
-        psError(__func__,"psListAlloc failed to return a list.");
-        return 4;
-    }
-
-    if (list->head == NULL || list->tail == NULL) {
-        psError(__func__,"head and/or tail was NULL for one-element new list.");
-        return 5;
-    }
-
-    if (list->head->data != data || list->tail->data != data) {
-        psError(__func__,"head and/or tail didn't point to data's node for one-element new list.");
-        return 6;
-    }
-
-    if (list->size != 1) {
-        psError(__func__,"size of list wasn't correctly set for new, one-element list.");
-        return 7;
-    }
-
-    ref = psMemGetRefCounter(data);
-    if (ref != 2) {
-        psError(__func__,"psList didn't increment reference count of data (%d.",ref);
-        return 8;
-    }
-
-
-    psListFree(list,PS_FREE);
-
-    psMemCheckLeaks(currentId,NULL,NULL);
-    psMemCheckCorruption(1);
-
-    return 0;
-}
-
-int testListAdd(void)
-{
-    int currentId = psMemGetId();
-    psList* list = NULL;
-    int* data;
-
-    psLogMsg(__func__,PS_LOG_INFO,"psListAdd shall add an element to list");
-
-    /*
-        psListAdd(list,data,where) should be tested in the instance where:
-
-        1. list is NULL (error)
-        2. data is NULL (error, list should not grow)
-        3. where is PS_LIST_HEAD or PS_LIST_TAIL
-        4. where is not PS_LIST_* but <0
-        5. where is >0
-    */
-
-    //  1. list is NULL (error)
-    list = psListAdd(NULL,data,PS_LIST_HEAD);
-
-    if (list != NULL) {
-        psError(__func__,"psListAdd was given a NULL list, but returned a non-NULL list.");
-        return 1;
-    }
-
-    //  2. data is NULL (error, list should not grow)
-    data = psAlloc(sizeof(int));
-    *data = 1;
-    list = psListAlloc(data);
-    if (list->size != 1) {
-        psError(__func__,"psListAlloc didn't create a list properly.");
-        return 2;
-    }
-
-    list = psListAdd(list, NULL,PS_LIST_HEAD);
-
-    if (list->size != 1) {
-        psError(__func__,"psListAdd with a NULL data element changed the list size.");
-        return 3;
-    }
-
-    //  3. where is PS_LIST_HEAD or PS_LIST_TAIL
-    data = psAlloc(sizeof(int));
-    *data = 2;
-    list = psListAdd(list,data,PS_LIST_HEAD);
-
-    // verify that the size incremented
-    if (list->size != 2) {
-        psError(__func__,"psListAdd didn't increment the size by one");
-        return 4;
-    }
-
-    // verify that the head is the inserted data item
-    if (*(int*)list->head->data != 2) {
-        psError(__func__,"psListAdd with PS_LIST_HEAD didn't insert at the head.");
-        return 5;
-    }
-
-    data = psAlloc(sizeof(int));
-    *data = 3;
-    list = psListAdd(list,data,PS_LIST_TAIL);
-
-    // verify that the size incremented
-    if (list->size != 3) {
-        psError(__func__,"psListAdd didn't increment the size by 1");
-        return 6;
-    }
-
-    // verify that the head is still the same
-    if (*(int*)list->head->data != 2) {
-        psError(__func__,"psListAdd with PS_LIST_TAIL modified the head.");
-        return 7;
-    }
-
-    // verify that the tail is the data item inserted
-    if (*(int*)list->tail->data != 3) {
-        psError(__func__,"psListAdd with PS_LIST_TAIL didn't insert at the tail.");
-        return 8;
-    }
-
-    // 4. where is not PS_LIST_* but <0
-
-    data = psAlloc(sizeof(int));
-    *data = 4;
-
-    psLogMsg(__func__,PS_LOG_INFO,"Following should warn with invalid insert location");
-    list = psListAdd(list,data,-10);
-    // verify that the size incremented
-    if (list->size != 4 || *(int*)list->head->data != 4) {
-        printListInt(list);
-        psError(__func__,"psListAdd didn't insert to head when where was invalid.");
-        return 9;
-    }
-
-    // 5. where is >0
-    data = psAlloc(sizeof(int));
-    *data = 5;
-    list = psListAdd(list,data,1);
-    // verify that the size incremented
-    if (list->size != 5 || *(int*)list->head->next->data != 5) {
-        printListInt(list);
-        psError(__func__,"psListAdd didn't insert to position #1.");
-        return 9;
-    }
-
-    data = psAlloc(sizeof(int));
-    *data = 6;
-    list = psListAdd(list,data,4);
-    // verify that the size incremented
-    if (list->size != 6  || *(int *)list->head->next->next->next->next->data != 6) {
-        printListInt(list);
-        psError(__func__,"psListAdd didn't insert to position #4.");
-        return 9;
-    }
-
-    data = psAlloc(sizeof(int));
-    *data = 7;
-    list = psListAdd(list,data,2);
-    // verify that the size incremented
-    if (list->size != 7  || *(int *)list->head->next->next->data != 7) {
-        printListInt(list);
-        psError(__func__,"psListAdd didn't insert to position #2.");
-        return 9;
-    }
-
-    data = psAlloc(sizeof(int));
-    *data = 7;
-    psLogMsg(__func__,PS_LOG_INFO,"Following should be a warning.");
-    list = psListAdd(list,data,9);
-    // verify that the size incremented
-    if (list->size != 8) {
-        printListInt(list);
-        psError(__func__,"psListAdd didn't insert to position #9.");
-        return 9;
-    }
-
-    psListFree(list, PS_FREE);
-
-    psMemCheckLeaks(currentId,NULL,NULL);
-    psMemCheckCorruption(1);
-
-    return 0;
-}
-
-void printListInt(psList* list)
-{
-    int* data = NULL;
-    bool first = true;
-
-    psListSetIterator(list,PS_LIST_HEAD);
-    data = psListGetCurrent(list);
-
-    while ( data != NULL ) {
-        if (!first) {
-            printf(", %d",*(int*)data);
-        } else {
-            printf("%d",*(int*)data);
-            first = false;
-        }
-        data = psListGetNext(list);
-    }
-
-    printf(".\n");
-}
-
-
-int testListGet(void)
-{
-    int currentId = psMemGetId();
-    psList* list = NULL;
-    int* data;
-
-    /*
-     psListGet(list,which) shall be tested with the following instances
-
-        1. list is NULL.
-        2. which>0 and which<list.n.
-        3. which>list.n.
-        4. which=PS_LIST_HEAD
-        5. which=PS_LIST_NEXT
-        6. which=PS_LIST_TAIL
-        7. which=PS_LIST_PREV
-        8. which<0 and not any PS_LIST_* values
-    */
-
-    //  1. list is NULL.
-    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error");
-    if (psListGet(list,PS_LIST_HEAD) != NULL) {
-        psError(__func__,"psListGet didn't return NULL given a NULL list.");
-        return 1;
-    };
-
-    // create a list
-    data = psAlloc(sizeof(int));
-    *data = 0;
-    list = psListAlloc(data);
-
-    data = psAlloc(sizeof(int));
-    *data = 1;
-    list = psListAdd(list,data,PS_LIST_TAIL);
-
-    data = psAlloc(sizeof(int));
-    *data = 2;
-    list = psListAdd(list,data,PS_LIST_TAIL);
-
-    data = psAlloc(sizeof(int));
-    *data = 3;
-    list = psListAdd(list,data,PS_LIST_TAIL);
-
-    //  2. which>0 and which<list.n.
-    data = (int*)psListGet(list,3);
-    if (data == NULL || *data != 3) {
-        psError(__func__,"psListGet failed with which=3");
-        return 2;
-    }
-    data = (int*)psListGet(list,1);
-    if (data == NULL || *data != 1) {
-        psError(__func__,"psListGet failed with which=1");
-        return 3;
-    }
-
-    //  3. which>=list.n.
-    data = (int*)psListGet(list,5);
-    if (data != NULL) {
-        psError(__func__,"psListGet failed with which=5");
-        return 4;
-    }
-    data = (int*)psListGet(list,4);
-    if (data != NULL) {
-        psError(__func__,"psListGet failed with which=4");
-        return 5;
-    }
-
-    //  4. which=PS_LIST_HEAD
-    data = (int*)psListGet(list,PS_LIST_HEAD);
-    if (data == NULL || *data != 0) {
-        psError(__func__,"psListGet failed with which=PS_LIST_HEAD");
-        return 6;
-    }
-
-    //  5. which=PS_LIST_NEXT
-    data = (int*)psListGet(list,PS_LIST_NEXT);
-    if (data == NULL || *data != 1) {
-        psError(__func__,"psListGet failed with which=PS_LIST_NEXT");
-        return 7;
-    }
-
-    //  6. which=PS_LIST_TAIL
-    data = (int*)psListGet(list,PS_LIST_TAIL);
-    if (data == NULL || *data != 3) {
-        psError(__func__,"psListGet failed with which=PS_LIST_TAIL");
-        return 8;
-    }
-
-    //  7. which=PS_LIST_PREV
-    data = (int*)psListGet(list,PS_LIST_PREVIOUS);
-    if (data == NULL || *data != 2) {
-        psError(__func__,"psListGet failed with which=PS_LIST_PREV");
-        return 9;
-    }
-
-    psListFree(list,PS_FREE);
-
-    psMemCheckLeaks(currentId,NULL,NULL);
-    psMemCheckCorruption(1);
-
-    return 0;
-}
-
-int testListRemove(void)
-{
-    int currentId = psMemGetId();
-    psList* list = NULL;
-    int* data;
-
-    /*
-        psListRemove(list,data,which) should be tested under the following conditions:
-
-        1. list is NULL
-        2. which is PS_LIST_HEAD (remove first element of list)
-        3. which is PS_LIST_TAIL (remove last element of list)
-        4. which is PS_LIST_NEXT (element right of cursor [which should be head,tail, and neither])
-        5. which is PS_LIST_PREV (element left of cursor [which should be head,tail, and neither])
-        6. which is PS_LIST_UNKNOWN and data=NULL (error)
-        7. which is PS_LIST_UNKNOWN and data=[head,tail,other list items]
-        8. which is PS_LIST_UNKNOWN and data!=NULL and data!=any element in list
-
-        In all conditions that are not an error, list.n shall be decremented and only the specified element
-        shall be removed. After each step, list.n should be checked to verify that it is the true
-        number of elements in list.
-    */
-
-    //  1. list is NULL.
-    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error");
-    if (psListRemove(list,NULL,PS_LIST_HEAD) != NULL) {
-        psError(__func__,"psListGet didn't return NULL given a NULL list.");
-        return 1;
-    };
-
-    // create a list
-    list = psListAlloc(NULL);
-
-    for (int lcv=0;lcv<15;lcv++) {
-        data = psAlloc(sizeof(int));
-        *data = lcv;
-        list = psListAdd(list,data,PS_LIST_TAIL);
-        psMemDecrRefCounter(data);
-    }
-
-
-    // 2. which is PS_LIST_HEAD (remove first element of list)
-    data = psListRemove(list,NULL,PS_LIST_HEAD);
-    if (data == NULL || *data != 0) {
-        printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_HEAD");
-        return 1;
-    }
-    psFree(data);
-    if (list->size != 14) {
-        printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 14.");
-        return 1;
-    }
-
-    // 3. which is PS_LIST_TAIL (remove last element of list)
-    data = psListRemove(list,NULL,PS_LIST_TAIL);
-    if (data == NULL || *data != 14) {
-        printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_TAIL");
-        return 1;
-    }
-    psFree(data);
-    if (list->size != 13) {
-        printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 13.");
-        return 1;
-    }
-
-    // 4. which is PS_LIST_NEXT (element right of cursor [which should be head,tail, and neither])
-    psListSetIterator(list,PS_LIST_HEAD);
-    data = psListRemove(list,NULL,PS_LIST_NEXT);
-    if (data == NULL || *data != 2) {
-        printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_NEXT @ PS_LIST_HEAD");
-        return 1;
-    }
-    psFree(data);
-    if (list->size != 12) {
-        printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 12.");
-        return 1;
-    }
-
-    psListSetIterator(list,PS_LIST_TAIL);
-    psLogMsg(__func__,PS_LOG_INFO,"Next message should be an error");
-    data = psListRemove(list,NULL,PS_LIST_NEXT);
-    if (data != NULL) {
-        printListInt(list);
-        psError(__func__,"Removed something with PS_LIST_NEXT @ PS_LIST_TAIL");
-        return 1;
-    }
-
-    psListSetIterator(list,2);
-    data = psListRemove(list,NULL,PS_LIST_NEXT);
-    if (data == NULL || *data != 5) {
-        printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_NEXT @ which=2");
-        return 1;
-    }
-    psFree(data);
-    if (list->size != 11) {
-        printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 11.");
-        return 1;
-    }
-
-    // 5. which is PS_LIST_PREV (element left of cursor [which should be head,tail, and neither])
-    psListSetIterator(list,PS_LIST_HEAD);
-    psLogMsg(__func__,PS_LOG_INFO,"Next message should be an error");
-    data = psListRemove(list,NULL,PS_LIST_PREVIOUS);
-    if (data != NULL) {
-        printListInt(list);
-        psError(__func__,"removed something for PS_LIST_PREVIOUS @ PS_LIST_HEAD");
-        return 1;
-    }
-
-    psListSetIterator(list,PS_LIST_TAIL);
-    data = psListRemove(list,NULL,PS_LIST_PREVIOUS);
-    if (data == NULL || *data != 12) {
-        printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_PREVIOUS @ PS_LIST_TAIL");
-        return 1;
-    }
-    psFree(data);
-    if (list->size != 10) {
-        printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 10.");
-        return 1;
-    }
-
-    psListSetIterator(list,2);
-    data = psListRemove(list,NULL,PS_LIST_PREVIOUS);
-    if (data == NULL || *data != 3) {
-        printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_PREVIOUS @ which=2");
-        return 1;
-    }
-    psFree(data);
-    if (list->size != 9) {
-        printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 9.");
-        return 1;
-    }
-
-    // 6. which is PS_LIST_UNKNOWN and data=NULL (error)
-    psLogMsg(__func__,PS_LOG_INFO,"Next message should be an error");
-    data = psListRemove(list,NULL,PS_LIST_UNKNOWN);
-    if (data != NULL) {
-        printListInt(list);
-        psError(__func__,"removed something for PS_LIST_UNKNOWN with data=NULL");
-        return 1;
-    }
-
-    // 7. which is PS_LIST_UNKNOWN and data=[head,tail,other list items]
-    data = psListGet(list,PS_LIST_HEAD);
-    data = psListRemove(list,data,PS_LIST_UNKNOWN);
-    if (data == NULL || *data != 1) {
-        printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_HEAD");
-        return 1;
-    }
-    psFree(data);
-    if (list->size != 8) {
-        printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 8.");
-        return 1;
-    }
-
-    data = psListGet(list,PS_LIST_TAIL);
-    data = psListRemove(list,data,PS_LIST_UNKNOWN);
-    if (data == NULL || *data != 13) {
-        printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_TAIL");
-        return 1;
-    }
-    psFree(data);
-    if (list->size != 7) {
-        printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 7.");
-        return 1;
-    }
-
-    psListSetIterator(list,PS_LIST_HEAD);
-    data = psListGet(list,PS_LIST_NEXT);
-
-    data = psListRemove(list,data,PS_LIST_UNKNOWN);
-    if (data == NULL || *data != 6) {
-        printListInt(list);
-        psError(__func__,"Failed to remove PS_LIST_UNKNOWN @ which=1");
-        return 1;
-    }
-    psFree(data);
-    if (list->size != 6) {
-        printListInt(list);
-        psError(__func__,"Didn't decrement size properly to 6.");
-        return 1;
-    }
-
-    // 8. which is PS_LIST_UNKNOWN and data!=NULL and data!=any element in list
-    psLogMsg(__func__,PS_LOG_INFO,"Next message should be an error");
-    data = psListRemove(list,data,PS_LIST_UNKNOWN);
-    if (data != NULL) {
-        printListInt(list);
-        psError(__func__,"removed something for PS_LIST_UNKNOWN with previously removed item");
-        return 1;
-    }
-
-    // clear out the list
-    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
-    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
-    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
-    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
-    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
-
-    data = psListRemove(list,data,PS_LIST_HEAD);
-    if (data == NULL || *data != 11) {
-        printListInt(list);
-        psError(__func__,"Failed to remove last element");
-        return 1;
-    }
-    psFree(data);
-
-    if (list->size != 0) {
-        printListInt(list);
-        psError(__func__,"Didn't remove all the elements.");
-        return 1;
-    }
-
-    psListFree(list,PS_FREE);
-
-    psMemCheckLeaks(currentId,NULL,NULL);
-    psMemCheckCorruption(1);
-
-    return 0;
-
-}
-
-int testListConvert(void)
-{
-
-    int currentId = psMemGetId();
-    psList* list = NULL;
-    psVector* vec = NULL;
-    int* data;
-
-    /*
-        array=psListToArray(list) shall take each element of the list, increment
-        their reference, and insert them into the returned fresh void* array.
-        The list shall not be changed, except for the element reference increment.
-    */
-
-    // test dlist -> vector
-
-    // create a list
-    list = psListAlloc(NULL);
-    for (int lcv=0;lcv<15;lcv++) {
-        data = psAlloc(sizeof(int));
-        *data = lcv;
-        list = psListAdd(list,data,PS_LIST_TAIL);
-        psMemDecrRefCounter(data);
-    }
-
-    vec = psListToVector(list);
-
-    if (vec->n != 15 || list->size != 15) {
-        psError(__func__,"The created vector didn't have the proper size");
-        return 1;
-    }
-    for (int i=0;i<vec->n;i++) {
-        if (i != *(int*)vec->data.PTR[i]) {
-            psError(__func__,"Element %d of vector is incorrect (%d).",
-                    i,*(int*)vec->data.PTR[i]);
-            return 1;
-        }
-        if (i != *(int*)psListGet(list,i)) {
-            psError(__func__,"Element %d of list is incorrect (%d).",
-                    i,*(int*)vec->data.PTR[i]);
-            return 1;
-        }
-        if (psMemGetRefCounter(vec->data.PTR[i]) != 2) {
-            psError(__func__,"Element %d had wrong reference count (%d).",
-                    i,psMemGetRefCounter(vec->data.PTR[i]));
-            return 1;
-        }
-    }
-
-    psVectorFree(vec);
-    psListFree(list,PS_FREE);
-
-    psMemCheckLeaks(currentId,NULL,NULL);
-    psMemCheckCorruption(1);
-
-    // test vector -> dlist
-
-    // create a vector
-    vec = psVectorAlloc(15,PS_TYPE_PTR);
-    vec->n = vec->nalloc;
-    for (int lcv=0;lcv<15;lcv++) {
-        data = psAlloc(sizeof(int));
-        *data = lcv;
-        vec->data.PTR[lcv] = data;
-    }
-
-    list = psVectorToDlist(vec);
-
-    if (vec->n != 15 || list->size != 15) {
-        psError(__func__,"The created vector didn't have the proper size");
-        return 1;
-    }
-    for (int i=0;i<vec->n;i++) {
-        if (i != *(int*)vec->data.PTR[i]) {
-            psError(__func__,"Element %d of vector is incorrect (%d).",
-                    i,*(int*)vec->data.PTR[i]);
-            return 1;
-        }
-        if (i != *(int*)psListGet(list,i)) {
-            psError(__func__,"Element %d of list is incorrect (%d).",
-                    i,*(int*)vec->data.PTR[i]);
-            return 1;
-        }
-        if (psMemGetRefCounter(vec->data.PTR[i]) != 2) {
-            psError(__func__,"Element %d had wrong reference count (%d).",
-                    i,psMemGetRefCounter(vec->data.PTR[i]));
-            return 1;
-        }
-    }
-
-    psVectorFree(vec);
-    psListFree(list,PS_FREE);
-
-    // now, make sure if input vector/list is NULL, output is NULL
-
-    vec = psListToVector(NULL);
-    if (vec != NULL) {
-        psError(__func__,"psListToVector didn't return NULL when given NULL");
-        return 1;
-    }
-
-    list = psVectorToDlist(NULL);
-    if (list != NULL) {
-        psError(__func__,"psVectorToDlist didn't return NULL when given NULL");
-        return 1;
-    }
-
-    // now, see what happens with a zero-size vector/list
-    vec = psVectorAlloc(1,PS_TYPE_PTR);
-    vec->n = 0;
-    list = psVectorToDlist(vec);
-    if (list == NULL) {
-        psError(__func__,"psVectorToDlist didn't create an empty list from an "
-                "empty vector.");
-        return 1;
-    }
-    psVectorFree(vec);
-    psListFree(list,PS_FREE);
-
-    list = psListAlloc(NULL);
-    vec = psListToVector(list);
-    if (vec == NULL) {
-        psError(__func__,"psVectorToDlist didn't create an empty vector from an "
-                "empty list.");
-        return 1;
-    }
-    psVectorFree(vec);
-    psListFree(list,PS_FREE);
-
-    psMemCheckLeaks(currentId,NULL,NULL);
-    psMemCheckCorruption(1);
-
-    return 0;
-}
-
-int testListIterator(void)
-{
-    int currentId = psMemGetId();
-
-    psLogMsg(__func__,PS_LOG_INFO," psListSetIterator/psListGetNext/psListGetPrev"
-             " shall move the list cursor to the specified location");
-
-    psMemCheckLeaks(currentId,NULL,NULL);
-    psMemCheckCorruption(1);
-
-    return 0;
-}
Index: /trunk/psLib/test/collections/tst_psList.c
===================================================================
--- /trunk/psLib/test/collections/tst_psList.c	(revision 921)
+++ /trunk/psLib/test/collections/tst_psList.c	(revision 921)
@@ -0,0 +1,770 @@
+/** @file  tst_psList.c
+ *
+ *  @brief Contains the tests for psList.[ch]
+ *
+ *
+ *  @author Robert DeSonia, MHPCC
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-08 19:12:05 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+#include "psTest.h"
+#include "pslib.h"
+
+void printListInt(psList* list);
+
+
+static int testListAlloc(void);
+static int testListAdd(void);
+static int testListGet(void);
+static int testListRemove(void);
+static int testListConvert(void);
+static int testListIterator(void);
+
+testDescription tests[] = {
+                              {testListAlloc,"487-testListAlloc",0},
+                              {testListAdd,"488-testListAdd",0},
+                              {testListGet,"489-testListGet",0},
+                              {testListRemove,"490-testListRemove",0},
+                              {testListConvert,"491-testListConvert",0},
+                              {testListIterator,"494-testListIterator",0},
+                              {NULL}
+                          };
+
+int main()
+{
+    psSetLogLevel(PS_LOG_INFO);
+
+    if (! runTestSuite(stderr,"psList",tests)) {
+        psAbort(__FILE__,"One or more tests failed");
+    }
+    return 0;
+}
+
+int testListAlloc(void)
+{
+    int currentId = psMemGetId();
+    psList* list;
+    int ref;
+    float* data;
+
+    psLogMsg(__func__,PS_LOG_INFO,"psListAlloc shall create a psList with either 0 or 1 element.");
+
+    data = psAlloc(sizeof(float));
+
+    // if psListAlloc is invoked with a NULL parameter, it shall return an
+    // empty psList struct with head=tail=NULL and n=0. Otherwise, it shall
+    // return a psList of one element (head=tail=data, n=1).
+
+    list = psListAlloc(NULL);
+    if (list == NULL) {
+        psError(__func__,"psListAlloc failed to return a list.");
+        return 1;
+    }
+
+    if (list->head != NULL || list->tail != NULL) {
+        psError(__func__,"head and/or tail was not NULL for empty list.");
+        return 2;
+    }
+
+    if (list->size != 0) {
+        psError(__func__,"size of list wasn't zero for empty list.");
+        return 3;
+    }
+
+    psListFree(list,NULL);
+
+    list = psListAlloc(data);
+    if (list == NULL) {
+        psError(__func__,"psListAlloc failed to return a list.");
+        return 4;
+    }
+
+    if (list->head == NULL || list->tail == NULL) {
+        psError(__func__,"head and/or tail was NULL for one-element new list.");
+        return 5;
+    }
+
+    if (list->head->data != data || list->tail->data != data) {
+        psError(__func__,"head and/or tail didn't point to data's node for one-element new list.");
+        return 6;
+    }
+
+    if (list->size != 1) {
+        psError(__func__,"size of list wasn't correctly set for new, one-element list.");
+        return 7;
+    }
+
+    ref = psMemGetRefCounter(data);
+    if (ref != 2) {
+        psError(__func__,"psList didn't increment reference count of data (%d.",ref);
+        return 8;
+    }
+
+
+    psListFree(list,PS_FREE);
+
+    psMemCheckLeaks(currentId,NULL,NULL);
+    psMemCheckCorruption(1);
+
+    return 0;
+}
+
+int testListAdd(void)
+{
+    int currentId = psMemGetId();
+    psList* list = NULL;
+    int* data;
+
+    psLogMsg(__func__,PS_LOG_INFO,"psListAdd shall add an element to list");
+
+    /*
+        psListAdd(list,data,where) should be tested in the instance where:
+
+        1. list is NULL (error)
+        2. data is NULL (error, list should not grow)
+        3. where is PS_LIST_HEAD or PS_LIST_TAIL
+        4. where is not PS_LIST_* but <0
+        5. where is >0
+    */
+
+    //  1. list is NULL (error)
+    list = psListAdd(NULL,data,PS_LIST_HEAD);
+
+    if (list != NULL) {
+        psError(__func__,"psListAdd was given a NULL list, but returned a non-NULL list.");
+        return 1;
+    }
+
+    //  2. data is NULL (error, list should not grow)
+    data = psAlloc(sizeof(int));
+    *data = 1;
+    list = psListAlloc(data);
+    if (list->size != 1) {
+        psError(__func__,"psListAlloc didn't create a list properly.");
+        return 2;
+    }
+
+    list = psListAdd(list, NULL,PS_LIST_HEAD);
+
+    if (list->size != 1) {
+        psError(__func__,"psListAdd with a NULL data element changed the list size.");
+        return 3;
+    }
+
+    //  3. where is PS_LIST_HEAD or PS_LIST_TAIL
+    data = psAlloc(sizeof(int));
+    *data = 2;
+    list = psListAdd(list,data,PS_LIST_HEAD);
+
+    // verify that the size incremented
+    if (list->size != 2) {
+        psError(__func__,"psListAdd didn't increment the size by one");
+        return 4;
+    }
+
+    // verify that the head is the inserted data item
+    if (*(int*)list->head->data != 2) {
+        psError(__func__,"psListAdd with PS_LIST_HEAD didn't insert at the head.");
+        return 5;
+    }
+
+    data = psAlloc(sizeof(int));
+    *data = 3;
+    list = psListAdd(list,data,PS_LIST_TAIL);
+
+    // verify that the size incremented
+    if (list->size != 3) {
+        psError(__func__,"psListAdd didn't increment the size by 1");
+        return 6;
+    }
+
+    // verify that the head is still the same
+    if (*(int*)list->head->data != 2) {
+        psError(__func__,"psListAdd with PS_LIST_TAIL modified the head.");
+        return 7;
+    }
+
+    // verify that the tail is the data item inserted
+    if (*(int*)list->tail->data != 3) {
+        psError(__func__,"psListAdd with PS_LIST_TAIL didn't insert at the tail.");
+        return 8;
+    }
+
+    // 4. where is not PS_LIST_* but <0
+
+    data = psAlloc(sizeof(int));
+    *data = 4;
+
+    psLogMsg(__func__,PS_LOG_INFO,"Following should warn with invalid insert location");
+    list = psListAdd(list,data,-10);
+    // verify that the size incremented
+    if (list->size != 4 || *(int*)list->head->data != 4) {
+        printListInt(list);
+        psError(__func__,"psListAdd didn't insert to head when where was invalid.");
+        return 9;
+    }
+
+    // 5. where is >0
+    data = psAlloc(sizeof(int));
+    *data = 5;
+    list = psListAdd(list,data,1);
+    // verify that the size incremented
+    if (list->size != 5 || *(int*)list->head->next->data != 5) {
+        printListInt(list);
+        psError(__func__,"psListAdd didn't insert to position #1.");
+        return 9;
+    }
+
+    data = psAlloc(sizeof(int));
+    *data = 6;
+    list = psListAdd(list,data,4);
+    // verify that the size incremented
+    if (list->size != 6  || *(int *)list->head->next->next->next->next->data != 6) {
+        printListInt(list);
+        psError(__func__,"psListAdd didn't insert to position #4.");
+        return 9;
+    }
+
+    data = psAlloc(sizeof(int));
+    *data = 7;
+    list = psListAdd(list,data,2);
+    // verify that the size incremented
+    if (list->size != 7  || *(int *)list->head->next->next->data != 7) {
+        printListInt(list);
+        psError(__func__,"psListAdd didn't insert to position #2.");
+        return 9;
+    }
+
+    data = psAlloc(sizeof(int));
+    *data = 7;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be a warning.");
+    list = psListAdd(list,data,9);
+    // verify that the size incremented
+    if (list->size != 8) {
+        printListInt(list);
+        psError(__func__,"psListAdd didn't insert to position #9.");
+        return 9;
+    }
+
+    psListFree(list, PS_FREE);
+
+    psMemCheckLeaks(currentId,NULL,NULL);
+    psMemCheckCorruption(1);
+
+    return 0;
+}
+
+void printListInt(psList* list)
+{
+    int* data = NULL;
+    bool first = true;
+
+    psListSetIterator(list,PS_LIST_HEAD);
+    data = psListGetCurrent(list);
+
+    while ( data != NULL ) {
+        if (!first) {
+            printf(", %d",*(int*)data);
+        } else {
+            printf("%d",*(int*)data);
+            first = false;
+        }
+        data = psListGetNext(list);
+    }
+
+    printf(".\n");
+}
+
+
+int testListGet(void)
+{
+    int currentId = psMemGetId();
+    psList* list = NULL;
+    int* data;
+
+    /*
+     psListGet(list,which) shall be tested with the following instances
+
+        1. list is NULL.
+        2. which>0 and which<list.n.
+        3. which>list.n.
+        4. which=PS_LIST_HEAD
+        5. which=PS_LIST_NEXT
+        6. which=PS_LIST_TAIL
+        7. which=PS_LIST_PREV
+        8. which<0 and not any PS_LIST_* values
+    */
+
+    //  1. list is NULL.
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error");
+    if (psListGet(list,PS_LIST_HEAD) != NULL) {
+        psError(__func__,"psListGet didn't return NULL given a NULL list.");
+        return 1;
+    };
+
+    // create a list
+    data = psAlloc(sizeof(int));
+    *data = 0;
+    list = psListAlloc(data);
+
+    data = psAlloc(sizeof(int));
+    *data = 1;
+    list = psListAdd(list,data,PS_LIST_TAIL);
+
+    data = psAlloc(sizeof(int));
+    *data = 2;
+    list = psListAdd(list,data,PS_LIST_TAIL);
+
+    data = psAlloc(sizeof(int));
+    *data = 3;
+    list = psListAdd(list,data,PS_LIST_TAIL);
+
+    //  2. which>0 and which<list.n.
+    data = (int*)psListGet(list,3);
+    if (data == NULL || *data != 3) {
+        psError(__func__,"psListGet failed with which=3");
+        return 2;
+    }
+    data = (int*)psListGet(list,1);
+    if (data == NULL || *data != 1) {
+        psError(__func__,"psListGet failed with which=1");
+        return 3;
+    }
+
+    //  3. which>=list.n.
+    data = (int*)psListGet(list,5);
+    if (data != NULL) {
+        psError(__func__,"psListGet failed with which=5");
+        return 4;
+    }
+    data = (int*)psListGet(list,4);
+    if (data != NULL) {
+        psError(__func__,"psListGet failed with which=4");
+        return 5;
+    }
+
+    //  4. which=PS_LIST_HEAD
+    data = (int*)psListGet(list,PS_LIST_HEAD);
+    if (data == NULL || *data != 0) {
+        psError(__func__,"psListGet failed with which=PS_LIST_HEAD");
+        return 6;
+    }
+
+    //  5. which=PS_LIST_NEXT
+    data = (int*)psListGet(list,PS_LIST_NEXT);
+    if (data == NULL || *data != 1) {
+        psError(__func__,"psListGet failed with which=PS_LIST_NEXT");
+        return 7;
+    }
+
+    //  6. which=PS_LIST_TAIL
+    data = (int*)psListGet(list,PS_LIST_TAIL);
+    if (data == NULL || *data != 3) {
+        psError(__func__,"psListGet failed with which=PS_LIST_TAIL");
+        return 8;
+    }
+
+    //  7. which=PS_LIST_PREV
+    data = (int*)psListGet(list,PS_LIST_PREVIOUS);
+    if (data == NULL || *data != 2) {
+        psError(__func__,"psListGet failed with which=PS_LIST_PREV");
+        return 9;
+    }
+
+    psListFree(list,PS_FREE);
+
+    psMemCheckLeaks(currentId,NULL,NULL);
+    psMemCheckCorruption(1);
+
+    return 0;
+}
+
+int testListRemove(void)
+{
+    int currentId = psMemGetId();
+    psList* list = NULL;
+    int* data;
+
+    /*
+        psListRemove(list,data,which) should be tested under the following conditions:
+
+        1. list is NULL
+        2. which is PS_LIST_HEAD (remove first element of list)
+        3. which is PS_LIST_TAIL (remove last element of list)
+        4. which is PS_LIST_NEXT (element right of cursor [which should be head,tail, and neither])
+        5. which is PS_LIST_PREV (element left of cursor [which should be head,tail, and neither])
+        6. which is PS_LIST_UNKNOWN and data=NULL (error)
+        7. which is PS_LIST_UNKNOWN and data=[head,tail,other list items]
+        8. which is PS_LIST_UNKNOWN and data!=NULL and data!=any element in list
+
+        In all conditions that are not an error, list.n shall be decremented and only the specified element
+        shall be removed. After each step, list.n should be checked to verify that it is the true
+        number of elements in list.
+    */
+
+    //  1. list is NULL.
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error");
+    if (psListRemove(list,NULL,PS_LIST_HEAD) != NULL) {
+        psError(__func__,"psListGet didn't return NULL given a NULL list.");
+        return 1;
+    };
+
+    // create a list
+    list = psListAlloc(NULL);
+
+    for (int lcv=0;lcv<15;lcv++) {
+        data = psAlloc(sizeof(int));
+        *data = lcv;
+        list = psListAdd(list,data,PS_LIST_TAIL);
+        psMemDecrRefCounter(data);
+    }
+
+
+    // 2. which is PS_LIST_HEAD (remove first element of list)
+    data = psListRemove(list,NULL,PS_LIST_HEAD);
+    if (data == NULL || *data != 0) {
+        printListInt(list);
+        psError(__func__,"Failed to remove PS_LIST_HEAD");
+        return 1;
+    }
+    psFree(data);
+    if (list->size != 14) {
+        printListInt(list);
+        psError(__func__,"Didn't decrement size properly to 14.");
+        return 1;
+    }
+
+    // 3. which is PS_LIST_TAIL (remove last element of list)
+    data = psListRemove(list,NULL,PS_LIST_TAIL);
+    if (data == NULL || *data != 14) {
+        printListInt(list);
+        psError(__func__,"Failed to remove PS_LIST_TAIL");
+        return 1;
+    }
+    psFree(data);
+    if (list->size != 13) {
+        printListInt(list);
+        psError(__func__,"Didn't decrement size properly to 13.");
+        return 1;
+    }
+
+    // 4. which is PS_LIST_NEXT (element right of cursor [which should be head,tail, and neither])
+    psListSetIterator(list,PS_LIST_HEAD);
+    data = psListRemove(list,NULL,PS_LIST_NEXT);
+    if (data == NULL || *data != 2) {
+        printListInt(list);
+        psError(__func__,"Failed to remove PS_LIST_NEXT @ PS_LIST_HEAD");
+        return 1;
+    }
+    psFree(data);
+    if (list->size != 12) {
+        printListInt(list);
+        psError(__func__,"Didn't decrement size properly to 12.");
+        return 1;
+    }
+
+    psListSetIterator(list,PS_LIST_TAIL);
+    psLogMsg(__func__,PS_LOG_INFO,"Next message should be an error");
+    data = psListRemove(list,NULL,PS_LIST_NEXT);
+    if (data != NULL) {
+        printListInt(list);
+        psError(__func__,"Removed something with PS_LIST_NEXT @ PS_LIST_TAIL");
+        return 1;
+    }
+
+    psListSetIterator(list,2);
+    data = psListRemove(list,NULL,PS_LIST_NEXT);
+    if (data == NULL || *data != 5) {
+        printListInt(list);
+        psError(__func__,"Failed to remove PS_LIST_NEXT @ which=2");
+        return 1;
+    }
+    psFree(data);
+    if (list->size != 11) {
+        printListInt(list);
+        psError(__func__,"Didn't decrement size properly to 11.");
+        return 1;
+    }
+
+    // 5. which is PS_LIST_PREV (element left of cursor [which should be head,tail, and neither])
+    psListSetIterator(list,PS_LIST_HEAD);
+    psLogMsg(__func__,PS_LOG_INFO,"Next message should be an error");
+    data = psListRemove(list,NULL,PS_LIST_PREVIOUS);
+    if (data != NULL) {
+        printListInt(list);
+        psError(__func__,"removed something for PS_LIST_PREVIOUS @ PS_LIST_HEAD");
+        return 1;
+    }
+
+    psListSetIterator(list,PS_LIST_TAIL);
+    data = psListRemove(list,NULL,PS_LIST_PREVIOUS);
+    if (data == NULL || *data != 12) {
+        printListInt(list);
+        psError(__func__,"Failed to remove PS_LIST_PREVIOUS @ PS_LIST_TAIL");
+        return 1;
+    }
+    psFree(data);
+    if (list->size != 10) {
+        printListInt(list);
+        psError(__func__,"Didn't decrement size properly to 10.");
+        return 1;
+    }
+
+    psListSetIterator(list,2);
+    data = psListRemove(list,NULL,PS_LIST_PREVIOUS);
+    if (data == NULL || *data != 3) {
+        printListInt(list);
+        psError(__func__,"Failed to remove PS_LIST_PREVIOUS @ which=2");
+        return 1;
+    }
+    psFree(data);
+    if (list->size != 9) {
+        printListInt(list);
+        psError(__func__,"Didn't decrement size properly to 9.");
+        return 1;
+    }
+
+    // 6. which is PS_LIST_UNKNOWN and data=NULL (error)
+    psLogMsg(__func__,PS_LOG_INFO,"Next message should be an error");
+    data = psListRemove(list,NULL,PS_LIST_UNKNOWN);
+    if (data != NULL) {
+        printListInt(list);
+        psError(__func__,"removed something for PS_LIST_UNKNOWN with data=NULL");
+        return 1;
+    }
+
+    // 7. which is PS_LIST_UNKNOWN and data=[head,tail,other list items]
+    data = psListGet(list,PS_LIST_HEAD);
+    data = psListRemove(list,data,PS_LIST_UNKNOWN);
+    if (data == NULL || *data != 1) {
+        printListInt(list);
+        psError(__func__,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_HEAD");
+        return 1;
+    }
+    psFree(data);
+    if (list->size != 8) {
+        printListInt(list);
+        psError(__func__,"Didn't decrement size properly to 8.");
+        return 1;
+    }
+
+    data = psListGet(list,PS_LIST_TAIL);
+    data = psListRemove(list,data,PS_LIST_UNKNOWN);
+    if (data == NULL || *data != 13) {
+        printListInt(list);
+        psError(__func__,"Failed to remove PS_LIST_UNKNOWN @ PS_LIST_TAIL");
+        return 1;
+    }
+    psFree(data);
+    if (list->size != 7) {
+        printListInt(list);
+        psError(__func__,"Didn't decrement size properly to 7.");
+        return 1;
+    }
+
+    psListSetIterator(list,PS_LIST_HEAD);
+    data = psListGet(list,PS_LIST_NEXT);
+
+    data = psListRemove(list,data,PS_LIST_UNKNOWN);
+    if (data == NULL || *data != 6) {
+        printListInt(list);
+        psError(__func__,"Failed to remove PS_LIST_UNKNOWN @ which=1");
+        return 1;
+    }
+    psFree(data);
+    if (list->size != 6) {
+        printListInt(list);
+        psError(__func__,"Didn't decrement size properly to 6.");
+        return 1;
+    }
+
+    // 8. which is PS_LIST_UNKNOWN and data!=NULL and data!=any element in list
+    psLogMsg(__func__,PS_LOG_INFO,"Next message should be an error");
+    data = psListRemove(list,data,PS_LIST_UNKNOWN);
+    if (data != NULL) {
+        printListInt(list);
+        psError(__func__,"removed something for PS_LIST_UNKNOWN with previously removed item");
+        return 1;
+    }
+
+    // clear out the list
+    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
+    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
+    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
+    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
+    psFree(psListRemove(list,NULL,PS_LIST_HEAD));
+
+    data = psListRemove(list,data,PS_LIST_HEAD);
+    if (data == NULL || *data != 11) {
+        printListInt(list);
+        psError(__func__,"Failed to remove last element");
+        return 1;
+    }
+    psFree(data);
+
+    if (list->size != 0) {
+        printListInt(list);
+        psError(__func__,"Didn't remove all the elements.");
+        return 1;
+    }
+
+    psListFree(list,PS_FREE);
+
+    psMemCheckLeaks(currentId,NULL,NULL);
+    psMemCheckCorruption(1);
+
+    return 0;
+
+}
+
+int testListConvert(void)
+{
+
+    int currentId = psMemGetId();
+    psList* list = NULL;
+    psVector* vec = NULL;
+    int* data;
+
+    /*
+        array=psListToArray(list) shall take each element of the list, increment
+        their reference, and insert them into the returned fresh void* array.
+        The list shall not be changed, except for the element reference increment.
+    */
+
+    // test dlist -> vector
+
+    // create a list
+    list = psListAlloc(NULL);
+    for (int lcv=0;lcv<15;lcv++) {
+        data = psAlloc(sizeof(int));
+        *data = lcv;
+        list = psListAdd(list,data,PS_LIST_TAIL);
+        psMemDecrRefCounter(data);
+    }
+
+    vec = psListToVector(list);
+
+    if (vec->n != 15 || list->size != 15) {
+        psError(__func__,"The created vector didn't have the proper size");
+        return 1;
+    }
+    for (int i=0;i<vec->n;i++) {
+        if (i != *(int*)vec->data.PTR[i]) {
+            psError(__func__,"Element %d of vector is incorrect (%d).",
+                    i,*(int*)vec->data.PTR[i]);
+            return 1;
+        }
+        if (i != *(int*)psListGet(list,i)) {
+            psError(__func__,"Element %d of list is incorrect (%d).",
+                    i,*(int*)vec->data.PTR[i]);
+            return 1;
+        }
+        if (psMemGetRefCounter(vec->data.PTR[i]) != 2) {
+            psError(__func__,"Element %d had wrong reference count (%d).",
+                    i,psMemGetRefCounter(vec->data.PTR[i]));
+            return 1;
+        }
+    }
+
+    psVectorFree(vec);
+    psListFree(list,PS_FREE);
+
+    psMemCheckLeaks(currentId,NULL,NULL);
+    psMemCheckCorruption(1);
+
+    // test vector -> dlist
+
+    // create a vector
+    vec = psVectorAlloc(15,PS_TYPE_PTR);
+    vec->n = vec->nalloc;
+    for (int lcv=0;lcv<15;lcv++) {
+        data = psAlloc(sizeof(int));
+        *data = lcv;
+        vec->data.PTR[lcv] = data;
+    }
+
+    list = psVectorToDlist(vec);
+
+    if (vec->n != 15 || list->size != 15) {
+        psError(__func__,"The created vector didn't have the proper size");
+        return 1;
+    }
+    for (int i=0;i<vec->n;i++) {
+        if (i != *(int*)vec->data.PTR[i]) {
+            psError(__func__,"Element %d of vector is incorrect (%d).",
+                    i,*(int*)vec->data.PTR[i]);
+            return 1;
+        }
+        if (i != *(int*)psListGet(list,i)) {
+            psError(__func__,"Element %d of list is incorrect (%d).",
+                    i,*(int*)vec->data.PTR[i]);
+            return 1;
+        }
+        if (psMemGetRefCounter(vec->data.PTR[i]) != 2) {
+            psError(__func__,"Element %d had wrong reference count (%d).",
+                    i,psMemGetRefCounter(vec->data.PTR[i]));
+            return 1;
+        }
+    }
+
+    psVectorFree(vec);
+    psListFree(list,PS_FREE);
+
+    // now, make sure if input vector/list is NULL, output is NULL
+
+    vec = psListToVector(NULL);
+    if (vec != NULL) {
+        psError(__func__,"psListToVector didn't return NULL when given NULL");
+        return 1;
+    }
+
+    list = psVectorToDlist(NULL);
+    if (list != NULL) {
+        psError(__func__,"psVectorToDlist didn't return NULL when given NULL");
+        return 1;
+    }
+
+    // now, see what happens with a zero-size vector/list
+    vec = psVectorAlloc(1,PS_TYPE_PTR);
+    vec->n = 0;
+    list = psVectorToDlist(vec);
+    if (list == NULL) {
+        psError(__func__,"psVectorToDlist didn't create an empty list from an "
+                "empty vector.");
+        return 1;
+    }
+    psVectorFree(vec);
+    psListFree(list,PS_FREE);
+
+    list = psListAlloc(NULL);
+    vec = psListToVector(list);
+    if (vec == NULL) {
+        psError(__func__,"psVectorToDlist didn't create an empty vector from an "
+                "empty list.");
+        return 1;
+    }
+    psVectorFree(vec);
+    psListFree(list,PS_FREE);
+
+    psMemCheckLeaks(currentId,NULL,NULL);
+    psMemCheckCorruption(1);
+
+    return 0;
+}
+
+int testListIterator(void)
+{
+    int currentId = psMemGetId();
+
+    psLogMsg(__func__,PS_LOG_INFO," psListSetIterator/psListGetNext/psListGetPrev"
+             " shall move the list cursor to the specified location");
+
+    psMemCheckLeaks(currentId,NULL,NULL);
+    psMemCheckCorruption(1);
+
+    return 0;
+}
Index: /trunk/psLib/test/collections/verified/tst_psList.stderr
===================================================================
--- /trunk/psLib/test/collections/verified/tst_psList.stderr	(revision 921)
+++ /trunk/psLib/test/collections/verified/tst_psList.stderr	(revision 921)
@@ -0,0 +1,56 @@
+/----------------------------- TESTPOINT ------------------------------------------\
+|             TestFile: tst_psDlist.c                                              |
+|            TestPoint: psDlist{487-testDlistAlloc}                                |
+|             TestType: Positive                                                   |
+\----------------------------------------------------------------------------------/
+
+ <DATE> <TIME> <HOST> |I|testDlistAlloc |psDlistAlloc shall create a psDlist with either 0 or 1 element.
+
+---> TESTPOINT PASSED (psDlist{487-testDlistAlloc} | tst_psDlist.c)
+
+/----------------------------- TESTPOINT ------------------------------------------\
+|             TestFile: tst_psDlist.c                                              |
+|            TestPoint: psDlist{488-testDlistAdd}                                  |
+|             TestType: Positive                                                   |
+\----------------------------------------------------------------------------------/
+
+ <DATE> <TIME> <HOST> |I|testDlistAdd   |psDlistAdd shall add an element to list
+ <DATE> <TIME> <HOST> |I|testDlistAdd   |Following should warn with invalid insert location
+ <DATE> <TIME> <HOST> |W|psDlistAdd     |The given insert location (-10) for psDlistAdd is invalid. Adding to head instead.
+ <DATE> <TIME> <HOST> |I|testDlistAdd   |Following should be a warning.
+ <DATE> <TIME> <HOST> |W|psDlistAdd     |Invalid index 9 (only 7 elements in psDList); assuming tail.
+
+---> TESTPOINT PASSED (psDlist{488-testDlistAdd} | tst_psDlist.c)
+
+/----------------------------- TESTPOINT ------------------------------------------\
+|             TestFile: tst_psDlist.c                                              |
+|            TestPoint: psDlist{489-testDlistGet}                                  |
+|             TestType: Positive                                                   |
+\----------------------------------------------------------------------------------/
+
+ <DATE> <TIME> <HOST> |I|testDlistGet   |Following should be an error
+ <DATE> <TIME> <HOST> |E|dlistSetIterator|Unexpected null pointer for psDlist parameter (psDlist.c:274).
+
+---> TESTPOINT PASSED (psDlist{489-testDlistGet} | tst_psDlist.c)
+
+/----------------------------- TESTPOINT ------------------------------------------\
+|             TestFile: tst_psDlist.c                                              |
+|            TestPoint: psDlist{490-testDlistRemove}                               |
+|             TestType: Positive                                                   |
+\----------------------------------------------------------------------------------/
+
+ <DATE> <TIME> <HOST> |I|testDlistRemove|Following should be an error
+ <DATE> <TIME> <HOST> |E|psDlistRemove  |list parameter found to be NULL in psDlistRemove
+ <DATE> <TIME> <HOST> |E|testDlistRemove|Failed to remove PS_DLIST_HEAD
+
+---> TESTPOINT PASSED (psDlist{490-testDlistRemove} | tst_psDlist.c)
+
+/----------------------------- TESTPOINT ------------------------------------------\
+|             TestFile: tst_psDlist.c                                              |
+|            TestPoint: psDlist{491-testDlistConvert}                              |
+|             TestType: Positive                                                   |
+\----------------------------------------------------------------------------------/
+
+
+---> TESTPOINT PASSED (psDlist{491-testDlistConvert} | tst_psDlist.c)
+
