Index: trunk/psLib/test/image/tst_psImageExtraction.c
===================================================================
--- trunk/psLib/test/image/tst_psImageExtraction.c	(revision 1364)
+++ trunk/psLib/test/image/tst_psImageExtraction.c	(revision 1404)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-02 18:30:10 $
+*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-06 21:50:14 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -27,5 +27,5 @@
                               }
                           };
-                          
+
 int main( int argc, char* argv[] )
 {
@@ -41,11 +41,12 @@
     psVector* out = NULL;
     psImage* image = psImageAlloc( c, r, PS_TYPE_F32 );
+    psVector* positions = psVectorAlloc( r, PS_TYPE_U32 );
     psImage* mask = psImageAlloc( c, r, PS_TYPE_MASK );
     psStats* stat = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN );
-    
+
     /*
         This function shall extract pixels from a specified region of a psImage
         structure into a vector using a specified statistical method.
-    
+
         Verify the returned psVector structure contains expected data, if the 
         input psImage input has known data and the psStats structure specifies 
@@ -57,33 +58,50 @@
      
      */
-    
+
     for ( int row = 0;row < r;row++ ) {
-            psF32* imageRow = image->data.F32[ row ];
-            psMaskType* maskRow = image->data.V[ row ];
-            psF32 rowOffset = ( psF32 ) row / ( psF32 ) r;
-            for ( int col = 0;col < c;col++ ) {
-                    imageRow[ col ] = ( psF32 ) col + rowOffset;
-                    maskRow[ col ] = 0;
-                }
+        psF32* imageRow = image->data.F32[ row ];
+        psMaskType* maskRow = image->data.V[ row ];
+        psF32 rowOffset = ( psF32 ) row / ( psF32 ) r;
+        for ( int col = 0;col < c;col++ ) {
+            imageRow[ col ] = ( psF32 ) col + rowOffset;
+            maskRow[ col ] = 0;
         }
-        
+    }
+
     // test MxN case
-    
+
     #define PSIMAGESLICE_TEST1(M,N,DIRECTION,TRUTH_SIZE,TRUTHPIX_X,TRUTHPIX_Y,TESTNUM) \
-    out = psImageSlice(out,image,mask,1,c/10,r/10,M,N,DIRECTION,stat); \
+    out = psImageSlice(out,positions,image,mask,1,c/10,r/10,M,N,DIRECTION,stat); \
     \
     if (out->n != TRUTH_SIZE) { \
-            psError(__func__,"Number of results is wrong (%d, not %d)", \
-                    out->n,n); \
-            return TESTNUM*2+1; \
-        } \
+        psError(__func__,"Number of results is wrong (%d, not %d)", \
+                out->n,n); \
+        return TESTNUM*4+1; \
+    } \
+    \
+    if (positions->n != TRUTH_SIZE) { \
+        psError(__func__,"Number of results for positions vector is wrong (%d, not %d)", \
+                out->n,n); \
+        return TESTNUM*4+2; \
+    } \
     \
     for (int i=0;i<out->n;i++) { \
-            if (abs(out->data.F64[i]-image->data.F32[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]) > 1.0/(psF32)r) { \
-                    psError(__func__,"Improper result at position %d.",i); \
-                    return TESTNUM*2+2; \
-                } \
-        }
-        
+        if (abs(out->data.F64[i]-image->data.F32[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]) > 1.0/(psF32)r) { \
+            psError(__func__,"Improper result at position %d.",i); \
+            return TESTNUM*4+3; \
+        } \
+        if (DIRECTION == PS_CUT_X_POS || DIRECTION == PS_CUT_X_NEG) { \
+            if (positions->data.U32[i] != c/10+TRUTHPIX_X) { \
+                psError(__func__,"Improper postions result @ %d.",i); \
+                return TESTNUM*4+4; \
+            } \
+        } else { \
+            if (positions->data.U32[i] != r/10+TRUTHPIX_Y) { \
+                psError(__func__,"Improper postions result @ %d.",i); \
+                return TESTNUM*4+4; \
+            } \
+        } \
+    }
+
     // test MxN case
     PSIMAGESLICE_TEST1( m, n, PS_CUT_X_POS, m, i, n / 2, 0 );
@@ -91,5 +109,5 @@
     PSIMAGESLICE_TEST1( m, n, PS_CUT_Y_POS, n, m / 2, i, 2 );
     PSIMAGESLICE_TEST1( m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3 );
-    
+
     // test Mx1 case
     PSIMAGESLICE_TEST1( m, 1, PS_CUT_X_POS, m, i, 0, 4 );
@@ -97,5 +115,5 @@
     PSIMAGESLICE_TEST1( m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6 );
     PSIMAGESLICE_TEST1( m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7 );
-    
+
     // test 1xN case
     PSIMAGESLICE_TEST1( 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8 );
@@ -103,5 +121,5 @@
     PSIMAGESLICE_TEST1( 1, n, PS_CUT_Y_POS, n, 0, n - 1 - i, 10 );
     PSIMAGESLICE_TEST1( 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11 );
-    
+
     // test 1x1 case
     PSIMAGESLICE_TEST1( 1, 1, PS_CUT_X_POS, 1, 0, 0, 12 );
@@ -109,18 +127,18 @@
     PSIMAGESLICE_TEST1( 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14 );
     PSIMAGESLICE_TEST1( 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15 );
-    
+
     /*
        Verify the returned psVector structure pointer is null and program 
        execution doesn't stop, if input psImage input is null.
-    
-    */
-    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
-    out = psImageSlice( out, NULL, NULL, 0, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
-    if ( out != NULL ) {
-            psError( __func__, "Giving a NULL image, psImageSlice didn't return NULL as expected" );
-            return 41;
-        }
-        
-        
+
+    */
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, NULL, NULL, NULL, 0, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+        psError( __func__, "Giving a NULL image, psImageSlice didn't return NULL as expected" );
+        return 101;
+    }
+
+
     /*
        Verify the returned psVector structure pointer is null and program 
@@ -128,12 +146,12 @@
     */
     psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
-    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, NULL );
-    if ( out != NULL ) {
-            psError( __func__, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
-            return 42;
-        }
-        
-    /*
-    
+    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, NULL );
+    if ( out != NULL ) {
+        psError( __func__, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
+        return 102;
+    }
+
+    /*
+
        Verify the returned psVector structure pointer is null and program 
        executions doesn't stop, if the input direction is not set to one of 
@@ -141,10 +159,10 @@
     */
     psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
-    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, 1, 5, stat );
-    if ( out != NULL ) {
-            psError( __func__, "Giving a bogus direction flag, psImageSlice didn't return NULL as expected" );
-            return 43;
-        }
-        
+    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 1, 1, 5, stat );
+    if ( out != NULL ) {
+        psError( __func__, "Giving a bogus direction flag, psImageSlice didn't return NULL as expected" );
+        return 103;
+    }
+
     /*
        Verify the returned psVector structure pointer is null and program 
@@ -152,10 +170,10 @@
     */
     psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
-    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 0, 0, PS_CUT_X_POS, stat );
-    if ( out != NULL ) {
-            psError( __func__, "Giving a 0x0 region, psImageSlice didn't return NULL as expected" );
-            return 44;
-        }
-        
+    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 0, 0, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+        psError( __func__, "Giving a 0x0 region, psImageSlice didn't return NULL as expected" );
+        return 104;
+    }
+
     /*
        Verify the returned psVector structure pointer is null and program 
@@ -164,31 +182,31 @@
     */
     psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
-    out = psImageSlice( out, image, mask, 1, c + 1, r / 10, 1, 1, PS_CUT_X_POS, stat );
-    if ( out != NULL ) {
-            psError( __func__, "Giving an invalid x position, psImageSlice didn't return NULL as expected" );
-            return 45;
-        }
-        
-    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
-    out = psImageSlice( out, image, mask, 1, c / 10, r + 1, 1, 1, PS_CUT_X_POS, stat );
-    if ( out != NULL ) {
-            psError( __func__, "Giving an invalid y position, psImageSlice didn't return NULL as expected" );
-            return 46;
-        }
-        
-    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
-    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, c, 1, PS_CUT_X_POS, stat );
-    if ( out != NULL ) {
-            psError( __func__, "Giving an invalid numCols, psImageSlice didn't return NULL as expected" );
-            return 47;
-        }
-        
-    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
-    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, r, PS_CUT_X_POS, stat );
-    if ( out != NULL ) {
-            psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
-            return 48;
-        }
-        
+    out = psImageSlice( out, NULL, image, mask, 1, c + 1, r / 10, 1, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+        psError( __func__, "Giving an invalid x position, psImageSlice didn't return NULL as expected" );
+        return 105;
+    }
+
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r + 1, 1, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+        psError( __func__, "Giving an invalid y position, psImageSlice didn't return NULL as expected" );
+        return 106;
+    }
+
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, c, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+        psError( __func__, "Giving an invalid numCols, psImageSlice didn't return NULL as expected" );
+        return 107;
+    }
+
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 1, r, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+        psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
+        return 108;
+    }
+
     /*
        Verify the returned psVector structure pointer is null and program 
@@ -198,24 +216,18 @@
     psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
     stat->options = 0;
-    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
-    if ( out != NULL ) {
-            psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
-            return 49;
-        }
-        
+    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+        psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
+        return 109;
+    }
+
     psFree( image );
+    psFree( positions );
     psFree( mask );
     psFree( out );
     psFree( stat );
-    
+
     return 0;
-    
+
 }
 
-
-
-
-
-
-
-
