Index: /trunk/psModules/src/pmObjects.c
===================================================================
--- /trunk/psModules/src/pmObjects.c	(revision 3716)
+++ /trunk/psModules/src/pmObjects.c	(revision 3717)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-14 03:27:50 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 22:58:48 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -45,5 +45,5 @@
     tmp->y = 0.0;
     tmp->Sx = 0.0;
-    tmp->Sx = 0.0;
+    tmp->Sy = 0.0;
     tmp->Sxy = 0.0;
     tmp->Sum = 0.0;
@@ -325,4 +325,5 @@
         psError(PS_ERR_UNKNOWN, true, "Currently, input image must have at least 2 rows and 2 columns.");
     }
+    psPeakType myPeakClass = PM_PEAK_UNDEF;
     psVector *tmpRow = NULL;
     psU32 col = 0;
@@ -343,33 +344,51 @@
         //
         if (col == 0) {
-            if ( (image->data.F32[row][col] >  image->data.F32[row][col+1]) &&
+            if ( (image->data.F32[row][col] > threshold) &&
+                    (image->data.F32[row][col] >  image->data.F32[row][col+1]) &&
                     (image->data.F32[row][col] >  image->data.F32[row+1][col]) &&
                     (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
-                if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
+                myPeakClass = PM_PEAK_EDGE;
+                if (image->data.F32[row][col] > image->data.F32[row+1][col+1]) {
+                    myPeakClass|= PM_PEAK_LONE;
+                } else {
+                    myPeakClass|= PM_PEAK_FLAT;
                 }
+                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
             }
         } else if (col < (image->numCols - 1)) {
-            if ( (image->data.F32[row][col] >= image->data.F32[row][col-1]) &&
+            if ( (image->data.F32[row][col] > threshold) &&
+                    (image->data.F32[row][col] >= image->data.F32[row][col-1]) &&
                     (image->data.F32[row][col] >  image->data.F32[row][col+1]) &&
                     (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
                     (image->data.F32[row][col] >  image->data.F32[row+1][col]) &&
                     (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
-                if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
+
+                myPeakClass = PM_PEAK_EDGE;
+                if ( (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
+                        (image->data.F32[row][col] > image->data.F32[row+1][col-1]) &&
+                        (image->data.F32[row][col] > image->data.F32[row+1][col+1])) {
+                    myPeakClass|= PM_PEAK_LONE;
+                } else {
+                    myPeakClass|= PM_PEAK_FLAT;
                 }
+                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
             }
 
         } else if (col == (image->numCols - 1)) {
-            if ( (image->data.F32[row][col] >= image->data.F32[row][col-1]) &&
+            if ( (image->data.F32[row][col] > threshold) &&
+                    (image->data.F32[row][col] >= image->data.F32[row][col-1]) &&
                     (image->data.F32[row][col] > image->data.F32[row+1][col]) &&
                     (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) {
-                if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
+                myPeakClass = PM_PEAK_EDGE;
+                if ( (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
+                        (image->data.F32[row][col] > image->data.F32[row+1][col-1])) {
+                    myPeakClass|= PM_PEAK_LONE;
+                } else {
+                    myPeakClass|= PM_PEAK_FLAT;
                 }
+                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
             }
-
         } else {
-            psError(PS_ERR_UNKNOWN, true, "peak specified valid column range.");
+            psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range.");
         }
     }
@@ -390,20 +409,30 @@
         // Step through all local peaks in this row.
         for (psU32 i = 0 ; i < row1->n ; i++ ) {
-            psPeakType myType = PM_PEAK_UNDEF;
             col = row1->data.U32[i];
 
             if (col == 0) {
                 // If col==0, then we can not read col-1 pixels
-                if ((image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
+                if ((image->data.F32[row][col] > threshold) &&
+                        (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
                         (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
                         (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&
                         (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&
                         (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
-                    myType = PM_PEAK_EDGE;
-                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType);
+
+                    myPeakClass = PM_PEAK_EDGE;
+                    if ((image->data.F32[row][col] > image->data.F32[row-1][col+1]) &&
+                            (image->data.F32[row][col] > image->data.F32[row][col+1]) &&
+                            (image->data.F32[row][col] > image->data.F32[row+1][col]) &&
+                            (image->data.F32[row][col] > image->data.F32[row+1][col+1])) {
+                        myPeakClass|= PM_PEAK_LONE;
+                    } else {
+                        myPeakClass|= PM_PEAK_FLAT;
+                    }
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
                 }
             } else if (col < (image->numCols - 1)) {
                 // This is an interior pixel
-                if ((image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
+                if ((image->data.F32[row][col] > threshold) &&
+                        (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
                         (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
                         (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
@@ -413,33 +442,22 @@
                         (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&
                         (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
-                    if (image->data.F32[row][col] > threshold) {
-                        if ((image->data.F32[row][col] > image->data.F32[row-1][col-1]) &&
-                                (image->data.F32[row][col] > image->data.F32[row-1][col]) &&
-                                (image->data.F32[row][col] > image->data.F32[row-1][col+1]) &&
-                                (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
-                                (image->data.F32[row][col] > image->data.F32[row][col+1]) &&
-                                (image->data.F32[row][col] > image->data.F32[row+1][col-1]) &&
-                                (image->data.F32[row][col] > image->data.F32[row+1][col]) &&
-                                (image->data.F32[row][col] > image->data.F32[row+1][col+1])) {
-                            myType = PM_PEAK_LONE;
-                        }
-
-                        if ((image->data.F32[row][col] == image->data.F32[row-1][col-1]) ||
-                                (image->data.F32[row][col] == image->data.F32[row-1][col]) ||
-                                (image->data.F32[row][col] == image->data.F32[row-1][col+1]) ||
-                                (image->data.F32[row][col] == image->data.F32[row][col-1]) ||
-                                (image->data.F32[row][col] == image->data.F32[row][col+1]) ||
-                                (image->data.F32[row][col] == image->data.F32[row+1][col-1]) ||
-                                (image->data.F32[row][col] == image->data.F32[row+1][col]) ||
-                                (image->data.F32[row][col] == image->data.F32[row+1][col+1])) {
-                            myType = PM_PEAK_FLAT;
-                        }
-
-                        list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType);
+
+                    if ((image->data.F32[row][col] > image->data.F32[row-1][col-1]) &&
+                            (image->data.F32[row][col] > image->data.F32[row-1][col+1]) &&
+                            (image->data.F32[row][col] > image->data.F32[row][col+1]) &&
+                            (image->data.F32[row][col] > image->data.F32[row+1][col-1]) &&
+                            (image->data.F32[row][col] > image->data.F32[row+1][col]) &&
+                            (image->data.F32[row][col] > image->data.F32[row+1][col+1])) {
+                        myPeakClass = PM_PEAK_LONE;
+                    } else {
+                        myPeakClass = PM_PEAK_FLAT;
                     }
+
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
                 }
             } else if (col == (image->numCols - 1)) {
                 // If col==numCols - 1, then we can not read col+1 pixels
-                if ((image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
+                if ((image->data.F32[row][col] > threshold) &&
+                        (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
                         (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
                         (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
@@ -447,11 +465,19 @@
                         (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
                         (image->data.F32[row][col] >= image->data.F32[row+1][col])) {
-                    myType = PM_PEAK_EDGE;
-                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myType);
+
+                    myPeakClass = PM_PEAK_EDGE;
+                    if ((image->data.F32[row][col] > image->data.F32[row-1][col-1]) &&
+                            (image->data.F32[row][col] > image->data.F32[row][col+1]) &&
+                            (image->data.F32[row][col] > image->data.F32[row+1][col-1]) &&
+                            (image->data.F32[row][col] > image->data.F32[row+1][col])) {
+                        myPeakClass|= PM_PEAK_LONE;
+                    } else {
+                        myPeakClass|= PM_PEAK_FLAT;
+                    }
+                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
                 }
             } else {
-                psError(PS_ERR_UNKNOWN, true, "peak specified valid column range.");
+                psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range.");
             }
-
         }
     }
@@ -466,29 +492,52 @@
         col = row1->data.U32[i];
         if (col == 0) {
-            if ( (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
+            if ( (image->data.F32[row][col] > threshold) &&
+                    (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
                     (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
                     (image->data.F32[row][col] >  image->data.F32[row][col+1])) {
-                if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
+
+                myPeakClass = PM_PEAK_EDGE;
+                if (image->data.F32[row][col] > image->data.F32[row-1][col+1]) {
+                    myPeakClass|= PM_PEAK_LONE;
+                } else {
+                    myPeakClass|= PM_PEAK_FLAT;
                 }
+
+                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
             }
         } else if (col < (image->numCols - 1)) {
-            if ( (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
+            if ( (image->data.F32[row][col] > threshold) &&
+                    (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
                     (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
                     (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
                     (image->data.F32[row][col] >  image->data.F32[row][col-1]) &&
                     (image->data.F32[row][col] >= image->data.F32[row][col+1])) {
-                if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
+
+                myPeakClass = PM_PEAK_EDGE;
+                if ( (image->data.F32[row][col] > image->data.F32[row-1][col-1]) &&
+                        (image->data.F32[row][col] > image->data.F32[row-1][col+1]) &&
+                        (image->data.F32[row][col] > image->data.F32[row][col+1])) {
+                    myPeakClass|= PM_PEAK_LONE;
+                } else {
+                    myPeakClass|= PM_PEAK_FLAT;
                 }
+
+                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
             }
 
         } else if (col == (image->numCols - 1)) {
-            if ( (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
+            if ( (image->data.F32[row][col] > threshold) &&
+                    (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
                     (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
                     (image->data.F32[row][col] >  image->data.F32[row][col-1])) {
-                if (image->data.F32[row][col] > threshold) {
-                    list = MyListAddPeak(list, col, row, image->data.F32[row][col], PM_PEAK_EDGE);
+
+                myPeakClass = PM_PEAK_EDGE;
+                if (image->data.F32[row][col] > image->data.F32[row-1][col-1]) {
+                    myPeakClass|= PM_PEAK_LONE;
+                } else {
+                    myPeakClass|= PM_PEAK_FLAT;
                 }
+
+                list = MyListAddPeak(list, col, row, image->data.F32[row][col], myPeakClass);
             }
         } else {
@@ -600,8 +649,8 @@
     psS32 SubImageCenterRow = peak->y;
     psS32 SubImageCenterCol = peak->x;
-    psS32 SubImageStartRow = SubImageCenterRow - outerRadiusS32;
-    psS32 SubImageEndRow = SubImageCenterRow + outerRadiusS32;
-    psS32 SubImageStartCol = SubImageCenterCol - outerRadiusS32;
-    psS32 SubImageEndCol = SubImageCenterCol + outerRadiusS32;
+    psS32 SubImageStartRow = PS_MAX(SubImageCenterRow - outerRadiusS32, 0);
+    psS32 SubImageEndRow =   PS_MIN(SubImageCenterRow + outerRadiusS32, image->numRows - 1);
+    psS32 SubImageStartCol = PS_MAX(SubImageCenterCol - outerRadiusS32, 0);
+    psS32 SubImageEndCol =   PS_MIN(SubImageCenterCol + outerRadiusS32, image->numCols - 1);
     // AnulusWidth == number of pixels width in the annulus.  We add one since
     // the pixels at the inner AND outher radius are included.
Index: /trunk/psModules/test/tst_pmObjects01.c
===================================================================
--- /trunk/psModules/test/tst_pmObjects01.c	(revision 3716)
+++ /trunk/psModules/test/tst_pmObjects01.c	(revision 3717)
@@ -19,6 +19,6 @@
  * abd never deallocate, no error is generated.
  *
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-14 00:16:39 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 22:58:48 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -62,5 +62,6 @@
 int main(int argc, char* argv[])
 {
-    return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv);
+    //    return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv);
+    test02();
 }
 
@@ -73,71 +74,174 @@
     psTraceSetLevel(".", 0);
 
-    psPeak *tmpPeak = pmPeakAlloc(0, 0, 0.0, PM_PEAK_UNDEF);
+    printf("Testing pmPeakAlloc()...\n");
+    psPeak *tmpPeak = pmPeakAlloc(1, 2, 3.0, PM_PEAK_LONE);
     if (tmpPeak == NULL) {
         printf("TEST ERROR: pmPeakAlloc() returned a NULL psPeak\n");
         testStatus = false;
-    }
-    // XXX: Test that values were set properly.
+    } else {
+        if (tmpPeak->x != 1) {
+            printf("TEST ERROR: pmPeakAlloc() improperly set psPeak->x\n");
+            testStatus = false;
+        }
+        if (tmpPeak->y != 2) {
+            printf("TEST ERROR: pmPeakAlloc() improperly set psPeak->y\n");
+            testStatus = false;
+        }
+        if (tmpPeak->counts != 3.0) {
+            printf("TEST ERROR: pmPeakAlloc() improperly set psPeak->counts\n");
+            testStatus = false;
+        }
+        if (tmpPeak->class != PM_PEAK_LONE) {
+            printf("TEST ERROR: pmPeakAlloc() improperly set psPeak->class\n");
+            testStatus = false;
+        }
+    }
     psFree(tmpPeak);
 
+    printf("Testing pmMomentsAlloc()...\n");
     psMoments *tmpMoments = pmMomentsAlloc();
     if (tmpMoments == NULL) {
         printf("TEST ERROR: pmMomentsAlloc() returned a NULL psMoments\n");
         testStatus = false;
+    } else {
+        if ((tmpMoments->x != 0.0) ||
+                (tmpMoments->y != 0.0) ||
+                (tmpMoments->Sx != 0.0) ||
+                (tmpMoments->Sy != 0.0) ||
+                (tmpMoments->Sxy != 0.0) ||
+                (tmpMoments->Sum != 0.0) ||
+                (tmpMoments->Peak != 0.0) ||
+                (tmpMoments->Sky != 0.0) ||
+                (tmpMoments->nPixels != 0)) {
+            printf("TEST ERROR: pmMomentsAlloc() did not properly initialize the psMoments structure.\n");
+            testStatus = false;
+        }
     }
     psFree(tmpMoments);
 
-    // XXX: Must test this with variety of models, and verify param length.
+    printf("Testing pmModelAlloc(PS_MODEL_GAUSS)...\n");
     psModel *tmpModel = pmModelAlloc(PS_MODEL_GAUSS);
     if (tmpModel == NULL) {
-        printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n");
-        testStatus = false;
-    }
-    // XXX: Test that values were set properly.
+        printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) returned a NULL psModel\n");
+        testStatus = false;
+    } else {
+        if (tmpModel->Nparams != 7) {
+            printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams);
+            testStatus = false;
+        } else {
+            for (psS32 i = 0 ; i < 7 ; i++) {
+                if ((tmpModel->params[i] != 0.0) ||
+                        (tmpModel->dparams[i] != 0.0)) {
+                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) did not ininitialize the params/dparams array to 0.0.\n");
+                    testStatus = false;
+                }
+            }
+        }
+    }
     psFree(tmpModel);
 
-    // XXX: Must test this with variety of models, and verify param length.
+    printf("Testing pmModelAlloc(PS_MODEL_PGAUSS)...\n");
     tmpModel = pmModelAlloc(PS_MODEL_PGAUSS);
     if (tmpModel == NULL) {
-        printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n");
-        testStatus = false;
-    }
-    // XXX: Test that values were set properly.
+        printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) returned a NULL psModel\n");
+        testStatus = false;
+    } else {
+        if (tmpModel->Nparams != 7) {
+            printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams);
+            testStatus = false;
+        } else {
+            for (psS32 i = 0 ; i < 7 ; i++) {
+                if ((tmpModel->params[i] != 0.0) ||
+                        (tmpModel->dparams[i] != 0.0)) {
+                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) did not ininitialize the params/dparams array to 0.0.\n");
+                    testStatus = false;
+                }
+            }
+        }
+    }
     psFree(tmpModel);
 
-    // XXX: Must test this with variety of models, and verify param length.
+    printf("Testing pmModelAlloc(PS_MODEL_TWIST_GAUSS)...\n");
     tmpModel = pmModelAlloc(PS_MODEL_TWIST_GAUSS);
     if (tmpModel == NULL) {
-        printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n");
-        testStatus = false;
-    }
-    // XXX: Test that values were set properly.
+        printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) returned a NULL psModel\n");
+        testStatus = false;
+    } else {
+        if (tmpModel->Nparams != 11) {
+            printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams);
+            testStatus = false;
+        } else {
+            for (psS32 i = 0 ; i < 11 ; i++) {
+                if ((tmpModel->params[i] != 0.0) ||
+                        (tmpModel->dparams[i] != 0.0)) {
+                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) did not ininitialize the params/dparams array to 0.0.\n");
+                    testStatus = false;
+                }
+            }
+        }
+    }
     psFree(tmpModel);
 
-    // XXX: Must test this with variety of models, and verify param length.
+    printf("Testing pmModelAlloc(PS_MODEL_WAUSS)...\n");
     tmpModel = pmModelAlloc(PS_MODEL_WAUSS);
     if (tmpModel == NULL) {
-        printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n");
-        testStatus = false;
-    }
-    // XXX: Test that values were set properly.
+        printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) returned a NULL psModel\n");
+        testStatus = false;
+    } else {
+        if (tmpModel->Nparams != 9) {
+            printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) allocated an incorrect number of params (%d)\n", tmpModel->Nparams);
+            testStatus = false;
+        } else {
+            for (psS32 i = 0 ; i < 9 ; i++) {
+                if ((tmpModel->params[i] != 0.0) ||
+                        (tmpModel->dparams[i] != 0.0)) {
+                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) did not ininitialize the params/dparams array to 0.0.\n");
+                    testStatus = false;
+                }
+            }
+        }
+    }
     psFree(tmpModel);
 
-    // XXX: Must test this with variety of models, and verify param length.
+    printf("Testing pmModelAlloc(PS_MODEL_SERSIC)...\n");
     tmpModel = pmModelAlloc(PS_MODEL_SERSIC);
     if (tmpModel == NULL) {
-        printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n");
-        testStatus = false;
-    }
-    // XXX: Test that values were set properly.
+        printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) returned a NULL psModel\n");
+        testStatus = false;
+    } else {
+        if (tmpModel->Nparams != 8) {
+            printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) allocated an incorrect number of params (%d)\n", tmpModel->Nparams);
+            testStatus = false;
+        } else {
+            for (psS32 i = 0 ; i < 8 ; i++) {
+                if ((tmpModel->params[i] != 0.0) ||
+                        (tmpModel->dparams[i] != 0.0)) {
+                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) did not ininitialize the params/dparams array to 0.0.\n");
+                    testStatus = false;
+                }
+            }
+        }
+    }
     psFree(tmpModel);
 
-    // XXX: Must test this with variety of models, and verify param length.
+    printf("Testing pmModelAlloc(PS_MODEL_SERSIC_CORE)...\n");
     tmpModel = pmModelAlloc(PS_MODEL_SERSIC_CORE);
     if (tmpModel == NULL) {
-        printf("TEST ERROR: pmModelAlloc() returned a NULL psModel\n");
-        testStatus = false;
-    }
-    // XXX: Test that values were set properly.
+        printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) returned a NULL psModel\n");
+        testStatus = false;
+    } else {
+        if (tmpModel->Nparams != 12) {
+            printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) allocated an incorrect number of params (%d)\n", tmpModel->Nparams);
+            testStatus = false;
+        } else {
+            for (psS32 i = 0 ; i < 12 ; i++) {
+                if ((tmpModel->params[i] != 0.0) ||
+                        (tmpModel->dparams[i] != 0.0)) {
+                    printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) did not ininitialize the params/dparams array to 0.0.\n");
+                    testStatus = false;
+                }
+            }
+        }
+    }
     psFree(tmpModel);
 
@@ -152,5 +256,9 @@
 }
 
-#define VECTOR_SIZE 10
+/******************************************************************************
+test01(): we first test pmFindVectorPeaks() with a variety of bad input
+parameters.  Then we test it with a simple vector both 1- and multi-elements.
+ *****************************************************************************/
+#define TST01_VECTOR_LENGTH 10
 bool test_pmFindVectorPeaks(int n)
 {
@@ -174,5 +282,4 @@
         testStatus = false;
     } else {
-
         if (outData->n != 1) {
             printf("TEST ERROR: outData->n is %d\n", outData->n);
@@ -315,9 +422,7 @@
     }
 
-
     psFree(inData);
     return(testStatus);
 }
-
 
 int test01( void )
@@ -325,5 +430,5 @@
     bool testStatus = true;
     psVector *tmpVec = NULL;
-    psVector *tmpVecF64 = psVectorAlloc(10, PS_TYPE_F64);
+    psVector *tmpVecF64 = psVectorAlloc(TST01_VECTOR_LENGTH, PS_TYPE_F64);
     psVector *tmpVecEmpty = psVectorAlloc(0, PS_TYPE_F32);
 
@@ -357,5 +462,5 @@
     }
     testStatus&= test_pmFindVectorPeaks(1);
-    testStatus&= test_pmFindVectorPeaks(VECTOR_SIZE);
+    testStatus&= test_pmFindVectorPeaks(TST01_VECTOR_LENGTH);
 
     psFree(tmpVecF64);
@@ -364,9 +469,18 @@
 }
 
-// XXX: Add tests for the PEAK_TYPE.
-// XXX: Add interior peaks, edge peaks, and flat peaks.
+/******************************************************************************
+test02(): 
+// XXX: Must test flat peaks.
+// XXX: test 1-by-n and n-by-1 images.
+ *****************************************************************************/
+#define TST02_NUM_ROWS 5
+#define TST02_NUM_COLS 5
 bool test_pmFindImagePeaks(int numRows, int numCols)
 {
     printf("-------------- Calling test_pmFindVectorPeaks on an %d-by-%d image. --------------\n", numRows, numCols);
+    if ((numRows < 4) || (numCols < 4)) {
+        printf("WARNING: Don't call this test with a smaller than 4-by-4 image.\n");
+        return(true);
+    }
     bool testStatus = true;
     psImage *inData = psImageAlloc(numCols, numRows, PS_TYPE_F32);
@@ -374,5 +488,5 @@
 
     //
-    // Test first pixel peak.
+    // Initialize test image.
     //
     for (psS32 i = 0 ; i < numRows ; i++) {
@@ -381,8 +495,16 @@
         }
     }
+    //
+    // Set corner and center pixels as peaks.
+    //
     inData->data.F32[0][0] = PS_SQR(numRows) + PS_SQR(numCols);
     inData->data.F32[0][numCols-1] = PS_SQR(numRows) + PS_SQR(numCols);
     inData->data.F32[numRows-1][0] = PS_SQR(numRows) + PS_SQR(numCols);
     inData->data.F32[numRows-1][numCols-1] = PS_SQR(numRows) + PS_SQR(numCols);
+    inData->data.F32[numRows/2][numCols/2] = PS_SQR(numRows) + PS_SQR(numCols);
+
+    //
+    // Print image.
+    //
     for (psS32 i = 0 ; i < numRows ; i++) {
         for (psS32 j = 0 ; j < numCols ; j++) {
@@ -392,4 +514,7 @@
     }
 
+    //
+    // Call pmFindImagePeaks() with a threshold of 0.0.
+    //
     outData = pmFindImagePeaks(inData, 0.0);
 
@@ -398,6 +523,6 @@
         testStatus = false;
     } else {
-        if (outData->size != 4) {
-            printf("TEST ERROR: pmFindImagePeaks found only %d peaks (should be 4)\n", outData->size);
+        if (outData->size != 5) {
+            printf("TEST ERROR: pmFindImagePeaks found %d peaks (should be 4)\n", outData->size);
             testStatus = false;
         }
@@ -406,10 +531,23 @@
         while (tmpPeakLE != NULL) {
             psPeak *tmpPeak = (psPeak *) tmpPeakLE->data;
-            if (((tmpPeak->x == 0) || (tmpPeak->x == numRows-1)) &&
-                ((tmpPeak->y == 0) || (tmpPeak->y == numCols-1))) {}
-            else {
-                printf("TEST ERROR: Peak at (%d, %d) (%f)\n", tmpPeak->x, tmpPeak->y, tmpPeak->counts);
+            if (((tmpPeak->x == 0) && (tmpPeak->y == 0)) ||
+                    ((tmpPeak->x == 0) && (tmpPeak->y == numRows-1)) ||
+                    ((tmpPeak->x == numCols-1) && (tmpPeak->y == 0)) ||
+                    ((tmpPeak->x == numCols-1) && (tmpPeak->y == numRows-1))) {
+                if (!(tmpPeak->class & PM_PEAK_LONE) ||
+                        !(tmpPeak->class & PM_PEAK_EDGE)) {
+                    printf("TEST ERROR: peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class);
+                    testStatus = false;
+                }
+            } else if ((tmpPeak->x == numCols/2) && (tmpPeak->y == numRows/2)) {
+                if (!(tmpPeak->class & PM_PEAK_LONE)) {
+                    printf("TEST ERROR: peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class);
+                    testStatus = false;
+                }
+            } else {
+                printf("TEST ERROR: Peak at (%d, %d) (%f)\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts);
                 testStatus = false;
             }
+
             tmpPeakLE = tmpPeakLE->next;
         }
@@ -421,10 +559,9 @@
 }
 
-
 int test02( void )
 {
     bool testStatus = true;
     psList *tmpList = NULL;
-    psImage *tmpImageF64 = psImageAlloc(10, 10, PS_TYPE_F64);
+    psImage *tmpImageF64 = psImageAlloc(TST02_NUM_ROWS, TST02_NUM_COLS, PS_TYPE_F64);
     psImage *tmpImageEmpty = psImageAlloc(0, 0, PS_TYPE_F32);
 
@@ -461,5 +598,8 @@
     //    testStatus&= test_pmFindImagePeaks(2, 5);
     //    testStatus&= test_pmFindImagePeaks(5, 2);
-    testStatus&= test_pmFindImagePeaks(10, 10);
+    // HEY
+    testStatus&= test_pmFindImagePeaks(TST02_NUM_ROWS,   TST02_NUM_COLS);
+    testStatus&= test_pmFindImagePeaks(2*TST02_NUM_ROWS, TST02_NUM_COLS);
+    testStatus&= test_pmFindImagePeaks(TST02_NUM_ROWS,   2*TST02_NUM_COLS);
 
 
