Index: trunk/psLib/test/dataManip/tst_psFunc07.c
===================================================================
--- trunk/psLib/test/dataManip/tst_psFunc07.c	(revision 1946)
+++ trunk/psLib/test/dataManip/tst_psFunc07.c	(revision 1982)
@@ -12,5 +12,5 @@
 #include "psFunctions.h"
 
-#define NUM_SPLINES 5
+#define NUM_SPLINES 50
 #define A 4.0
 #define B -3.0
@@ -20,4 +20,5 @@
 #define MAX 30
 #define ERROR_TOLERANCE 0.10
+#define OFFSET (NUM_SPLINES * ERROR_TOLERANCE)
 
 float myFunc(float x)
@@ -26,5 +27,5 @@
 }
 
-int main()
+int t00()
 {
     int testStatus = true;
@@ -37,8 +38,4 @@
     psVector *y = NULL;
     psVector *newY = NULL;
-    float NRX[NUM_SPLINES+2];
-    float NRY[NUM_SPLINES+2];
-    //    float tmpY;
-    //    float derivs[NUM_SPLINES+2];
 
     psTraceSetLevel(".", 0);
@@ -46,7 +43,4 @@
     /****************************************************************************/
     testStatus = true;
-    printPositiveTestHeader(stdout,
-                            "psFunction functions",
-                            "psSpline1DAlloc()");
     x = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F32);
     newX = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F32);
@@ -55,8 +49,8 @@
 
     for (i=0;i<NUM_SPLINES+1;i++) {
-        NRX[i+1] = x->data.F32[i] = tmpSpline->domains[i];
-        NRY[i+1] = y->data.F32[i] = myFunc(x->data.F32[i]);
-        //        printf("DATA: (x, y) is (%f, %f)\n", x->data.F32[i], y->data.F32[i]);
+        x->data.F32[i] = tmpSpline->domains[i];
+        y->data.F32[i] = myFunc(x->data.F32[i]);
     }
+
     for (i=0;i<NUM_SPLINES;i++) {
         newX->data.F32[i]= ((x->data.F32[i] + x->data.F32[i+1])/2.0);
@@ -66,16 +60,16 @@
     /*   psLib Code      */
     /****************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
 
     psVectorFitSpline1D(tmpSpline, x, y, NULL);
     newY = psSpline1DEvalVector(newX, tmpSpline);
 
-    for (i=0;i<NUM_SPLINES+1;i++) {
+    for (i=OFFSET;i<NUM_SPLINES-OFFSET+1;i++) {
         if ( fabs( newY->data.F32[i] - myFunc(newX->data.F32[i]) ) > fabs( ERROR_TOLERANCE * myFunc(newX->data.F32[i]) ) ) {
             printf("ERROR[%d]: f(%f) is %f.  Should be %f\n", i,
                    newX->data.F32[i], newY->data.F32[i], myFunc(newX->data.F32[i]));
         }
-        //        tmpY = p_psNRSpline1DEval(tmpSpline, x, y, newX->data.F32[i]);
-        //        printf("HMMM: p_psNRSpline1DEval(%f) is %f.  Should be %f\n",
-        //                newX->data.F32[i], tmpY, myFunc(newX->data.F32[i]));
     }
 
@@ -99,2 +93,74 @@
     return (!testStatus);
 }
+
+int t00()
+{
+    int testStatus = true;
+    int memLeaks=0;
+    int  currentId = psMemGetId();
+    int i;
+    psSpline1D *tmpSpline = NULL;
+    psVector *x = NULL;
+    psVector *newX = NULL;
+    psVector *y = NULL;
+    psVector *newY = NULL;
+
+    psTraceSetLevel(".", 0);
+    /****************************************************************************/
+    /****************************************************************************/
+    testStatus = true;
+    x = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F32);
+    newX = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F32);
+    y = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F32);
+    tmpSpline = psSpline1DAlloc(NUM_SPLINES, 3, MIN, MAX);
+
+    for (i=0;i<NUM_SPLINES+1;i++) {
+        x->data.F32[i] = tmpSpline->domains[i];
+        y->data.F32[i] = myFunc(x->data.F32[i]);
+    }
+
+    for (i=0;i<NUM_SPLINES;i++) {
+        newX->data.F32[i]= ((x->data.F32[i] + x->data.F32[i+1])/2.0);
+    }
+    newX->data.F32[NUM_SPLINES] = x->data.F32[NUM_SPLINES];
+    /****************************************************************************/
+    /*   psLib Code      */
+    /****************************************************************************/
+    printPositiveTestHeader(stdout,
+                            "psFunction functions",
+                            "psSpline1DAlloc()");
+
+    psVectorFitSpline1D(tmpSpline, x, y, NULL);
+    newY = psSpline1DEvalVector(newX, tmpSpline);
+
+    for (i=OFFSET;i<NUM_SPLINES-OFFSET+1;i++) {
+        if ( fabs( newY->data.F32[i] - myFunc(newX->data.F32[i]) ) > fabs( ERROR_TOLERANCE * myFunc(newX->data.F32[i]) ) ) {
+            printf("ERROR[%d]: f(%f) is %f.  Should be %f\n", i,
+                   newX->data.F32[i], newY->data.F32[i], myFunc(newX->data.F32[i]));
+        }
+    }
+
+    psFree(x);
+    psFree(newX);
+    psFree(y);
+    p_psSpline1DFree(tmpSpline);
+    psFree(newY);
+
+    psMemCheckCorruption(1);
+    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
+    if (0 != memLeaks) {
+        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
+    }
+
+    printFooter(stdout,
+                "psFunctions functions",
+                "psSpline1DAlloc()",
+                testStatus);
+
+    return (!testStatus);
+}
+
+int main()
+{
+    t00();
+}
