Index: trunk/psLib/test/dataManip/tst_psHist02.c
===================================================================
--- trunk/psLib/test/dataManip/tst_psHist02.c	(revision 887)
+++ trunk/psLib/test/dataManip/tst_psHist02.c	(revision 893)
@@ -12,5 +12,4 @@
 #define LOWER 20.0
 #define UPPER 30.0
-#define NUM_BINS 20
 #define NUM_DATA 10000
 
@@ -18,8 +17,11 @@
 {
     psHistogram *myHist = NULL;
+    psHistogram *myHist2= NULL;
     psVector *myData    = NULL;
     psVector *myMask    = NULL;
     int testStatus      = true;
     int memLeaks        = 0;
+    int nb              = 0;
+    int numBins         = 0;
     int i               = 0;
     int currentId       = 0;
@@ -27,4 +29,7 @@
     currentId       = psMemGetId();
 
+    /*********************************************************************/
+    /*  Allocate and initialize data structures                          */
+    /*********************************************************************/
     myData = psVectorAlloc(NUM_DATA, PS_TYPE_F32);
     myData->n = myData->nalloc;
@@ -42,47 +47,115 @@
         }
     }
-    /*************************************************************************/
-    /*  Allocate and Perform Histogram, no mask                      */
-    /*************************************************************************/
+
+    for (nb=0;nb<4;nb++) {
+        if (nb == 0)
+            numBins = 1;
+        if (nb == 1)
+            numBins = 2;
+        if (nb == 2)
+            numBins = 10;
+        if (nb == 3)
+            numBins = 20;
+
+        /*********************************************************************/
+        /*  Allocate and Perform Histogram, no mask                          */
+        /*********************************************************************/
+        printPositiveTestHeader(stdout,
+                                "psStats functions",
+                                "Allocate and Perform Histogram, no mask");
+
+        myHist = psHistogramAlloc(LOWER, UPPER, numBins);
+        myHist = psHistogramVector(myHist, myData, NULL, 0);
+
+        for (i=0;i<numBins;i++) {
+            printf("Bin number %d bounds: (%f - %f) data (%d)\n", i,
+                   myHist->bounds->data.F32[i],
+                   myHist->bounds->data.F32[i+1],
+                   myHist->nums->data.S32[i]);
+        }
+        psMemCheckCorruption(1);
+        psHistogramFree(myHist);
+        psMemCheckCorruption(1);
+
+        printFooter(stdout,
+                    "psStats functions",
+                    "Allocate and Perform Histogram, no mask",
+                    testStatus);
+
+        /*********************************************************************/
+        /*  Allocate and Perform Histogram with mask                         */
+        /*********************************************************************/
+        printPositiveTestHeader(stdout,
+                                "psStats functions",
+                                "Allocate and Perform Histogram with mask");
+
+        myHist = psHistogramAlloc(LOWER, UPPER, numBins);
+        myHist = psHistogramVector(myHist, myData, myMask, 1);
+
+        for (i=0;i<numBins;i++) {
+            printf("Bin number %d bounds: (%f - %f) data (%d)\n", i,
+                   myHist->bounds->data.F32[i],
+                   myHist->bounds->data.F32[i+1],
+                   myHist->nums->data.S32[i]);
+        }
+        psMemCheckCorruption(1);
+        psHistogramFree(myHist);
+        psMemCheckCorruption(1);
+
+        printFooter(stdout,
+                    "psStats functions",
+                    "Allocate and Perform Histogram with mask",
+                    testStatus);
+    }
+    psVectorFree(myMask);
+
     printPositiveTestHeader(stdout,
                             "psStats functions",
-                            "Allocate and Perform Histogram, no mask");
+                            "Calling psHistogramVector() with various NULL inputs.");
 
-    myHist = psHistogramAlloc(LOWER, UPPER, NUM_BINS);
-    myHist = psHistogramVector(myHist, myData, NULL, 0);
+    // Verify the return value is null and program execution doesn't stop,
+    // if input parameter myHist is null.
 
-    for (i=0;i<NUM_BINS;i++) {
-        printf("Bin number %d bounds: (%f - %f) data (%d)\n", i,
-               myHist->bounds->data.F32[i],
-               myHist->bounds->data.F32[i+1],
-               myHist->nums->data.S32[i]);
+    myHist2 = psHistogramVector(NULL, myData, NULL, 0);
+    if (myHist2 != NULL) {
+        printf("ERROR: myHist2!=NULL\n");
+        testStatus = false;
+    }
+    psVectorFree(myData);
+
+
+    // Verify the retrun value is the same as the input parameter myHist and
+    // program execution doesn't stop, if the input parameter myArray is
+    // null.
+
+    myHist = psHistogramAlloc(LOWER, UPPER, numBins);
+    myHist = psHistogramVector(myHist, NULL, NULL, 0);
+    if (myHist == NULL) {
+        printf("ERROR: myHist==NULL\n");
+        testStatus = false;
     }
     psHistogramFree(myHist);
 
+
+    // Verify the return value is the same as the input parameter myHist and
+    // program execution doesn't stop, if the input parameter myArray has no
+    // elements.
+    // NOTE: This code segment is commented out because psVectorAlloc returns
+    // NULL if called with an N element data.
+    /*
+    myData = psVectorAlloc(0, PS_TYPE_F32);
+    myData->n = myData->nalloc;
+    myHist = psHistogramAlloc(LOWER, UPPER, numBins);
+    myHist = psHistogramVector(myHist, NULL, NULL, 0);
+    if (myHist == NULL) {
+        printf("ERROR: myHist==NULL\n");
+        testStatus = false;
+    }
+    psHistogramFree(myHist);
+    psVectorFree(myData);
+    */
     printFooter(stdout,
                 "psStats functions",
-                "Allocate and Perform Histogram, no mask",
-                testStatus);
-
-    /*************************************************************************/
-    /*  Allocate and Perform Histogram with mask                     */
-    /*************************************************************************/
-    printPositiveTestHeader(stdout,
-                            "psStats functions",
-                            "Allocate and Perform Histogram with mask");
-
-    myHist = psHistogramAlloc(LOWER, UPPER, NUM_BINS);
-    myHist = psHistogramVector(myHist, myData, myMask, 1);
-
-    for (i=0;i<NUM_BINS;i++) {
-        printf("Bin number %d bounds: (%f - %f) data (%d)\n", i,
-               myHist->bounds->data.F32[i],
-               myHist->bounds->data.F32[i+1],
-               myHist->nums->data.S32[i]);
-    }
-
-    printFooter(stdout,
-                "psStats functions",
-                "Allocate and Perform Histogram with mask",
+                "Calling psHistogramVector() with various NULL inputs.",
                 testStatus);
 
@@ -93,7 +166,4 @@
                             "psStats functions",
                             "Deallocate the psHistogram structure.");
-    psHistogramFree(myHist);
-    psVectorFree(myData);
-    psVectorFree(myMask);
 
     psMemCheckCorruption(1);
