Index: trunk/psLib/test/imageops/tap_psImageGeomManip.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImageGeomManip.c	(revision 13123)
+++ trunk/psLib/test/imageops/tap_psImageGeomManip.c	(revision 13614)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-05-02 04:14:33 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-06-04 20:25:32 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -16,4 +16,158 @@
 #include "pstap.h"
 #define VERBOSE 0
+
+void genericImageRollTest(int numRows, int numCols)
+{
+    psMemId id = psMemGetId();
+    psImage *in;
+    psImage *out;
+    psImage *out2;
+
+    // The function psImageRoll shall generate a new psImage structure by
+    // rolling the input image the correponding number of pixels in the vertical
+    // and/or horizontal direction. The image output image shall be the same size
+    // as the input image. Values which roll off the image are wrapped to the
+    // other side.
+    //
+    // Verify the returned psImage structure contains expected values, if the
+    // input image contains known values and the roll performed is known.
+    // Cases should include no roll, vertical roll, horizontal roll and
+    // combination vertical/horizontal rolls. Positive and negative rolls
+    // should be performed.
+
+    in = psImageAlloc(numCols,numRows,PS_TYPE_F32);
+    for (psS32 row=0;row<numRows;row++) {
+        for (psS32 col=0;col<numCols;col++) {
+            in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f;
+        }
+    }
+
+    out = psImageRoll(NULL,in,0,0);
+    bool errorFlag = false;
+    for (psS32 row=0;row<numRows;row++) {
+        psF32 *inRow = in->data.F32[row];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[col] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=0, dy=0",
+                     col,row,inRow[col],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (no roll)");
+
+    errorFlag = false;
+    out2 = psImageRoll(out,in,numCols/4,0);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[row];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[(col+numCols/4) % numCols] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=numCols/4, dy=0",
+                     col,row,inRow[(col+numCols/4) % numCols],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (column roll only");
+
+    // Verify the returned psImage structure pointer is equal to the input
+    // parameter out if provided.
+    ok(out2 == out, "psImageRoll did recycle the out psImage");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,0,numRows/4);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[(row+numRows/4)%numRows];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[col] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=0, dy=numRows/4",
+                     col,row,inRow[col],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (row roll onlt)");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,numCols/4,numRows/4);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[(row+numRows/4)%numRows];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[(col+numCols/4) % numCols] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=numCols/4, dy=numRows/4",
+                     col,row,inRow[(col+numCols/4) % numCols],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (column and row roll)");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,-numCols/4,0);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[row];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[(col+(numCols-numCols/4)) % numCols] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=-numCols/4, dy=0",
+                     col,row,inRow[(col+(numCols-numCols/4)) % numCols],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (negative column roll)");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,0,-numRows/4);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[(row+numRows-numRows/4)%numRows];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[col] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=0, dy=-numRows/4",
+                     col,row,inRow[col],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (negative row roll)");
+
+    errorFlag = false;
+    out = psImageRoll(out,in,-numCols/4,-numRows/4);
+    for (psS32 row=0;row<numRows;row++)
+    {
+        psF32 *inRow = in->data.F32[(row+numRows-numRows/4)%numRows];
+        psF32 *outRow = out->data.F32[row];
+        for (psS32 col=0;col<numCols;col++) {
+            if (inRow[(col+numCols-numCols/4) % numCols] != outRow[col]) {
+                diag("psImageRoll didn't produce expected result "
+                     "at %d,%d (%f vs %f) for dx=numCols/4, dy=numRows/4",
+                     col,row,inRow[(col+numCols-numCols/4) % numCols],outRow[col]);
+                errorFlag = true;
+            }
+        }
+    }
+    ok(!errorFlag, "psImageRoll() produced the correct data values (negative column and row roll)");
+    psFree(in);
+    psFree(out);
+    ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+}
+
+
 
 bool testImageShiftCase(psS32 cols,
@@ -152,5 +306,5 @@
     psLogSetFormat("HLNM");
     psLogSetLevel(PS_LOG_INFO);
-    plan_tests(237);
+    plan_tests(280);
 
     // test psImageRebin()
@@ -366,4 +520,11 @@
     if (1) {
         psMemId id = psMemGetId();
+        // Perform generic tests with various image sizes
+        genericImageRollTest(8, 1);
+        genericImageRollTest(1, 8);
+        genericImageRollTest(8, 8);
+        genericImageRollTest(8, 16);
+        genericImageRollTest(16, 8);
+
         psImage *in;
         psImage *out;
@@ -373,17 +534,4 @@
         psS32 rows1 = 8;
         psS32 cols1 = 8;
-
-        // The function psImageRoll shall generate a new psImage structure by
-        // rolling the input image the correponding number of pixels in the vertical
-        // and/or horizontal direction. The image output image shall be the same size
-        // as the input image. Values which roll off the image are wrapped to the
-        // other side.
-        //
-        // Verify the returned psImage structure contains expected values, if the
-        // input image contains known values and the roll performed is known.
-        // Cases should include no roll, vertical roll, horizontal roll and
-        // combination vertical/horizontal rolls. Positive and negative rolls
-        // should be performed.
-
         in = psImageAlloc(cols,rows,PS_TYPE_F32);
         for (psS32 row=0;row<rows;row++) {
@@ -393,127 +541,5 @@
         }
 
-        out = psImageRoll(NULL,in,0,0);
         bool errorFlag = false;
-        for (psS32 row=0;row<rows;row++) {
-            psF32 *inRow = in->data.F32[row];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[col] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=0, dy=0",
-                         col,row,inRow[col],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out2 = psImageRoll(out,in,cols/4,0);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[row];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[(col+cols/4) % cols] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=cols/4, dy=0",
-                         col,row,inRow[(col+cols/4) % cols],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        // Verify the returned psImage structure pointer is equal to the input
-        // parameter out if provided.
-        ok(out2 == out, "psImageRoll didt recycle the out psImage");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,0,rows/4);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[(row+rows/4)%rows];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[col] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=0, dy=rows/4",
-                         col,row,inRow[col],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,cols/4,rows/4);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[(row+rows/4)%rows];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[(col+cols/4) % cols] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4",
-                         col,row,inRow[(col+cols/4) % cols],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,-cols/4,0);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[row];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[(col+(cols-cols/4)) % cols] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=-cols/4, dy=0",
-                         col,row,inRow[(col+(cols-cols/4)) % cols],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,0,-rows/4);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[(row+rows-rows/4)%rows];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[col] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=0, dy=-rows/4",
-                         col,row,inRow[col],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-        errorFlag = false;
-        out = psImageRoll(out,in,-cols/4,-rows/4);
-        for (psS32 row=0;row<rows;row++)
-        {
-            psF32 *inRow = in->data.F32[(row+rows-rows/4)%rows];
-            psF32 *outRow = out->data.F32[row];
-            for (psS32 col=0;col<cols;col++) {
-                if (inRow[(col+cols-cols/4) % cols] != outRow[col]) {
-                    diag("psImageRoll didn't produce expected result "
-                         "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4",
-                         col,row,inRow[(col+cols-cols/4) % cols],outRow[col]);
-                    errorFlag = true;
-                }
-            }
-        }
-        ok(!errorFlag, "psImageRoll() produced the correct data values");
-
-
         // Verify the returned psImage structure pointer is NULL and program
         // execution doesn't stop, if input parameter input is NULL.
