Index: trunk/psLib/test/image/tst_psImage.c
===================================================================
--- trunk/psLib/test/image/tst_psImage.c	(revision 953)
+++ trunk/psLib/test/image/tst_psImage.c	(revision 980)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-09 21:20:53 $
+ *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-10 03:16:13 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -26,4 +26,5 @@
 static int testImageClip(void);
 static int testImageClipNAN(void);
+static int testImageOverlay(void);
 
 testDescription tests[] = {
@@ -33,4 +34,5 @@
                               {testImageClip,"571-testImageClip",0},
                               {testImageClipNAN,"572-testImageClipNAN",0},
+                              {testImageOverlay,"573-testImageOverlay",0},
                               {NULL}
                           };
@@ -38,6 +40,6 @@
 int main()
 {
-    psSetLogLevel(PS_LOG_INFO);
-
+    psLogSetLevel(PS_LOG_INFO);
+    testImageOverlay();
     if (! runTestSuite(stderr,"psImage",tests)) {
         psAbort(__FILE__,"One or more tests failed");
@@ -787,2 +789,96 @@
     return 0;
 }
+
+int testImageOverlay(void)
+{
+
+    psImage* img = NULL;
+    psImage* img2 = NULL;
+    unsigned int c = 128;
+    unsigned int r = 256;
+    int retVal;
+
+    /*
+    psImageSectionOverlay shall modified pixel values in a psImage structure to
+    be equal to the value of the originaldata and an overlay image with a
+    specified operation. Valid operations include =, +, -, *, /.
+
+    Verify the returned integer is equal to the number of pixels modified
+    and the input parameter psImage structure is modified at the specified
+    location and range with the given overlay image and the specified
+    function. Cases should include all the valid operations. Comparison of
+    expected values should include a delta to allow for testing on
+    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.
+    */
+
+
+
+    #define testOverlayTypeOP(DATATYPE,OP,OPSTRING) \
+    img = psImageAlloc(c,r,PS_TYPE_##DATATYPE); \
+    for (unsigned row=0;row<r;row++) { \
+        ps##DATATYPE* imgRow = img->data.DATATYPE[row]; \
+        for (unsigned col=0;col<c;col++) { \
+            imgRow[col] = 6.0; \
+        } \
+    } \
+    img2 = psImageAlloc(c/2,r/2,PS_TYPE_##DATATYPE); \
+    for (unsigned row=0;row<r/2;row++) { \
+        ps##DATATYPE* img2Row = img2->data.DATATYPE[row]; \
+        for (unsigned col=0;col<c/2;col++) { \
+            img2Row[col] = 2.0; \
+        } \
+    } \
+    retVal = psImageOverlaySection(img,img2,c/4,r/4,OPSTRING); \
+    if (retVal != 0) { \
+        psError(__func__,"psImageOverlaySection returned non-zero %s op",OPSTRING); \
+        return 1; \
+    } \
+    for (unsigned row=0;row<r;row++) { \
+        ps##DATATYPE* imgRow = img->data.DATATYPE[row]; \
+        for (unsigned col=0;col<c;col++) { \
+            ps##DATATYPE val = 6.0; \
+            if ( ! (row < r/4 || row >= r/2+r/4 || col < c/4 || col >= c/2+c/4)) { \
+                val OP 2.0; \
+            } \
+            if (fabsf(imgRow[col] - val) > FLT_EPSILON) { \
+                psError(__func__,"Value incorrect at %d,%d (%.2f vs %.2f for %s)", \
+                        col,row,imgRow[col],val,OPSTRING); \
+                return 2; \
+            } \
+        } \
+    } \
+    psImageFree(img); \
+    psImageFree(img2);
+
+    #define testOverlayType(DATATYPE) \
+    testOverlayTypeOP(DATATYPE,+=,"+"); \
+    testOverlayTypeOP(DATATYPE,-=,"-"); \
+    testOverlayTypeOP(DATATYPE,*=,"*");\
+    testOverlayTypeOP(DATATYPE,/=,"/");\
+    testOverlayTypeOP(DATATYPE,=,"=");
+
+    testOverlayType(C64);
+    testOverlayType(C32);
+    testOverlayType(F64);
+    testOverlayType(F32);
+    testOverlayType(S16);
+    testOverlayType(S8);
+    testOverlayType(U16);
+    testOverlayType(U8);
+
+    return 0;
+}
