Index: /trunk/psLib/test/image/tst_psImage.c
===================================================================
--- /trunk/psLib/test/image/tst_psImage.c	(revision 938)
+++ /trunk/psLib/test/image/tst_psImage.c	(revision 939)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-08 23:57:00 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-09 00:28:09 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +25,5 @@
 static int testImageCopy(void);
 static int testImageClip(void);
+static int testImageClipNAN(void);
 
 testDescription tests[] = {
@@ -31,4 +32,5 @@
                               {testImageCopy,"551-testImageCopy",0},
                               {testImageClip,"571-testImageClip",0},
+                              {testImageClipNAN,"572-testImageClipNAN",0},
                               {NULL}
                           };
@@ -733,2 +735,88 @@
     return 0;
 }
+
+int testImageClipNAN(void)
+{
+    psImage* img = NULL;
+    unsigned int c = 128;
+    unsigned int r = 256;
+    int currentId = psMemGetId();
+    int numClipped = 0;
+    int retVal;
+
+    psLogMsg(__func__,PS_LOG_INFO,
+             "psImageClipNaN shall modified pixel values of NaN with a specified value");
+
+    /*
+        psImageClipNaN shall modify a psImage structure with pixel values set
+        to NaN to a value specified as an input parameter.
+
+        Verify the returned integer is equal to the number of pixels modified
+        and the psImage is modified at locations where NaN pixels where
+        located to the value specified in the input parameter value.
+
+        Verify the returned integer is zero and program execution doesn't stop,
+        if the input parameter psImage structure pointer is null.
+    */
+
+    // create image
+    #define testImageClipNaNByType(datatype) \
+    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++) { \
+            if (row == col) { \
+                imgRow[col] = NAN; \
+            } else if (row+1 == col) { \
+                imgRow[col] = INFINITY; \
+            } else { \
+                imgRow[col] = (ps##datatype)(row+col); \
+            } \
+        } \
+    } \
+    \
+    retVal = psImageClipNaN(img,-1.0f); \
+    \
+    numClipped = 0; \
+    for (unsigned row=0;row<r;row++) { \
+        ps##datatype* imgRow = img->data.datatype[row]; \
+        for (unsigned col=0;col<c;col++) { \
+            ps##datatype value = (ps##datatype)(row+col); \
+            if ( (row == col) || (row+1 == col) ) { \
+                numClipped++; \
+                value = -1.0; \
+            } \
+            if (fabsf(imgRow[col]-value) > FLT_EPSILON) { \
+                psError(__func__,"Pixel value is not as expected (%f vs %f) at %d,%d", \
+                        imgRow[col],value,col,row); \
+                return 1; \
+            } \
+        } \
+    } \
+    if (retVal != numClipped) { \
+        psError(__func__,"Expected %d clips, but got %d", \
+                numClipped,retVal); \
+        return 2; \
+    } \
+    psImageFree(img);
+
+    testImageClipNaNByType(F32);
+    testImageClipNaNByType(F64);
+
+    // Verify the retuned integer is zero, psImage structure input is unmodified
+    // and program executions doesn't stop, if input parameter psImage structure
+    // pointer is null.
+    retVal = psImageClipNaN(NULL,-1.0f);
+    if (retVal != 0) {
+        psError(__func__,"Expected zero return for clips of a NULL image.");
+        return 3;
+    }
+
+
+    if (psMemCheckLeaks(currentId,NULL,NULL) != 0) {
+        psAbort(__func__,"Memory Leaks!");
+    }
+    psMemCheckCorruption(1);
+
+    return 0;
+}
