Index: /trunk/psLib/test/image/tst_psImageManip.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageManip.c	(revision 1921)
+++ /trunk/psLib/test/image/tst_psImageManip.c	(revision 1922)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-28 01:24:46 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-29 00:28:21 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -873,91 +873,102 @@
     */
 
-    in = psImageAlloc(16,16,PS_TYPE_F32);
-    meanTruth = psImageAlloc(4,4,PS_TYPE_F32);
-    maxTruth = psImageAlloc(6,6,PS_TYPE_F32);
-    memset(meanTruth->data.F32[0],0,sizeof(psF32)*4*4);
-    memset(maxTruth->data.F32[0],0,sizeof(psF32)*6*6);
-
-    for (int row = 0; row<16; row++) {
-        psF32* inRow = in->data.F32[row];
-        psF32* meanTruthRow = meanTruth->data.F32[row/4];
-        psF32* maxTruthRow = maxTruth->data.F32[row/3];
-        for (int col = 0; col<16; col++) {
-            inRow[col] = row + col;
-            meanTruthRow[col/4] += row + col;
-            if (maxTruthRow[col/3] < row + col) {
-                maxTruthRow[col/3] = row+col;
-            }
-        }
-    }
-    for (int row = 0; row<4; row++) {
-        psF32* meanTruthRow = meanTruth->data.F32[row];
-        for (int col = 0; col<4; col++) {
-            meanTruthRow[col] /= 16;
-        }
-    }
-
+    #define testRebinType(DATATYPE)  \
+    in = psImageAlloc(16,16,PS_TYPE_##DATATYPE); \
+    meanTruth = psImageAlloc(4,4,PS_TYPE_F32); \
+    maxTruth = psImageAlloc(6,6,PS_TYPE_F32); \
+    memset(meanTruth->data.F32[0],0,sizeof(psF32)*4*4); \
+    memset(maxTruth->data.F32[0],0,sizeof(psF32)*6*6); \
+    for (int row = 0; row<16; row++) { \
+        ps##DATATYPE* inRow = in->data.DATATYPE[row]; \
+        psF32* meanTruthRow = meanTruth->data.F32[row/4]; \
+        psF32* maxTruthRow = maxTruth->data.F32[row/3]; \
+        for (int col = 0; col<16; col++) { \
+            inRow[col] = row + col; \
+            meanTruthRow[col/4] += row + col; \
+            if (maxTruthRow[col/3] < row + col) { \
+                maxTruthRow[col/3] = row+col; \
+            } \
+        } \
+    } \
+    for (int row = 0; row<4; row++) { \
+        psF32* meanTruthRow = meanTruth->data.F32[row]; \
+        for (int col = 0; col<4; col++) { \
+            meanTruthRow[col] /= 16; \
+        } \
+    } \
+    stats.options = PS_STAT_SAMPLE_MEAN; \
+    out = psImageRebin(NULL,in,NULL,0,4,&stats); \
+    if (out == NULL) { \
+        psError(__func__,"psImageRebin returned a NULL pointer!?"); \
+        return 1; \
+    } \
+    if (out->numRows != 4 || out->numCols != 4) { \
+        psError(__func__,"psImageRebin didn't produce the proper size image " \
+                "(%d x %d).", \
+                out->numCols, out->numRows); \
+        return 2; \
+    } \
+    for (int row = 0; row<4; row++) { \
+        ps##DATATYPE* outRow = out->data.DATATYPE[row]; \
+        psF32* truthRow = meanTruth->data.F32[row]; \
+        for (int col = 0; col<4; col++) { \
+            if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \
+                psError(__func__,"psImageRebin didn't produce the proper mean " \
+                        "result at (%d,%d) [%f vs %f].", \
+                        col,row,outRow[col],truthRow[col]); \
+                return 3; \
+            } \
+        } \
+    } \
+    stats.options = PS_STAT_MAX; \
+    out2 = psImageRebin(out,in,NULL,0,3,&stats); \
+    if (out != out2) { \
+        psError(__func__,"psImageRebin didn't recycle a psImage properly!?"); \
+        return 7; \
+    } \
+    if (out == NULL) { \
+        psError(__func__,"psImageRebin returned a NULL pointer!?"); \
+        return 4; \
+    } \
+    if (out->numRows != 6 || out->numCols != 6) { \
+        psError(__func__,"psImageRebin didn't produce the proper size image " \
+                "(%d x %d).", \
+                out->numCols, out->numRows); \
+        return 5; \
+    } \
+    for (int row = 0; row<6; row++) { \
+        ps##DATATYPE* outRow = out->data.DATATYPE[row]; \
+        psF32* truthRow = maxTruth->data.F32[row]; \
+        for (int col = 0; col<6; col++) { \
+            if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \
+                psError(__func__,"psImageRebin didn't produce the proper " \
+                        "max result at (%d,%d) [%f vs %f].", \
+                        col,row,outRow[col],truthRow[col]); \
+                return 6; \
+            } \
+        } \
+    } \
+    psFree(in); \
+    psFree(out); \
+    psFree(meanTruth); \
+    psFree(maxTruth);
+
+    testRebinType(F32);
+    testRebinType(F64);
+    testRebinType(U16);
+    testRebinType(S8);
+
+    // Verify the returned psImage structure is null and program execution
+    // doesn't stop, if the input image type is not supported.
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
+    in = psImageAlloc(16,16,PS_TYPE_U8);
     stats.options = PS_STAT_SAMPLE_MEAN;
     out = psImageRebin(NULL,in,NULL,0,4,&stats);
-
-    if (out == NULL) {
-        psError(__func__,"psImageRebin returned a NULL pointer!?");
-        return 1;
-    }
-
-    if (out->numRows != 4 || out->numCols != 4) {
-        psError(__func__,"psImageRebin didn't produce the proper size image "
-                "(%d x %d).",
-                out->numCols, out->numRows);
-        return 2;
-    }
-
-    for (int row = 0; row<4; row++) {
-        psF32* outRow = out->data.F32[row];
-        psF32* truthRow = meanTruth->data.F32[row];
-        for (int col = 0; col<4; col++) {
-            if (fabsf(outRow[col]-truthRow[col]) > FLT_EPSILON) {
-                psError(__func__,"psImageRebin didn't produce the proper "
-                        "result at (%d,%d) [%f vs %f].",
-                        col,row,outRow[col],truthRow[col]);
-                return 3;
-            }
-        }
-    }
-
-    stats.options = PS_STAT_MAX;
-    out2 = psImageRebin(out,in,NULL,0,3,&stats);
-
-    // Verify the returned psImage structure is equal to the input parameter
-    // out if specified.
-    if (out != out2) {
-        psError(__func__,"psImageRebin didn't recycle a psImage properly!?");
-        return 7;
-    }
-
-    if (out == NULL) {
-        psError(__func__,"psImageRebin returned a NULL pointer!?");
-        return 4;
-    }
-
-    if (out->numRows != 6 || out->numCols != 6) {
-        psError(__func__,"psImageRebin didn't produce the proper size image "
-                "(%d x %d).",
-                out->numCols, out->numRows);
-        return 5;
-    }
-
-    for (int row = 0; row<6; row++) {
-        psF32* outRow = out->data.F32[row];
-        psF32* truthRow = maxTruth->data.F32[row];
-        for (int col = 0; col<6; col++) {
-            if (fabsf(outRow[col]-truthRow[col]) > FLT_EPSILON) {
-                psError(__func__,"psImageRebin didn't produce the proper "
-                        "result at (%d,%d) [%f vs %f].",
-                        col,row,outRow[col],truthRow[col]);
-                return 6;
-            }
-        }
-    }
+    if(out != NULL) {
+        psError(__func__,"psImageRebin return an image eventhough the "
+                "type is not handled.");
+        return 14;
+    }
+    psFree(in);
 
     // Verify the returned psImage structure is null and program execution
@@ -974,4 +985,5 @@
     // Verify the returned psImage structure is null and program execution
     // doesn't stop, if the input parameter scale is less than or equal to zero.
+    in = psImageAlloc(16, 16, PS_TYPE_F32);
     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     out2 = psImageRebin(NULL,in,NULL,0,0,&stats);
@@ -1031,9 +1043,5 @@
     }
 
-
     psFree(in);
-    psFree(out);
-    psFree(meanTruth);
-    psFree(maxTruth);
 
     return 0;
