Index: /trunk/psLib/src/types/psBitSet.c
===================================================================
--- /trunk/psLib/src/types/psBitSet.c	(revision 9081)
+++ /trunk/psLib/src/types/psBitSet.c	(revision 9082)
@@ -11,6 +11,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 02:55:34 $
+ *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-01 00:40:35 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -27,4 +27,5 @@
 #include "psAbort.h"
 #include "psString.h"
+#include "psAssert.h"
 
 
@@ -60,7 +61,4 @@
 static void bitSetFree(psBitSet* inBitSet)
 {
-    if (inBitSet == NULL) {
-        return;
-    }
     psFree(inBitSet->bits);
 }
@@ -77,13 +75,13 @@
 psBitSet* psBitSetAlloc(long nalloc)
 {
+    if (nalloc < 0) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                _("The number of bit in a psBitSet (%ld) must be greater than zero."),
+                nalloc);
+        return NULL;
+    }
+
     psS32 numBytes = 0;
     psBitSet* newObj = NULL;
-
-    if (nalloc < 0) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                _("The number of bit in a psBitSet (%ld) must be greater than zero."),
-                nalloc);
-        return NULL;
-    }
 
     numBytes = ceil(nalloc / 8.0);
@@ -174,4 +172,16 @@
                      const psBitSet* inBitSet2)
 {
+    if (inBitSet1 == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                _("First psBitSet operand can not be NULL."));
+        psFree(outBitSet);
+        return NULL;
+    }
+    if (operator == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                _("Specified operator is NULL.  Must specify desired operator."));
+        psFree(outBitSet);
+        return NULL;
+    }
     psS32 i = 0;
     psS32 n = 0;
@@ -181,18 +191,6 @@
     psS32 op = UNKNOWN_OP;
 
-    if (inBitSet1 == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("First psBitSet operand can not be NULL."));
-        psFree(outBitSet);
-        return NULL;
-    }
     inBits1 = inBitSet1->bits;
 
-    if (operator == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("Specified operator is NULL.  Must specify desired operator."));
-        psFree(outBitSet);
-        return NULL;
-    }
 
     // parse the operator
@@ -257,11 +255,9 @@
         break;
     case NOT_OP:
+    default:
         for (i = 0; i < n; i++) {
             outBits[i] = ~inBits1[i];
         }
         break;
-    default:
-        psAbort("psBitSetOp",
-                "Unexpected error - operator parsed successfully but not valid?");
     }
 
@@ -281,9 +277,4 @@
     outBitSet = psBitSetOp(outBitSet,inBitSet,"NOT",NULL);
 
-    if (outBitSet == NULL) {
-        psError(PS_ERR_UNKNOWN, false,
-                _("Could not perform NOT operation."));
-    }
-
     return outBitSet;
 }
@@ -291,7 +282,9 @@
 psString psBitSetToString(const psBitSet* bitSet)
 {
+    PS_ASSERT_PTR_NON_NULL(bitSet, NULL);
     psS32 i = 0;
     psS32 numBits = bitSet->n * 8;
-    char *outString = psAlloc((size_t) numBits + 1);
+    //    char *outString = psAlloc((size_t) numBits + 1);
+    psString outString = psStringAlloc(numBits + 1);
 
     for (i = 0; i < numBits; i++) {
Index: /trunk/psLib/src/types/psBitSet.h
===================================================================
--- /trunk/psLib/src/types/psBitSet.h	(revision 9081)
+++ /trunk/psLib/src/types/psBitSet.h	(revision 9082)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-26 02:55:34 $
+ *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-01 00:40:35 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -32,6 +32,7 @@
 /** Struct containing array of bytes to hold bit data and corresponding array length.
  *
- *  The bits in the struct are assembled in as an array of bytes with eight bits per byte. The bits are
- *  arranged with the LSB in first (right most) position of the first array element.
+ *  The bits in the struct are assembled in as an array of bytes with eight bits per
+ *  byte. The bits are arranged with the LSB in first (right most) position of the
+ *  first array element.
  */
 typedef struct
@@ -51,5 +52,5 @@
  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
  *
- *  @return bool:       True if the pointer matches a psBitSet structure, false otherwise.
+ *  @return bool:     True if the pointer matches a psBitSet structure, false otherwise.
  */
 bool psMemCheckBitSet(
@@ -60,11 +61,11 @@
 /** Allocate a psBitSet.
  *
- *  Create a psBitSet with the number of bits specified by the user. All bits are set to zero upon
- *  allocation.
+ *  Create a psBitSet with the number of bits specified by the user. All bits are set
+ *  to zero upon allocation.
  *
  *  @return  psBitSet* : Pointer to struct containing array of bits and size of array.
  */
 psBitSet* psBitSetAlloc(
-    long nalloc                            ///< Number of bits in psBitSet array
+    long nalloc                        ///< Number of bits in psBitSet array
 );
 
@@ -72,6 +73,7 @@
  *
  *  Sets a bit at a given bit location. The bit is set based on a zero index with the
- *  first bit set in the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in
- *  an array with two elements would result in an psBitSet that looks like 00000000 00001000.
+ *  first bit set in the zero bit slot of the zero element of the byte array. As an
+ *  example, setting bit 3 in an array with two elements would result in an psBitSet
+ *  that looks like 00000000 00001000.
  *
  *  @return  psBitSet* : Pointer to struct containing psBitSet.
@@ -97,12 +99,12 @@
 /** Test the value of a bit.
  *
- *  Prints the value of a bit at a given bit location, either one or zero. The resulting bit is based on a
- *  zero index format with the first bit set in the zero bit slot of the zero element of the byte array
- *  As an example, testing bit 3 in a psBitSet with two bytes that looks like 00000000 00001000 would return a
- *  value of one, since that is the value that was set.
+ *  Prints the value of a bit at a given bit location, either one or zero. The resulting
+ *  bit is based on a zero index format with the first bit set in the zero bit slot of
+ *  the zero element of the byte array.  As an example, testing bit 3 in a psBitSet with
+ *  two bytes that looks like 00000000 00001000 would return a value of one, since that
+ *  is the value that was set.
  *
  *  @return  bool:      True if successful, otherwise false
  */
-
 bool psBitSetTest(
     const psBitSet* bitSet,            ///< Pointer psBitSet to be tested.
@@ -112,23 +114,23 @@
 /** Perform a binary operation on two psBitSets
  *
- *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the same size, the operation will not
- *  be performed and an error message will be logged.
+ *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the same size,
+ *  the operation will not be performed and an error message will be logged.
  *
  *  @return  psBitSet* : Pointer to struct containing result of binary operation.
  */
 psBitSet* psBitSetOp(
-    psBitSet* outBitSet,                 ///< Resulting psBitSet from binary operation
-    const psBitSet* inBitSet1,           ///< First psBitSet on which to operate
-    const char *operator,                    ///< Bit operation
-    const psBitSet* inBitSet2            ///< First psBitSet on which to operate
+    psBitSet* outBitSet,               ///< Resulting psBitSet from binary operation
+    const psBitSet* inBitSet1,         ///< First psBitSet on which to operate
+    const char *operator,              ///< Bit operation
+    const psBitSet* inBitSet2          ///< Second psBitSet on which to operate
 );
 
 /** Perform a not operation on a psBitSet
  *
- *  Toggles bits in a psBitset. All zero bits are set to one and all one bits are set to zero.
+ *  Toggles bits in a psBitset. All zero bits are set to one and all one bits are set
+ *  to zero.
  *
  *  @return  psBitSet* : Pointer to struct containing result of operation.
  */
-
 psBitSet* psBitSetNot(
     psBitSet* outBitSet,               ///< Resulting psBitSet from operation
@@ -138,12 +140,12 @@
 /** Convert the psBitSet to a string of ones and zeros.
  *
- *  Converts the contents of a psBitSet to a string representation of its binary form of ones and zeros. The
- *  LSB is the right-most chracter. Each set of eight characters represents one byte.
+ *  Converts the contents of a psBitSet to a string representation of its binary form of
+ *  ones and zeros. The LSB is the right-most chracter. Each set of eight characters
+ *  represents one byte.
  *
- *  @return  char*: Pointer to character array containing string data.
+ *  @return  psString:      Pointer to character array containing string data.
  */
-
 psString psBitSetToString(
-    const psBitSet* bitSet             ///< psBitSet to convert */
+    const psBitSet* bitSet             ///< psBitSet to convert
 );
 
Index: /trunk/psLib/test/types/Makefile.am
===================================================================
--- /trunk/psLib/test/types/Makefile.am	(revision 9081)
+++ /trunk/psLib/test/types/Makefile.am	(revision 9082)
@@ -24,5 +24,9 @@
 	tap_psMetadata_polynomials \
 	tap_psArray_all \
-	tap_psArguments_all
+	tap_psArguments_all \
+	tap_psPixels_all \
+	tap_psHash_all \
+	tap_psBitSet_all \
+	tap_psList_all
 
 if BUILD_TESTS
@@ -42,5 +46,5 @@
 	data/test3.config \
 	data/test4.config \
-	data/test5.config 
+	data/test5.config
 
 tmp_files = \
@@ -53,5 +57,5 @@
 	test3.config \
 	test4.config \
-	test5.config 
+	test5.config
 
 CLEANFILES = $(tmp_files) multi.fits table.fits temp/* MDCopy.in MDCopy.out mdcfgwrt.out \
Index: /trunk/psLib/test/types/execute_tap
===================================================================
--- /trunk/psLib/test/types/execute_tap	(revision 9081)
+++ /trunk/psLib/test/types/execute_tap	(revision 9082)
@@ -15,2 +15,4 @@
 ./tap_psPixels_all
 ./tap_psHash_all
+./tap_psBitSet_all
+./tap_psList_all
Index: /trunk/psLib/test/types/tap_psBitSet_all.c
===================================================================
--- /trunk/psLib/test/types/tap_psBitSet_all.c	(revision 9081)
+++ /trunk/psLib/test/types/tap_psBitSet_all.c	(revision 9082)
@@ -12,4 +12,5 @@
 
 #include <pslib.h>
+#include <string.h>
 
 #include "tap.h"
@@ -21,5 +22,5 @@
 int main(void)
 {
-    plan_tests(5);
+    plan_tests(31);
 
     diag("Tests for psBitSet Functions");
@@ -50,4 +51,11 @@
             "psBitSetAlloc:         return properly allocated psBitSet.");
     }
+    //Return properly allocated psBitSet
+    {
+        psFree(bs);
+        bs = psBitSetAlloc(8);
+        ok( bs != NULL && psMemCheckBitSet(bs) && bs->n == 1,
+            "psBitSetAlloc:         return properly allocated psBitSet.");
+    }
     //Make sure psMemCheckBitSet works correctly - return false
     {
@@ -56,11 +64,89 @@
             "psMemCheckBitSet:      return false for non-BitSet input.");
     }
-    //Return properly allocated psBitSet
-    {
-        psFree(bs);
-        bs = psBitSetAlloc(8);
-        ok( bs != NULL && psMemCheckBitSet(bs) && bs->n == 1,
-            "psBitSetAlloc:         return properly allocated psBitSet.");
-    }
+
+    //BitSetSet Tests
+    //Return NULL for NULL input psBitSet
+    {
+        noBits = psBitSetSet(noBits, 0);
+        ok( noBits == NULL,
+            "psBitSetSet:           return NULL for NULL BitSet input.");
+    }
+    //Return input BitSet for negative bit input
+    {
+        noBits = psBitSetSet(bs, -1);
+        ok( noBits == bs,
+            "psBitSetSet:           return input BitSet for negative bits input.");
+        noBits = NULL;
+    }
+    //Return input BitSet for out-of-range bits
+    {
+        noBits = psBitSetSet(bs, 8);
+        ok( noBits == bs,
+            "psBitSetSet:           return input BitSet for out-of-range bits input.");
+        noBits = NULL;
+    }
+    //Return set BitSet for valid inputs
+    {
+        bs = psBitSetSet(bs, 2);
+        ok( bs->bits[0] == 4,
+            "psBitSetSet:           return properly set BitSet for valid inputs.");
+    }
+
+    //BitSetClear Tests
+    //Return NULL for NULL input psBitSet
+    {
+        noBits = psBitSetClear(noBits, 0);
+        ok( noBits == NULL,
+            "psBitSetClear:         return NULL for NULL BitSet input.");
+    }
+    //Return input BitSet for negative bit input
+    {
+        noBits = psBitSetClear(bs, -1);
+        ok( noBits == bs,
+            "psBitSetClear:        return input BitSet for negative bits input.");
+        noBits = NULL;
+    }
+    //Return input BitSet for out-of-range bits
+    {
+        noBits = psBitSetClear(bs, 8);
+        ok( noBits == bs,
+            "psBitSetClear:        return input BitSet for out-of-range bits input.");
+        noBits = NULL;
+    }
+    //Return cleared BitSet for valid inputs
+    {
+        bs = psBitSetClear(bs, 2);
+        ok( bs->bits[0] == 0,
+            "psBitSetClear:        return properly cleared BitSet for valid inputs.");
+    }
+
+    //BitSetTest Tests
+    //Return false for NULL input psBitSet
+    {
+        ok( !psBitSetTest(noBits, 0),
+            "psBitSetTest:         return false for NULL BitSet input.");
+    }
+    //Return false for negative bit input
+    {
+        ok( !psBitSetTest(bs, -1),
+            "psBitSetTest:         return false for negative bits input.");
+    }
+    //Return false for out-of-range bits
+    {
+        ok( !psBitSetTest(bs, 8),
+            "psBitSetTest:         return false for out-of-range bits input.");
+    }
+    //Return false for non-matching bit in BitSet
+    {
+        ok( !psBitSetTest(bs, 2),
+            "psBitSetTest:         return false for non-matching bit in BitSet.");
+    }
+    //Return false for non-matching bit in BitSet
+    {
+        bs = psBitSetSet(bs, 2);
+        ok( psBitSetTest(bs, 2),
+            "psBitSetTest:         return true for matching bit in BitSet.");
+    }
+
 
     //Check for Memory leaks
@@ -74,22 +160,132 @@
 {
     diag("  >>>Test 2:  psBitSet Operation Fxns");
+    psBitSet *noBits = NULL;
+    psBitSet *bs = NULL;
+    bs = psBitSetAlloc(8);
+    bs = psBitSetSet(bs, 2);  // 0000 0100 == 4
+    bs = psBitSetSet(bs, 3);  // 0000 1100 == 12
+    bs = psBitSetSet(bs, 4);  // 0001 1100 == 28
+    bs = psBitSetSet(bs, 5);  // 0011 1100 == 60
+    bs = psBitSetSet(bs, 6);  // 0111 1100 == 124
+    bs = psBitSetSet(bs, 7);  // 1111 1100 == 252
+    psBitSet *out = NULL;
+
+    //psBitSetNot Tests
+    //Return NULL for NULL BitSet input
+    {
+        out = psBitSetNot(out, noBits);
+        ok( out == NULL,
+            "psBitSetNot:          return NULL for NULL BitSet input.");
+    }
+    //Return correct BitSet for valid BitSet input
+    {
+        out = psBitSetNot(out, bs);  //bs = 1111 1100  so out should = 0000 0011 = 3
+        ok( out->bits[0] == 3,
+            "psBitSetNot:          return correct BitSet for valid BitSet input.");
+    }
+
+    //psBitSetOp Tests   out = psBitSetOp(out, bs1, "op", bs2);
+    //Return NULL for NULL BitSet input
+    {
+        psFree(out);
+        out = NULL;
+        out = psBitSetOp(out, noBits, "op", noBits);
+        ok( out == NULL,
+            "psBitSetOp:           return NULL for NULL BitSet input.");
+    }
+    //Return NULL for NULL operator input
+    {
+        out = psBitSetOp(out, bs, NULL, noBits);
+        ok( out == NULL,
+            "psBitSetOp:           return NULL for NULL operator input.");
+    }
+    //Return NULL for invalid operator input
+    {
+        out = psBitSetOp(out, bs, "XAND", noBits);
+        ok( out == NULL,
+            "psBitSetOp:           return NULL for invalid operator input.");
+    }
+    //Return NULL for AND operator with NULL second BitSet input
+    {
+        out = psBitSetOp(out, bs, "AND", noBits);
+        ok( out == NULL,
+            "psBitSetOp:           return NULL for AND operator with NULL second BitSet input.");
+    }
+    //Return NULL for AND operator with BitSet inputs of differing size.
+    psBitSet *bs2 = psBitSetAlloc(16);
+    {
+        out = psBitSetOp(out, bs, "AND", bs2);
+        ok( out == NULL,
+            "psBitSetOp:           return NULL for AND operator with BitSet inputs of"
+            " differing size.");
+    }
+    psFree(bs);
+    bs = psBitSetAlloc(16);
+    bs = psBitSetSet(bs, 1);     // 0000 0010 == 2
+    bs2 = psBitSetSet(bs2, 2);   // 0000 0100 == 4
+    //Return correct psBitSet output for valid inputs with AND operator
+    {
+        out = psBitSetOp(out, bs, "AND", bs2);
+        ok( out->bits[0] == 0,
+            "psBitSetOp:           return correct psBitSet output for valid inputs"
+            " with AND operator.");
+    }
+    //Return correct psBitSet output for valid inputs with OR operator
+    {
+        out = psBitSetOp(out, bs, "OR", bs2);
+        ok( out->bits[0] == 6,
+            "psBitSetOp:           return correct psBitSet output for valid inputs"
+            " with OR operator.");
+    }
+    //Return correct psBitSet output for valid inputs with XOR operator
+    bs2 = psBitSetSet(bs2, 1);     // 0000 0110 == 6
+    {
+        out = psBitSetOp(out, bs, "XOR", bs2);
+        ok( out->bits[0] == 4,
+            "psBitSetOp:           return correct psBitSet output for valid inputs"
+            " with XOR operator.");
+    }
+    //Return correct psBitSet output for valid inputs with NOT operator
+    {
+        psFree(out);
+        out = psBitSetAlloc(0);
+        bs = psBitSetSet(bs, 2);  // 0000 0110 == 4
+        bs = psBitSetSet(bs, 3);  // 0000 1110 == 12
+        bs = psBitSetSet(bs, 4);  // 0001 1110 == 28
+        bs = psBitSetSet(bs, 5);  // 0011 1110 == 60
+        bs = psBitSetSet(bs, 6);  // 0111 1110 == 124
+        bs = psBitSetSet(bs, 7);  // 1111 1110 == 252
+        out = psBitSetOp(out, bs, "NOT", bs2);
+        ok( out->bits[0] == 1,
+            "psBitSetOp:           return correct psBitSet output for valid inputs"
+            " with NOT operator.");
+    }
+
+    //psBitSetToString Tests
+    //Return NULL for NULL BitSet input
+    psString bitStr = NULL;
+    {
+        bitStr = psBitSetToString(noBits);
+        ok( bitStr == NULL,
+            "psBitSetToString:     return NULL for NULL BitSet input.");
+    }
+    //Return correct string for valid BitSet input
+    {
+        psFree(bs);
+        bs = psBitSetAlloc(8);
+        bs = psBitSetSet(bs, 2);  // 0000 0100 == 4
+        bitStr = psBitSetToString(bs);
+        ok( !strncmp(bitStr, "00000100", 10),
+            "psBitSetToString:     return correct string for valid BitSet input.");
+    }
 
 
     //Check for Memory leaks
     {
+        psFree(bitStr);
+        psFree(out);
+        psFree(bs);
+        psFree(bs2);
         checkMem();
     }
 }
-
-/*
-    //Attempt to reallocate the psArray - smaller
-{
-    skip_start(  !psArraySet(a, 0, s32) || !psArraySet(a, 1, s32), 1,
-                  "Skipping 1 tests because psArraySet failed");
-    ok( a->n == 1 && a->nalloc == 1 && *s32_2 == 1,
-        "psArrayRealloc:   return properly reallocated psArray.");
-    skip_end();
-}
- 
-*/
-
Index: /trunk/psLib/test/types/tap_psHash_all.c
===================================================================
--- /trunk/psLib/test/types/tap_psHash_all.c	(revision 9081)
+++ /trunk/psLib/test/types/tap_psHash_all.c	(revision 9082)
@@ -12,4 +12,5 @@
 
 #include <pslib.h>
+#include <string.h>
 
 #include "tap.h"
Index: /trunk/psLib/test/types/tap_psList_all.c
===================================================================
--- /trunk/psLib/test/types/tap_psList_all.c	(revision 9081)
+++ /trunk/psLib/test/types/tap_psList_all.c	(revision 9082)
@@ -12,4 +12,5 @@
 
 #include <pslib.h>
+#include <string.h>
 
 #include "tap.h"
