Index: trunk/psLib/test/dataManip/tst_psStats07.c
===================================================================
--- trunk/psLib/test/dataManip/tst_psStats07.c	(revision 1900)
+++ trunk/psLib/test/dataManip/tst_psStats07.c	(revision 2197)
@@ -10,10 +10,10 @@
 #include <math.h>
 
-#define N 200
+#define N 90
 #define MEAN 32.0
 #define STDEV 2.0
 #define ERROR_TOLERANCE 0.10
 
-int main()
+int t00()
 {
     psStats * myStats = NULL;
@@ -32,18 +32,11 @@
     float realMedianNoMask = MEAN;
     float realModeNoMask = MEAN;
-    float realStdevNoMask = STDEV * 0.33;
+    float realStdevNoMask = STDEV * 0.20;
     float realLQNoMask = MEAN - ( 0.6 * STDEV );
     float realUQNoMask = MEAN + ( 0.6 * STDEV );
     int realN50NoMask = N / 4;
     int realNfitNoMask = N / 4;
-    float realMeanWithMask = MEAN;
-    float realMedianWithMask = MEAN;
-    float realModeWithMask = MEAN;
-    float realStdevWithMask = STDEV;
-    float realLQWithMask = MEAN;
-    float realUQWithMask = MEAN;
-    int realN50WithMask = N / 4;
-    int realNfitWithMask = N / 4;
-
+
+    psTraceSetLevel(".psLib.dataManip.psStats", 10);
 
     /*************************************************************************/
@@ -232,7 +225,78 @@
                  "PS_STAT_ROBUST_STATS: robust Nfit: no vector mask",
                  testStatus );
-
-
-    return ( 0 );
+    return(testStatus);
+
+    /*************************************************************************/
+    /*  Deallocate data structures                                           */
+    /*************************************************************************/
+    printPositiveTestHeader( stdout,
+                             "psStats functions",
+                             "psStats(): deallocating memory" );
+
+    psFree( myStats );
+    psFree( myVector );
+    psFree( maskVector );
+
+    psMemCheckCorruption( 1 );
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
+    if ( 0 != memLeaks ) {
+        psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
+    }
+
+    printFooter( stdout,
+                 "psVector functions",
+                 "psStats(): deallocating memory",
+                 testStatus );
+
+    return ( !globalTestStatus );
+}
+
+
+int t01()
+{
+    psStats * myStats = NULL;
+    int testStatus = true;
+    int globalTestStatus = true;
+    int i = 0;
+    psVector *myVector = NULL;
+    psVector *maskVector = NULL;
+    // NOTE: These values were calculated by running the function on the data.
+    // A: They must be changed if we adjust the number of data points.
+    // B: We don't really know that they are correct.
+    int count = 0;
+    int currentId = psMemGetId();
+    int memLeaks = 0;
+    float realMeanWithMask = MEAN;
+    float realMedianWithMask = MEAN;
+    float realModeWithMask = MEAN;
+    float realStdevWithMask = STDEV * 0.20;
+    float realLQWithMask = MEAN;
+    float realUQWithMask = MEAN;
+    int realN50WithMask = N / 4;
+    int realNfitWithMask = N / 4;
+
+    psTraceSetLevel(".psLib.dataManip.psStats", 10);
+
+    /*************************************************************************/
+    /*  Allocate and initialize data structures                              */
+    /*************************************************************************/
+    myStats = psStatsAlloc( PS_STAT_ROBUST_MEAN |
+                            PS_STAT_ROBUST_MEDIAN |
+                            PS_STAT_ROBUST_MODE |
+                            PS_STAT_ROBUST_STDEV |
+                            PS_STAT_ROBUST_QUARTILE );
+
+    maskVector = psVectorAlloc( N, PS_TYPE_U8 );
+    maskVector->n = N;
+    myVector = psGaussianDev( MEAN, STDEV, N );
+    // Set the mask vector and calculate the expected maximum.
+    for ( i = 0;i < N;i++ ) {
+        if ( i < ( N / 2 ) ) {
+            maskVector->data.U8[ i ] = 0;
+            count++;
+        } else {
+            maskVector->data.U8[ i ] = 1;
+        }
+    }
 
     /*************************************************************************/
@@ -422,2 +486,8 @@
     return ( !globalTestStatus );
 }
+
+int main()
+{
+    t00();
+    t01();
+}
