Changeset 1346 for trunk/psLib/test/dataManip/tst_psMatrix01.c
- Timestamp:
- Jul 29, 2004, 4:55:47 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMatrix01.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMatrix01.c
r1073 r1346 1 1 /** @file tst_psMatrix_01.c 2 *3 * @brief Test driver for psMatrix transpose function4 *5 * This test driver contains the following tests for psMatrix test point 1:6 * A) Create input and output images7 * B) Transpose input image into output image8 * C) Transpose input image into auto allocated NULL output image9 * D) Free images and check for leaks10 *11 * @author Ross Harman, MHPCC12 *13 * @version $Revision: 1.4$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-06-23 23:00:17 $15 *16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii17 *18 */2 * 3 * @brief Test driver for psMatrix transpose function 4 * 5 * This test driver contains the following tests for psMatrix test point 1: 6 * A) Create input and output images 7 * B) Transpose input image into output image 8 * C) Transpose input image into auto allocated NULL output image 9 * D) Free images and check for leaks 10 * 11 * @author Ross Harman, MHPCC 12 * 13 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-07-30 02:55:47 $ 15 * 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 17 * 18 */ 19 19 20 20 #include "pslib.h" … … 23 23 #define PRINT_MATRIX(IMAGE) \ 24 24 for(int i=IMAGE->numRows-1; i>-1; i--) { \ 25 for(int j=0; j<IMAGE->numCols; j++) { \26 printf("%f ", IMAGE->data.F64[i][j]); \27 } \28 printf("\n"); \29 }30 31 int main( int argc,32 char* argv[])25 for(int j=0; j<IMAGE->numCols; j++) { \ 26 printf("%f ", IMAGE->data.F64[i][j]); \ 27 } \ 28 printf("\n"); \ 29 } 30 31 int main( int argc, 32 char* argv[] ) 33 33 { 34 psImage * tempImage = NULL;35 36 34 psImage * tempImage = NULL; 35 36 37 37 // Test A - Create input and output images 38 printPositiveTestHeader( stdout, "psMatrix", "Create input and output images");39 psImage *inImage = ( psImage*)psImageAlloc(3, 3, PS_TYPE_F64);40 psImage *outImage = ( psImage*)psImageAlloc(3, 3, PS_TYPE_F64);41 inImage->data.F64[ 0][0] = 1;42 inImage->data.F64[ 0][1] = 2;43 inImage->data.F64[ 0][2] = 3;44 inImage->data.F64[ 1][0] = 4;45 inImage->data.F64[ 1][1] = 5;46 inImage->data.F64[ 1][2] = 6;47 inImage->data.F64[ 2][0] = 7;48 inImage->data.F64[ 2][1] = 8;49 inImage->data.F64[ 2][2] = 9;50 PRINT_MATRIX( inImage);51 printFooter( stdout, "psMatrix", "Create input and output images", true);52 53 38 printPositiveTestHeader( stdout, "psMatrix", "Create input and output images" ); 39 psImage *inImage = ( psImage* ) psImageAlloc( 3, 3, PS_TYPE_F64 ); 40 psImage *outImage = ( psImage* ) psImageAlloc( 3, 3, PS_TYPE_F64 ); 41 inImage->data.F64[ 0 ][ 0 ] = 1; 42 inImage->data.F64[ 0 ][ 1 ] = 2; 43 inImage->data.F64[ 0 ][ 2 ] = 3; 44 inImage->data.F64[ 1 ][ 0 ] = 4; 45 inImage->data.F64[ 1 ][ 1 ] = 5; 46 inImage->data.F64[ 1 ][ 2 ] = 6; 47 inImage->data.F64[ 2 ][ 0 ] = 7; 48 inImage->data.F64[ 2 ][ 1 ] = 8; 49 inImage->data.F64[ 2 ][ 2 ] = 9; 50 PRINT_MATRIX( inImage ); 51 printFooter( stdout, "psMatrix", "Create input and output images", true ); 52 53 54 54 // Test B - Transpose input image into output image 55 printPositiveTestHeader( stdout, "psMatrix", "Transpose input image into output image");55 printPositiveTestHeader( stdout, "psMatrix", "Transpose input image into output image" ); 56 56 tempImage = outImage; 57 outImage = psMatrixTranspose( outImage, inImage);58 PRINT_MATRIX( outImage);59 if (outImage->type.dimen != PS_DIMEN_IMAGE) {60 printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");61 } else if(outImage != tempImage) {62 printf("Error: Return pointer not equal to output argument pointer\n");63 }64 printFooter( stdout, "psMatrix", "Transpose input image into output image", true);65 66 57 outImage = psMatrixTranspose( outImage, inImage ); 58 PRINT_MATRIX( outImage ); 59 if ( outImage->type.dimen != PS_DIMEN_IMAGE ) { 60 printf( "Error: Resulting image is not PS_DIMEN_IMAGE\n" ); 61 } else if ( outImage != tempImage ) { 62 printf( "Error: Return pointer not equal to output argument pointer\n" ); 63 } 64 printFooter( stdout, "psMatrix", "Transpose input image into output image", true ); 65 66 67 67 // Test C - Transpose input image into auto allocated NULL output image 68 printPositiveTestHeader( stdout, "psMatrix", "ranspose input image into auto allocated NULL output image");68 printPositiveTestHeader( stdout, "psMatrix", "ranspose input image into auto allocated NULL output image" ); 69 69 psImage *outImageNull = NULL; 70 outImageNull = psMatrixTranspose( outImageNull, inImage);71 PRINT_MATRIX( outImageNull);72 printFooter( stdout, "psMatrix", "ranspose input image into auto allocated NULL output image", true);73 74 70 outImageNull = psMatrixTranspose( outImageNull, inImage ); 71 PRINT_MATRIX( outImageNull ); 72 printFooter( stdout, "psMatrix", "ranspose input image into auto allocated NULL output image", true ); 73 74 75 75 // Test D - Free images and check for leaks 76 printPositiveTestHeader(stdout, "psMatrix", "Free images and check for leaks"); 77 psFree(inImage); 78 psFree(outImage); 79 psFree(outImageNull); 80 psMemCheckLeaks(0, NULL, stdout); 81 int nBad = psMemCheckCorruption(0); 82 if(nBad) { 83 printf("ERROR: Found %d bad memory blocks\n", nBad); 84 } 85 printFooter(stdout, "psMatrix" ,"Free images and check for leaks", true); 86 76 printPositiveTestHeader( stdout, "psMatrix", "Free images and check for leaks" ); 77 psFree( inImage ); 78 psFree( outImage ); 79 psFree( outImageNull ); 80 int nLeaks = psMemCheckLeaks( 0, NULL, stdout ); 81 if ( nLeaks != 0 ) { 82 printf( "ERROR: Found %d memory leaks\n", nLeaks ); 83 } 84 int nBad = psMemCheckCorruption( 0 ); 85 if ( nBad ) { 86 printf( "ERROR: Found %d bad memory blocks\n", nBad ); 87 } 88 printFooter( stdout, "psMatrix" , "Free images and check for leaks", true ); 89 87 90 return 0; 88 91 }
Note:
See TracChangeset
for help on using the changeset viewer.
