Index: /trunk/psLib/test/image/tst_psImage.c
===================================================================
--- /trunk/psLib/test/image/tst_psImage.c	(revision 855)
+++ /trunk/psLib/test/image/tst_psImage.c	(revision 856)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-04 00:19:54 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-04 03:12:11 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -15,4 +15,5 @@
 #include <float.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include "psTest.h"
@@ -34,6 +35,4 @@
 {
     psSetLogLevel(PS_LOG_INFO);
-
-    testImageSubset();
 
     if (! runTestSuite(stderr,"psImage",tests)) {
@@ -549,20 +548,54 @@
     // Verify the returned psImage structure member are equal to the values in
     // the input psImage structure input.
-    for (unsigned row=0;row<r;row++) {
-        psF32* imgRow = img->data.F32[row];
-        psF32* img2Row = img2->data.F32[row];
-        for (unsigned col=0;col<c;col++) {
-            if (imgRow[col] - (row+col) > FLT_EPSILON) {
-                psError(__func__,"Input image was changed at %d,%d (%f)!",
-                        col,row,imgRow[col]);
-                return 2;
-            }
-
-            if (imgRow[col] != img2Row[col]) {
-                psError(__func__,"returned psImage values after copy don't match!");
-                return 2;
-            }
-        }
-    }
+
+    #define testImageCopyType(IN,OUT) \
+    img = psImageRecycle(img,c,r,PS_TYPE_##IN); \
+    for (unsigned row=0;row<r;row++) { \
+        ps##IN* imgRow = img->data.IN[row]; \
+        for (unsigned col=0;col<c;col++) { \
+            imgRow[col] = (ps##IN)(row+col); \
+        } \
+    } \
+    img2 = psImageCopy(img2,img,PS_TYPE_##OUT); \
+    if (img2 == NULL) { \
+        psError(__func__,"psImageCopy failed to copy U8."); \
+        return 2; \
+    } \
+    for (unsigned int row=0;row<r;row++) { \
+        ps##IN* imgRow = img->data.IN[row]; \
+        ps##OUT* img2Row = img2->data.OUT[row]; \
+        for (unsigned int col=0;col<c;col++) { \
+            if (abs(imgRow[col] - (ps##IN)(row+col)) > 0.5) { \
+                psError(__func__,"Input image was changed at %d,%d!", \
+                        col,row); \
+                return 2; \
+            } \
+            if (abs(img2Row[col] - (ps##OUT)(imgRow[col])) > 0.5) { \
+                psError(__func__,"returned psImage values after copy don't match at %d,%d " \
+                        "(%d vs %d)",\
+                        col,row,img2Row[col], (ps##OUT)(imgRow[col])); \
+                return 2; \
+            } \
+        } \
+    }
+
+    #define testImageCopyTypes(IN) \
+    testImageCopyType(IN,U8); \
+    testImageCopyType(IN,U16); \
+    testImageCopyType(IN,U32); \
+    testImageCopyType(IN,S8);\
+    testImageCopyType(IN,S16);\
+    testImageCopyType(IN,S32);\
+    testImageCopyType(IN,F32);\
+    testImageCopyType(IN,F64);
+
+    testImageCopyTypes(U8);
+    testImageCopyTypes(U16);
+    testImageCopyTypes(U32);
+    testImageCopyTypes(S8);
+    testImageCopyTypes(S16);
+    testImageCopyTypes(S32);
+    testImageCopyTypes(F32);
+    testImageCopyTypes(F64);
 
     // Verify the returned psImage structure pointer is null and program
@@ -575,32 +608,4 @@
     }
 
-    img2 = psImageCopy(img2,img,PS_TYPE_U8);
-    for (unsigned row=0;row<r;row++) {
-        psF32* imgRow = img->data.F32[row];
-        psU8* img2Row = img2->data.U8[row];
-        for (unsigned col=0;col<c;col++) {
-            if (imgRow[col] - (row+col) > FLT_EPSILON) {
-                psError(__func__,"Input image was changed at %d,%d (%f)!",
-                        col,row,imgRow[col]);
-                return 2;
-            }
-
-            if (row+col != img2Row[col]) {
-                psError(__func__,"returned psImage values after copy don't match at %d,%d (%d vs %d)",
-                        col,row,img2Row[col], row+col);
-                return 2;
-            }
-        }
-    }
-
-    img2 = psImageCopy(img2,img,PS_TYPE_U16);
-    img2 = psImageCopy(img2,img,PS_TYPE_U32);
-    img2 = psImageCopy(img2,img,PS_TYPE_S8);
-    img2 = psImageCopy(img2,img,PS_TYPE_S16);
-    img2 = psImageCopy(img2,img,PS_TYPE_S32);
-    img2 = psImageCopy(img2,img,PS_TYPE_F64);
-    img2 = psImageCopy(img2,img,PS_TYPE_C32);
-    img2 = psImageCopy(img2,img,PS_TYPE_C64);
-
     psImageFree(img);
     psImageFree(img2);
