Index: /trunk/psLib/src/collections/psBitSet.c
===================================================================
--- /trunk/psLib/src/collections/psBitSet.c	(revision 964)
+++ /trunk/psLib/src/collections/psBitSet.c	(revision 965)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-09 21:18:24 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-10 00:29:09 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,4 +22,5 @@
 #include <stdio.h>
 #include <ctype.h>
+#include <math.h>
 
 #include "psBitSet.h"
@@ -77,4 +78,5 @@
 psBitSet* psBitSetAlloc(int n)
 {
+    int numBytes = 0;
     psBitSet *newObj = NULL;
 
@@ -84,11 +86,12 @@
     }
 
+    numBytes = ceil(n/8.0);
     newObj = psAlloc(sizeof(psBitSet));
-    newObj->n = n;
+    newObj->n = numBytes;
 
     // Ignore splint warning about releasing pointer members, since they've not been allocated yet
     /*@i@*/
-    newObj->bits = psAlloc(sizeof(char)*n);
-    memset(newObj->bits, n, 0);
+    newObj->bits = psAlloc(sizeof(char)*numBytes);
+    memset(newObj->bits, numBytes, 0);
 
     return newObj;
@@ -113,5 +116,8 @@
         return inBitSet;
     } else if(bit < 0) {
-        psError(__func__, " : Line %d - Negative bit position not allowed: %d\n", __LINE__, bit);
+        psError(__func__, " : Line %d - Bit position too small: %d\n", __LINE__, bit);
+        return inBitSet;
+    } else if(bit > inBitSet->n*8-1) {
+        psError(__func__, " : Line %d - Bit position too large: %d\n", __LINE__, bit);
         return inBitSet;
     }
@@ -132,5 +138,8 @@
         return 0;
     } else if(bit < 0) {
-        psError(__func__, " : Line %d - Negative bit position not allowed: %d\n", __LINE__, bit);
+        psError(__func__, " : Line %d - Bit position too small: %d\n", __LINE__, bit);
+        return 0;
+    } else if(bit > inBitSet->n*8-1) {
+        psError(__func__, " : Line %d - Bit position too large: %d\n", __LINE__, bit);
         return 0;
     }
Index: /trunk/psLib/src/collections/psBitSet.h
===================================================================
--- /trunk/psLib/src/collections/psBitSet.h	(revision 964)
+++ /trunk/psLib/src/collections/psBitSet.h	(revision 965)
@@ -4,12 +4,12 @@
  *
  *  Bit masks are useful tools for toggling various flags and options. This set of functions module provides
- *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary 
+ *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary
  *  operations. A print function is also provided to display the entire set of bits in binary format as a
  *  string.
  *
  *  @author Ross Harman, MHPCC
- *   
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-08 00:08:27 $
+ *
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-10 00:28:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -25,5 +25,5 @@
 /** 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 
+ *  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.
  */
@@ -41,5 +41,5 @@
 /** Allocate a psBitSet.
  *
- *  Create a psBitSet with the number of bytes specified by the user. All bits are set to zero upon 
+ *  Create a psBitSet with the number of bytes specified by the user. All bits are set to zero upon
  *  allocation.
  *
@@ -48,5 +48,5 @@
 /*@null@*/
 psBitSet* psBitSetAlloc(
-    int n   /**< Number of bytes in psBitSet array */
+    int n   /**< Number of bits in psBitSet array */
 );
 
@@ -61,5 +61,5 @@
 /** Set a bit.
  *
- *  Sets a bit at a given bit location, either one or zero. The bit is set based on a zero index with the 
+ *  Sets a bit at a given bit location, either one or zero. 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.
@@ -74,6 +74,6 @@
 /** 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 
+ *  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.
Index: /trunk/psLib/src/types/psBitSet.c
===================================================================
--- /trunk/psLib/src/types/psBitSet.c	(revision 964)
+++ /trunk/psLib/src/types/psBitSet.c	(revision 965)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-09 21:18:24 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-10 00:29:09 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,4 +22,5 @@
 #include <stdio.h>
 #include <ctype.h>
+#include <math.h>
 
 #include "psBitSet.h"
@@ -77,4 +78,5 @@
 psBitSet* psBitSetAlloc(int n)
 {
+    int numBytes = 0;
     psBitSet *newObj = NULL;
 
@@ -84,11 +86,12 @@
     }
 
+    numBytes = ceil(n/8.0);
     newObj = psAlloc(sizeof(psBitSet));
-    newObj->n = n;
+    newObj->n = numBytes;
 
     // Ignore splint warning about releasing pointer members, since they've not been allocated yet
     /*@i@*/
-    newObj->bits = psAlloc(sizeof(char)*n);
-    memset(newObj->bits, n, 0);
+    newObj->bits = psAlloc(sizeof(char)*numBytes);
+    memset(newObj->bits, numBytes, 0);
 
     return newObj;
@@ -113,5 +116,8 @@
         return inBitSet;
     } else if(bit < 0) {
-        psError(__func__, " : Line %d - Negative bit position not allowed: %d\n", __LINE__, bit);
+        psError(__func__, " : Line %d - Bit position too small: %d\n", __LINE__, bit);
+        return inBitSet;
+    } else if(bit > inBitSet->n*8-1) {
+        psError(__func__, " : Line %d - Bit position too large: %d\n", __LINE__, bit);
         return inBitSet;
     }
@@ -132,5 +138,8 @@
         return 0;
     } else if(bit < 0) {
-        psError(__func__, " : Line %d - Negative bit position not allowed: %d\n", __LINE__, bit);
+        psError(__func__, " : Line %d - Bit position too small: %d\n", __LINE__, bit);
+        return 0;
+    } else if(bit > inBitSet->n*8-1) {
+        psError(__func__, " : Line %d - Bit position too large: %d\n", __LINE__, bit);
         return 0;
     }
Index: /trunk/psLib/src/types/psBitSet.h
===================================================================
--- /trunk/psLib/src/types/psBitSet.h	(revision 964)
+++ /trunk/psLib/src/types/psBitSet.h	(revision 965)
@@ -4,12 +4,12 @@
  *
  *  Bit masks are useful tools for toggling various flags and options. This set of functions module provides
- *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary 
+ *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary
  *  operations. A print function is also provided to display the entire set of bits in binary format as a
  *  string.
  *
  *  @author Ross Harman, MHPCC
- *   
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-08 00:08:27 $
+ *
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-10 00:28:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -25,5 +25,5 @@
 /** 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 
+ *  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.
  */
@@ -41,5 +41,5 @@
 /** Allocate a psBitSet.
  *
- *  Create a psBitSet with the number of bytes specified by the user. All bits are set to zero upon 
+ *  Create a psBitSet with the number of bytes specified by the user. All bits are set to zero upon
  *  allocation.
  *
@@ -48,5 +48,5 @@
 /*@null@*/
 psBitSet* psBitSetAlloc(
-    int n   /**< Number of bytes in psBitSet array */
+    int n   /**< Number of bits in psBitSet array */
 );
 
@@ -61,5 +61,5 @@
 /** Set a bit.
  *
- *  Sets a bit at a given bit location, either one or zero. The bit is set based on a zero index with the 
+ *  Sets a bit at a given bit location, either one or zero. 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.
@@ -74,6 +74,6 @@
 /** 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 
+ *  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.
Index: /trunk/psLib/test/collections/tst_psBitSet_01.c
===================================================================
--- /trunk/psLib/test/collections/tst_psBitSet_01.c	(revision 964)
+++ /trunk/psLib/test/collections/tst_psBitSet_01.c	(revision 965)
@@ -5,12 +5,18 @@
  *  This test driver contains the following tests for psArray test point 1:
  *     A)  Create psBitSet
- *     B)  Set single bit
- *     C)  Test single bit
- *     D)  Free psBitSet
+ *     B)  Set bits
+ *     C)  Test bits
+ *     D)  Attempt to test negative bit
+ *     E)  Attempt to test bit to large
+ *     F)  Attempt to test bit in null BitSet
+ *     G)  Attempt to set negative bit
+ *     H)  Attempt to set bit to large
+ *     I)  Attempt to set bit in null BitSet
+ *     J)  Free psBitSet
  *
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-05-18 19:22:34 $
+ *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-06-10 00:28:23 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +31,5 @@
 {
     char *binOut = NULL;
+    psBitSet *tempBs = NULL;
 
 
@@ -30,5 +37,5 @@
     printPositiveTestHeader(stdout,"psBitSet", "Create psBitSet");
     printf("Creating psBitSet with 24 bits...\n");
-    psBitSet* bs = psBitSetAlloc(3);
+    psBitSet* bs = psBitSetAlloc(24);
     binOut = psBitSetToString(bs);
     printf("%s\n\n", binOut);
@@ -37,22 +44,80 @@
 
 
-    // Test B - Set single bit
-    printPositiveTestHeader(stdout, "psBitSet", "Set single bit");
+    // Test B - Set bits
+    printPositiveTestHeader(stdout, "psBitSet", "Set bits");
+    tempBs = bs;
+    printf("Setting first bit...\n");
+    bs = psBitSetSet(bs, 0);
     printf("Setting third bit...\n");
     bs = psBitSetSet(bs, 2);
+    printf("Setting last bit...\n");
+    bs = psBitSetSet(bs, 23);
+    if(bs != tempBs) {
+        printf("Error: Return pointer not equal to output argument pointer\n");
+    }
     binOut = psBitSetToString(bs);
     printf("%s\n\n", binOut);
     psFree(binOut);
-    printFooter(stdout, "psBitSet", "Set single bit", true);
+    printFooter(stdout, "psBitSet", "Set bits", true);
 
 
-    // Test C - Test single bit
-    printPositiveTestHeader(stdout, "psBitSet", "Test single bit");
+    // Test C - Test bits
+    printPositiveTestHeader(stdout, "psBitSet", "Test bits");
+    printf("Testing first bit...\n");
+    printf("Result: %d\n", psBitSetTest(bs, 0));
     printf("Testing third bit...\n");
     printf("Result: %d\n", psBitSetTest(bs, 2));
-    printFooter(stdout, "psBitSet", "Test single bit", true);
+    printf("Testing last bit...\n");
+    printf("Result: %d\n", psBitSetTest(bs, 23));
+    printFooter(stdout, "psBitSet", "Test bits", true);
 
 
-    // Test D - Free psBitSet
+    // Test D - Attempt to test negative bit
+    printNegativeTestHeader(stdout,"psBitSet", "Attempt to test negative bit",
+                            "Bit position too small: -4", 0);
+    if(psBitSetTest(bs, -4)) {
+        printf("Error: Return value should be zero\n");
+    }
+    printFooter(stdout, "psBitSet", "Attempt to test negative bit", true);
+
+
+    // Test E - Attempt to test bit to large
+    printNegativeTestHeader(stdout,"psBitSet", "Attempt to test bit to large",
+                            "Bit position too large: 200", 0);
+    if(psBitSetTest(bs, 200)) {
+        printf("Error: Return value should be zero\n");
+    }
+    printFooter(stdout, "psBitSet", "Attempt to test bit to large", true);
+
+
+    // Test F - Attempt to test bit in null BitSet
+    printNegativeTestHeader(stdout,"psBitSet", "Attempt to test bit in null BitSet",
+                            "Null psBitSet for inBitSet argument", 0);
+    psBitSetTest(NULL, 0);
+    printFooter(stdout, "psBitSet", "Attempt to test bit in null BitSet", true);
+
+
+    // Test G - Attempt to set negative bit
+    printNegativeTestHeader(stdout,"psBitSet", "Attempt to set negative bit",
+                            "Bit position too small: -4", 0);
+    bs = psBitSetSet(bs, -4);
+    printFooter(stdout, "psBitSet", "Attempt to set negative bit", true);
+
+
+    // Test H - Attempt to set bit to large
+    printNegativeTestHeader(stdout,"psBitSet", "Attempt to set bit to large",
+                            "Bit position too large: 200", 0);
+    bs = psBitSetSet(bs, 200);
+    printFooter(stdout, "psBitSet", "Attempt to set bit to large", true);
+
+
+    // Test I - Attempt to set bit in null BitSet
+    printNegativeTestHeader(stdout,"psBitSet", "Attempt to set bit in null BitSet",
+                            "Null psBitSet for inBitSet argument", 0);
+    psBitSetSet(NULL, 0);
+    printFooter(stdout, "psBitSet", "Attempt to set bit in null BitSet", true);
+
+
+    // Test J - Free psBitSet
     printPositiveTestHeader(stdout, "psBitSet", "Free psBitSet");
     psBitSetFree(bs);
Index: /trunk/psLib/test/collections/tst_psBitSet_05.c
===================================================================
--- /trunk/psLib/test/collections/tst_psBitSet_05.c	(revision 964)
+++ /trunk/psLib/test/collections/tst_psBitSet_05.c	(revision 965)
@@ -10,6 +10,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-05-18 19:22:34 $
+ *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-06-10 00:28:36 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -28,6 +28,6 @@
     // Test A - Create two psBitSets
     printPositiveTestHeader(stdout,"psBitSet", "Create two psBitSets of different size");
-    psBitSet* bs1 = psBitSetAlloc(3);
-    psBitSet* bs2 = psBitSetAlloc(5);
+    psBitSet* bs1 = psBitSetAlloc(24);
+    psBitSet* bs2 = psBitSetAlloc(40);
     binOut = psBitSetToString(bs1);
     printf("%s\n", binOut);
@@ -41,5 +41,5 @@
     // Test B - Attempt OR with psBitsets, should get error
     printNegativeTestHeader(stdout, "psBitSet", "Attempt OR with psBitsets", "psBitSet sizes not the same", 0);
-    psBitSet* outbs = psBitSetAlloc(3);
+    psBitSet* outbs = psBitSetAlloc(24);
     outbs = psBitSetOp(outbs, bs1, "OR", bs2);
     printFooter(stdout, "psBitSet", "Attempt OR with psBitsets", true);
Index: /trunk/psLib/test/collections/tst_psBitSet_06.c
===================================================================
--- /trunk/psLib/test/collections/tst_psBitSet_06.c	(revision 964)
+++ /trunk/psLib/test/collections/tst_psBitSet_06.c	(revision 965)
@@ -12,6 +12,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2004-06-09 21:29:56 $
+ *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2004-06-10 00:28:43 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -30,6 +30,6 @@
     // Test A - Create two psBitSets
     printPositiveTestHeader(stdout,"psBitSet", "Create two psBitSets");
-    psBitSet* bs1 = psBitSetAlloc(3);
-    psBitSet* bs2 = psBitSetAlloc(3);
+    psBitSet* bs1 = psBitSetAlloc(24);
+    psBitSet* bs2 = psBitSetAlloc(24);
     binOut = psBitSetToString(bs1);
     printf("%s\n", binOut);
@@ -44,5 +44,5 @@
     printNegativeTestHeader(stdout,"psBitSet", "Perform invalid binary operation",
                             "Invalid psBitMask binary operation", 0);
-    psBitSet* outbs = psBitSetAlloc(3);
+    psBitSet* outbs = psBitSetAlloc(24);
     outbs = psBitSetOp(outbs, bs1, "ZZXOR", bs2);
     printFooter(stdout, "psBitSet", "Perform binary XOR with psBitSets", true);
