Index: /trunk/psLib/test/collections/Makefile
===================================================================
--- /trunk/psLib/test/collections/Makefile	(revision 1420)
+++ /trunk/psLib/test/collections/Makefile	(revision 1421)
@@ -3,6 +3,6 @@
 ##  Makefile:   test/collections
 ##
-##  $Revision: 1.21 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-07-28 02:50:37 $
+##  $Revision: 1.22 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-08-09 20:42:24 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -19,19 +19,24 @@
 LDFLAGS := -L../../lib -lpslib -lpstest $(LDFLAGS)
 
-TARGET = tst_psVector \
-         tst_psArray \
-         tst_psBitSet_01 \
-         tst_psBitSet_02 \
-         tst_psBitSet_03 \
-         tst_psBitSet_04 \
-         tst_psBitSet_05 \
-         tst_psBitSet_06 \
-         tst_psBitSet_07 \
-         tst_psBitSet_08 \
+TARGET = tst_psVector          \
+         tst_psArray           \
+         tst_psBitSet_01       \
+         tst_psBitSet_02       \
+         tst_psBitSet_03       \
+         tst_psBitSet_04       \
+         tst_psBitSet_05       \
+         tst_psBitSet_06       \
+         tst_psBitSet_07       \
+         tst_psBitSet_08       \
          tst_psVectorSort_01   \
          tst_psVectorSort_02   \
          tst_psVectorSort_03   \
          tst_psVectorSort_04   \
-         tst_psList
+         tst_psList            \
+         tst_psHash00          \
+         tst_psHash01          \
+         tst_psHash02          \
+         tst_psHash03          \
+         tst_psHash04
 
 OBJS = $(addsuffix .o,$(TARGET))
Index: /trunk/psLib/test/collections/tst_psHash00.c
===================================================================
--- /trunk/psLib/test/collections/tst_psHash00.c	(revision 1421)
+++ /trunk/psLib/test/collections/tst_psHash00.c	(revision 1421)
@@ -0,0 +1,64 @@
+/*****************************************************************************
+    This code will test whether a hash table can be allocated successfully,
+    then deallocated successfully.
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psHash.h"
+#define NUM_HASH_TABLE_BUCKETS 10
+int main()
+{
+    psHash *myHashTable = NULL;
+    int testStatus      = true;
+    int i               = 0;
+    int currentId = psMemGetId();
+    int memLeaks        = 0;
+    printPositiveTestHeader(stdout,
+                            "psHash functions",
+                            "psHashAlloc()");
+
+    myHashTable = psHashAlloc(NUM_HASH_TABLE_BUCKETS);
+
+    if (myHashTable == NULL) {
+        fprintf(stderr, "%s: could not allocate a hash table.", __func__);
+        testStatus = false;
+    }
+
+    if (myHashTable->nbucket != NUM_HASH_TABLE_BUCKETS) {
+        fprintf(stderr, "%s: myHashTable->nbucket not set properly.\n",
+                __func__);
+        testStatus = false;
+
+    }
+
+    if (myHashTable->buckets == NULL) {
+        fprintf(stderr, "%s: myHashTable->buckets is NULL.\n",
+                __func__);
+        testStatus = false;
+
+    }
+
+    for (i=0;i<NUM_HASH_TABLE_BUCKETS;i++) {
+        if (myHashTable->buckets[i] != NULL) {
+            fprintf(stderr, "%s: hash table bucket[%d] not equal to NULL.\n",
+                    __func__, i);
+            testStatus = false;
+        }
+    }
+
+    printFooter(stdout,
+                "psHash functions",
+                "psHashAlloc()",
+                testStatus);
+
+    psFree(myHashTable);
+
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+    psMemCheckCorruption(1);
+
+    return (!testStatus);
+}
Index: /trunk/psLib/test/collections/tst_psHash01.c
===================================================================
--- /trunk/psLib/test/collections/tst_psHash01.c	(revision 1421)
+++ /trunk/psLib/test/collections/tst_psHash01.c	(revision 1421)
@@ -0,0 +1,79 @@
+/*****************************************************************************
+    This code will test whether a hash table can be de-allocated successfully.
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psHash.h"
+#define NUM_HASH_TABLE_BUCKETS 100
+int imGlobal = 0;
+
+typedef struct
+{
+    char *name;
+}
+ID;
+
+static void IdFree(ID *id);
+
+static ID *IdAlloc(const char *name)
+{
+    ID *id = psAlloc(sizeof(ID));
+    p_psMemSetDeallocator(id,(psFreeFcn)IdFree);
+    id->name = psStringCopy(name);
+
+    return id;
+}
+
+static void IdFree(ID *id)
+{
+    imGlobal++;
+    psFree(id->name);
+}
+
+int main()
+{
+    psHash *myHashTable = NULL;
+    int testStatus      = true;
+    int currentId = psMemGetId();
+    ID* id = NULL;
+    int memLeaks        = 0;
+
+    printPositiveTestHeader(stdout,
+                            "psHash functions",
+                            "psHashFree()");
+
+    myHashTable = psHashAlloc(NUM_HASH_TABLE_BUCKETS);
+    id = IdAlloc("IDA");
+    psHashAdd(myHashTable, "ENTRY00", id);
+    psFree(id);
+    id = IdAlloc("IDB");
+    psHashAdd(myHashTable, "ENTRY01", id);
+    psFree(id);
+    id = IdAlloc("IDC");
+    psHashAdd(myHashTable, "ENTRY02", id);
+    psFree(id);
+    id = IdAlloc("IDD");
+    psHashAdd(myHashTable, "ENTRY03", id);
+    psFree(id);
+    psFree(myHashTable);
+
+    if (imGlobal != 4) {
+        fprintf(stderr, "%s: only (%d/4) entries were freed",
+                __func__, imGlobal);
+        testStatus = false;
+    }
+
+    printFooter(stdout,
+                "psHash functions",
+                "psHashFree()",
+                testStatus);
+
+    memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+    psMemCheckCorruption(1);
+
+    return (!testStatus);
+}
Index: /trunk/psLib/test/collections/tst_psHash02.c
===================================================================
--- /trunk/psLib/test/collections/tst_psHash02.c	(revision 1421)
+++ /trunk/psLib/test/collections/tst_psHash02.c	(revision 1421)
@@ -0,0 +1,94 @@
+/*****************************************************************************
+    This code will test whether hash tables entries can be inserted correctly,
+    and retrieved correctly.
+ 
+    NOTE: Add code to test whether duplicates are handled correctly (use a
+    small hash table and lots of keys).
+ *****************************************************************************/
+#include <stdio.h>
+#include <string.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psHash.h"
+#define NUM_HASH_TABLE_BUCKETS 100
+int imGlobal = 0;
+
+typedef struct
+{
+    char *name;
+}
+ID;
+static void IdFree(ID *id);
+
+static ID *IdAlloc(const char *name)
+{
+    ID *id = psAlloc(sizeof(ID));
+    p_psMemSetDeallocator(id,(psFreeFcn)IdFree);
+    id->name = psStringCopy(name);
+
+    return id;
+}
+
+static void IdFree(ID *id)
+{
+    imGlobal++;
+    psFree(id->name);
+}
+
+int main()
+{
+    psHash *myHashTable = NULL;
+    int testStatus      = true;
+    int i               = 0;
+    ID *id = NULL;
+    char *myKeys[] = {"ENTRY00", "ENTRY01", "ENTRY02", "ENTRY03", NULL
+                     };
+    char *myData[] = {"IDA", "IDB", "IDC", "IDD", NULL
+                     };
+    int currentId = psMemGetId();
+    int memLeaks        = 0;
+
+    printPositiveTestHeader(stdout,
+                            "psHash functions",
+                            "psHashAdd()");
+
+    myHashTable = psHashAlloc(NUM_HASH_TABLE_BUCKETS);
+    i = 0;
+    while (myKeys[i] != NULL) {
+        id = IdAlloc(myData[i]);
+        psHashAdd(myHashTable, myKeys[i], id);
+        psFree(id);
+        i++;
+    }
+
+    i = 0;
+    while (myKeys[i] != NULL) {
+        id = psHashLookup(myHashTable, myKeys[i]);
+        if (0 != strcmp(myData[i], id->name)) {
+            fprintf(stderr, "%s: Hash table entry for key %s was %s (should be %s).\n",
+                    __func__, myKeys[i], id->name, myData[i]);
+        }
+        i++;
+    }
+    id = psHashLookup(myHashTable, "BogusKey");
+    if (id != NULL) {
+        fprintf(stderr, "%s: Hash table entry for key %s was not NULL.\n",
+                __func__, "BogusKey");
+    }
+
+    //    psHashFree(myHashTable, NULL);
+    psFree(myHashTable);
+
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+    psMemCheckCorruption(1);
+
+    printFooter(stdout,
+                "psHash functions",
+                "psHashAdd()",
+                testStatus);
+
+    return (!testStatus);
+}
Index: /trunk/psLib/test/collections/tst_psHash03.c
===================================================================
--- /trunk/psLib/test/collections/tst_psHash03.c	(revision 1421)
+++ /trunk/psLib/test/collections/tst_psHash03.c	(revision 1421)
@@ -0,0 +1,139 @@
+/*****************************************************************************
+    This code will test whether hash tables entries can be removed correctly.
+ 
+    NOTE: Add code to test whether duplicates are handled correctly.
+ *****************************************************************************/
+#include <stdio.h>
+#include <string.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psHash.h"
+#include "psMemory.h"
+#define NUM_HASH_TABLE_BUCKETS 100
+int imGlobal = 0;
+int currentId = 0;
+
+typedef struct
+{
+    char *name;
+}
+ID;
+static void IdFree(ID *id);
+
+// NOTE: This is my own little routine I used in debugging a memory
+// leak.  I will take this out of this file later.
+void printMemBlocks(char *myString)
+{
+    psMemBlock **memBlocks = NULL;
+    psMemBlock *tmp = NULL;
+    int numBlocks = 0;
+
+    numBlocks = psMemCheckLeaks(currentId, &memBlocks, NULL);
+    printf("******************** %s ********************\n", myString);
+    printf("%d mem blocks\n", psMemCheckLeaks(currentId,NULL,NULL));
+    printf("%d blocks\n", numBlocks);
+    printf("*  ");
+    if (memBlocks != NULL) {
+        for (tmp = *memBlocks; tmp != NULL; tmp = tmp->nextBlock) {
+            printf("%d ", (int) tmp->id);
+        }
+    }
+    printf("*\n");
+    printf("*************************************************\n");
+    psFree(memBlocks);
+}
+
+static ID *IdAlloc(const char *name)
+{
+    ID *id = NULL;
+
+    id = psAlloc(sizeof(ID));
+    p_psMemSetDeallocator(id,(psFreeFcn)IdFree);
+
+    id->name = psStringCopy(name);
+
+    return id;
+}
+
+static void IdFree(ID *id)
+{
+    imGlobal++;
+    psFree(id->name);
+}
+
+int main()
+{
+    psHash *myHashTable = NULL;
+    int testStatus      = true;
+    int i               = 0;
+    int TotalKeys       = 0;
+    bool retVal         = false;
+    ID *id = NULL;
+    ID *ids[4];
+    char *myKeys[] = {"ENTRY00", "ENTRY01", "ENTRY02", "ENTRY03", NULL
+                     };
+    char *myData[] = {"IDA", "IDB", "IDC", "IDD", NULL
+                     };
+    int memLeaks        = 0;
+
+    currentId = psMemGetId();
+
+    printPositiveTestHeader(stdout,
+                            "psHash functions",
+                            "psHashRemove()");
+
+    myHashTable = psHashAlloc(NUM_HASH_TABLE_BUCKETS);
+
+    i = 0;
+    while (myKeys[i] != NULL) {
+        ids[i] = IdAlloc(myData[i]);
+        psHashAdd(myHashTable, myKeys[i], ids[i]);
+        i++;
+    }
+    TotalKeys = i - 1;
+
+    i = TotalKeys;
+    while (i >= 0) {
+
+        id = psHashLookup(myHashTable, myKeys[i]);
+        if (0 != strcmp(myData[i], id->name)) {
+            fprintf(stderr, "%s: Hash table entry for key %s was %s (should be %s).\n",
+                    __func__, myKeys[i], id->name, myData[i]);
+        }
+        i--;
+    }
+
+    i = 0;
+    while (myKeys[i] != NULL) {
+        // The psHashRemove() procedure removes the entry from the hash
+        // table and deletes the data.
+        retVal = psHashRemove(myHashTable, myKeys[i]);
+        if (!retVal) {
+            fprintf(stderr,"%s: Hash table entry not removed.\n",__func__);
+        }
+        id = psHashLookup(myHashTable, myKeys[i]);
+        if (id != NULL) {
+            fprintf(stderr, "%s: Hash table entry for key %s not removed.\n",
+                    __func__, "IDA");
+        }
+        i++;
+    }
+
+    printFooter(stdout,
+                "psHash functions",
+                "psHashRemove()",
+                testStatus);
+
+    psFree(myHashTable);
+    for(i=0; i<(TotalKeys+1); i++) {
+        psFree(ids[i]);
+    }
+    memLeaks = psMemCheckLeaks(currentId,NULL,stdout);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+    psMemCheckCorruption(true);
+
+    return (!testStatus);
+}
+
Index: /trunk/psLib/test/collections/tst_psHash04.c
===================================================================
--- /trunk/psLib/test/collections/tst_psHash04.c	(revision 1421)
+++ /trunk/psLib/test/collections/tst_psHash04.c	(revision 1421)
@@ -0,0 +1,84 @@
+/*****************************************************************************
+    This code will test whether the call psHashKeyList() function works.
+ *****************************************************************************/
+#include <stdio.h>
+#include "pslib.h"
+#include "psTest.h"
+#include "psHash.h"
+#define NUM_HASH_TABLE_BUCKETS 100
+int imGlobal = 0;
+
+typedef struct
+{
+    char *name;
+}
+ID;
+static void IdFree(ID *id);
+
+static ID *IdAlloc(const char *name)
+{
+    ID *id = psAlloc(sizeof(ID));
+    p_psMemSetDeallocator(id,(psFreeFcn)IdFree);
+
+    id->name = psStringCopy(name);
+
+    return id;
+}
+
+static void IdFree(ID *id)
+{
+    imGlobal++;
+    psFree(id->name);
+}
+
+int main()
+{
+    psHash *myHashTable = NULL;
+    int testStatus      = true;
+    int i               = 0;
+    char *myKeys[] = {"ENTRY00", "ENTRY01", "ENTRY02", "ENTRY03", NULL
+                     };
+    char *myData[] = {"IDA", "IDB", "IDC", "IDD", NULL
+                     };
+    int currentId = psMemGetId();
+    int memLeaks        = 0;
+    psList *myLinkList = NULL;
+    psListElem *tmp = NULL;
+    ID* id = NULL;
+
+    printPositiveTestHeader(stdout,
+                            "psHash functions",
+                            "psHashKeyList()");
+
+    myHashTable = psHashAlloc(NUM_HASH_TABLE_BUCKETS);
+    i = 0;
+    while (myKeys[i] != NULL) {
+        id = IdAlloc(myData[i]);
+        psHashAdd(myHashTable, myKeys[i], id);
+        psFree(id);
+        i++;
+    }
+    myLinkList = psHashKeyList(myHashTable);
+    tmp = myLinkList->head;
+    while (tmp != NULL) {
+        printf("Linked List Entries: %s\n", (char *) tmp->data);
+        tmp = tmp->next;
+    }
+
+    psFree(myLinkList);
+
+    printFooter(stdout,
+                "psHash functions",
+                "psHashKeyList()",
+                testStatus);
+
+    psFree(myHashTable);
+
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+    psMemCheckCorruption(1);
+
+    return(!testStatus);
+}
Index: /trunk/psLib/test/collections/verified/tst_psHash00.stdout
===================================================================
--- /trunk/psLib/test/collections/verified/tst_psHash00.stdout	(revision 1421)
+++ /trunk/psLib/test/collections/verified/tst_psHash00.stdout	(revision 1421)
@@ -0,0 +1,9 @@
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psHash00.c                                             *
+*            TestPoint: psHash functions{psHashAlloc()}                            *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psHash functions{psHashAlloc()} | tst_psHash00.c)
+
Index: /trunk/psLib/test/collections/verified/tst_psHash01.stdout
===================================================================
--- /trunk/psLib/test/collections/verified/tst_psHash01.stdout	(revision 1421)
+++ /trunk/psLib/test/collections/verified/tst_psHash01.stdout	(revision 1421)
@@ -0,0 +1,9 @@
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psHash01.c                                             *
+*            TestPoint: psHash functions{psHashFree()}                             *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psHash functions{psHashFree()} | tst_psHash01.c)
+
Index: /trunk/psLib/test/collections/verified/tst_psHash03.stdout
===================================================================
--- /trunk/psLib/test/collections/verified/tst_psHash03.stdout	(revision 1421)
+++ /trunk/psLib/test/collections/verified/tst_psHash03.stdout	(revision 1421)
@@ -0,0 +1,9 @@
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psHash03.c                                             *
+*            TestPoint: psHash functions{psHashRemove()}                           *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psHash functions{psHashRemove()} | tst_psHash03.c)
+
Index: /trunk/psLib/test/collections/verified/tst_psHash04.stdout
===================================================================
--- /trunk/psLib/test/collections/verified/tst_psHash04.stdout	(revision 1421)
+++ /trunk/psLib/test/collections/verified/tst_psHash04.stdout	(revision 1421)
@@ -0,0 +1,13 @@
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psHash04.c                                             *
+*            TestPoint: psHash functions{psHashKeyList()}                          *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+Linked List Entries: ENTRY03
+Linked List Entries: ENTRY02
+Linked List Entries: ENTRY01
+Linked List Entries: ENTRY00
+
+---> TESTPOINT PASSED (psHash functions{psHashKeyList()} | tst_psHash04.c)
+
Index: /trunk/psLib/test/sysUtils/Makefile
===================================================================
--- /trunk/psLib/test/sysUtils/Makefile	(revision 1420)
+++ /trunk/psLib/test/sysUtils/Makefile	(revision 1421)
@@ -3,6 +3,6 @@
 ##  Makefile:   test/sysUtils
 ##
-##  $Revision: 1.17 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-07-13 01:37:59 $
+##  $Revision: 1.18 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-08-09 20:38:11 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -24,9 +24,4 @@
          tst_psMemory     \
          tst_psError      \
-         tst_psHash00     \
-         tst_psHash01     \
-         tst_psHash02     \
-         tst_psHash03     \
-         tst_psHash04     \
          tst_psLogMsg00   \
          tst_psLogMsg01   \
