Index: /trunk/psLib/test/collections/tst_psDlist.c
===================================================================
--- /trunk/psLib/test/collections/tst_psDlist.c	(revision 910)
+++ /trunk/psLib/test/collections/tst_psDlist.c	(revision 911)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-08 00:58:39 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-08 02:17:49 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,4 +22,5 @@
 static int testDlistGet(void);
 static int testDlistRemove(void);
+static int testDlistConvert(void);
 
 testDescription tests[] = {
@@ -28,4 +29,5 @@
                               {testDlistGet,"489-testDlistGet",0},
                               {testDlistRemove,"490-testDlistRemove",0},
+                              {testDlistConvert,"491-testDlistConvert",0},
                               {NULL}
                           };
@@ -417,4 +419,5 @@
         *data = lcv;
         list = psDlistAdd(list,data,PS_DLIST_TAIL);
+        psMemDecrRefCounter(data);
     }
 
@@ -616,2 +619,115 @@
 
 }
+
+int testDlistConvert(void)
+{
+
+    int currentId = psMemGetId();
+    psDlist* list = NULL;
+    psVector* vec = NULL;
+    int* data;
+
+    /*
+        array=psDlistToArray(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 = psDlistAlloc(NULL);
+    for (int lcv=0;lcv<15;lcv++) {
+        data = psAlloc(sizeof(int));
+        *data = lcv;
+        list = psDlistAdd(list,data,PS_DLIST_TAIL);
+        psMemDecrRefCounter(data);
+    }
+
+    vec = psDlistToVector(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*)psDlistGet(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);
+    psDlistFree(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*)psDlistGet(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);
+    psDlistFree(list,PS_FREE);
+
+    // now, make sure if input vector/list is NULL, output is NULL
+
+    vec = psDlistToVector(NULL);
+    if (vec != NULL) {
+        psError(__func__,"psDlistToVector 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;
+    }
+
+    psMemCheckLeaks(currentId,NULL,NULL);
+    psMemCheckCorruption(1);
+
+    return 0;
+}
