Index: trunk/psLib/test/imageops/tap_psImagePixelManip.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImagePixelManip.c	(revision 13123)
+++ trunk/psLib/test/imageops/tap_psImagePixelManip.c	(revision 13614)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-05-02 04:14:33 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-04 20:25:32 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -18,9 +18,49 @@
 #define VERBOSE false
 
+void genericImageClipTest(int numRows, int numCols) {
+    psMemId id = psMemGetId();
+
+    psImage *image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
+    for (int row = 0 ; row < numRows ; row++) {
+        for (int col = 0 ; col < numCols ; col++) {
+            image->data.F32[row][col] = (float) (row + col);
+        }
+    }
+    psF32 min = (psF64)numRows/2.0;
+    psF32 max = (psF64)numRows;
+
+    psS32 retVal = psImageClip(image, min, (double)PS_MIN_F32, max, (double)PS_MAX_F32);
+    int numClipped = 0;
+    bool errorFlag = false;
+    for (int row=0;row<numRows;row++) {
+        for (int col=0;col<numCols;col++) {
+            psF32 value = (psF32)(row+col);
+            if (value < min) {
+                numClipped++;
+                value = PS_MIN_F32;
+            } else if (value > max) {
+                numClipped++;
+                value = PS_MAX_F32;
+            }
+            if (fabsf(image->data.F32[row][col]-value) > FLT_EPSILON) {
+                diag("Pixel value is not as expected (%g vs %g) at %u,%u",
+                     (psF64)image->data.F32[row][col], (psF64)value, col, row);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageClip() produced the correct data values");
+    ok(retVal == numClipped, "Got the expected number of clips");
+    psFree(image);
+
+    ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+}
+
+
 psS32 main(psS32 argc, char* argv[])
 {
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(107);
+    plan_tests(122);
 
     // test psImageClip()
@@ -49,4 +89,11 @@
         // and program executions doesn't stop, if input parameter min is larger than max.
         // create image
+
+        genericImageClipTest(8, 1);
+        genericImageClipTest(1, 8);
+        genericImageClipTest(8, 8);
+        genericImageClipTest(8, 16);
+        genericImageClipTest(16, 8);
+
         #define testImageClipByType(datatype) \
         { \
