Index: /trunk/psLib/test/image/tst_psImage.c
===================================================================
--- /trunk/psLib/test/image/tst_psImage.c	(revision 980)
+++ /trunk/psLib/test/image/tst_psImage.c	(revision 981)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 03:16:13 $
+ *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-10 18:48:35 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -804,5 +804,5 @@
     specified operation. Valid operations include =, +, -, *, /.
 
-    Verify the returned integer is equal to the number of pixels modified
+    Verify the returned integer is zero
     and the input parameter psImage structure is modified at the specified
     location and range with the given overlay image and the specified
@@ -811,17 +811,4 @@
     different platforms.
 
-    Verify the returned integer is equal to zero and the input psImage structure
-    is unmodified, if the overlay specified is not within the data range of the
-    input psImage structure.
-
-    Verify the returned integer is equal to zero, the input psImage
-    structure is unmodified and program execution doesn't stop, if the
-    overlay specified is null.
-
-    Verify the returned integer is equal to zero and program execution
-    doesn't stop, if the input parameter image is null.
-
-    Verify program execution doen't stop, if the overly image contains
-    zero values with division operation is specified.
     */
 
@@ -850,4 +837,5 @@
     for (unsigned row=0;row<r;row++) { \
         ps##DATATYPE* imgRow = img->data.DATATYPE[row]; \
+        ps##DATATYPE* img2Row = img2->data.DATATYPE[row]; \
         for (unsigned col=0;col<c;col++) { \
             ps##DATATYPE val = 6.0; \
@@ -860,4 +848,9 @@
                 return 2; \
             } \
+            if (row < r/2 && col < c/2 && fabsf(img2Row[col] - 2.0) > FLT_EPSILON) { \
+                psError(__func__,"Overlay modified at %d,%d (%.2f for %s)", \
+                        col,row,img2Row[col],OPSTRING); \
+                return 2; \
+            } \
         } \
     } \
@@ -881,4 +874,98 @@
     testOverlayType(U8);
 
+    /*
+    Verify the returned integer is equal to non-zero and the input psImage structure
+    is unmodified, if the overlay specified is not within the data range of the
+    input psImage structure.
+    */
+
+    img = psImageAlloc(c,r,PS_TYPE_F32);
+    for (unsigned row=0;row<r;row++) {
+        psF32* imgRow = img->data.F32[row];
+        for (unsigned col=0;col<c;col++) {
+            imgRow[col] = 6.0f;
+        }
+    }
+    img2 = psImageAlloc(c,r,PS_TYPE_F32);
+    for (unsigned row=0;row<r;row++) {
+        psF32* img2Row = img2->data.F32[row];
+        for (unsigned col=0;col<c;col++) {
+            img2Row[col] = 2.0f;
+        }
+    }
+
+    psLogMsg(__func__,PS_LOG_INFO,"Following should error as overlay isn't within image boundaries");
+    retVal = psImageOverlaySection(img,img2,c/4,r/4,"+");
+    if (retVal == 0) {
+        psError(__func__,"psImageOverlaySection returned zero even though "
+                "overlay too big");
+        return 3;
+    }
+    for (unsigned row=0;row<r;row++) {
+        psF32* imgRow = img->data.F32[row];
+        for (unsigned col=0;col<c;col++) {
+            if (imgRow[col] != 6.0f) {
+                psError(__func__,"Input image modified when overlay size too big");
+                return 4;
+            }
+        }
+    }
+
+    /*
+    Verify the returned integer is equal to non-zero, the input psImage
+    structure is unmodified and program execution doesn't stop, if the
+    overlay specified is null.
+    */
+
+    psLogMsg(__func__,PS_LOG_INFO,"Following should error as overlay is NULL");
+    retVal = psImageOverlaySection(img,NULL,c/4,r/4,"+");
+    if (retVal == 0) {
+        psError(__func__,"psImageOverlaySection returned zero even though "
+                "overlay too big");
+        return 5;
+    }
+    for (unsigned row=0;row<r;row++) {
+        psF32* imgRow = img->data.F32[row];
+        for (unsigned col=0;col<c;col++) {
+            if (imgRow[col] != 6.0f) {
+                psError(__func__,"Input image modified when overlay NULL");
+                return 6;
+            }
+        }
+    }
+
+    /*
+    Verify the returned integer is equal to non-zero and program execution
+    doesn't stop, if the input parameter image is null.
+    */
+
+    psLogMsg(__func__,PS_LOG_INFO,"Following should error as image input is NULL");
+    retVal = psImageOverlaySection(NULL,img2,c/4,r/4,"+");
+    if (retVal == 0) {
+        psError(__func__,"psImageOverlaySection returned zero even though "
+                "overlay too big");
+        return 7;
+    }
+
+    /*
+    Verify program execution doen't stop, if the overly image contains
+    zero values with division operation is specified.
+    */
+    for (unsigned row=0;row<r;row++) {
+        psF32* img2Row = img2->data.F32[row];
+        for (unsigned col=0;col<c;col++) {
+            img2Row[col] = 0.0f;
+        }
+    }
+    retVal = psImageOverlaySection(img,img2,0,0,"/");
+    if (retVal != 0) {
+        psError(__func__,"psImageOverlaySection returned non-zero when "
+                "checking divide-by-zero.");
+        return 8;
+    }
+
+    psImageFree(img);
+    psImageFree(img2);
+
     return 0;
 }
