IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 29, 2004, 5:13:08 PM (22 years ago)
Author:
evanalst
Message:

Add memory leak check.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataManip/tst_psMatrix05.c

    r1073 r1347  
    11/** @file  tst_psMatrix_05.c
    2  *
    3  *  @brief Test driver for psMatrix multiplication function
    4  *
    5  *  This test driver contains the following tests for psMatrix test point 5:
    6  *     A)  Create input and output images
    7  *     B)  Multiply images
    8  *     C)  Free input and output images
    9  *
    10  *  @author  Ross Harman, MHPCC
    11  *
    12  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    13  *  @date  $Date: 2004-06-23 23:00:17 $
    14  *
    15  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    16  *
    17  */
     2*
     3*  @brief Test driver for psMatrix multiplication function
     4*
     5*  This test driver contains the following tests for psMatrix test point 5:
     6*     A)  Create input and output images
     7*     B)  Multiply images
     8*     C)  Free input and output images
     9*
     10*  @author  Ross Harman, MHPCC
     11*
     12*  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     13*  @date  $Date: 2004-07-30 03:13:08 $
     14*
     15*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     16*
     17*/
    1818
    1919#include "pslib.h"
     
    2222#define PRINT_MATRIX(IMAGE)                         \
    2323for(int i=0; i<IMAGE->numRows; i++) {           \
    24     for(int j=0; j<IMAGE->numCols; j++) {       \
    25         printf("%f ", IMAGE->data.F64[i][j]);   \
    26     }                                          \
    27     printf("\n");                              \
    28 }
    29 
    30 
    31 int main(int argc,
    32          char* argv[])
     24        for(int j=0; j<IMAGE->numCols; j++) {       \
     25                printf("%f ", IMAGE->data.F64[i][j]);   \
     26            }                                          \
     27        printf("\n");                              \
     28    }
     29   
     30   
     31int main( int argc,
     32          char* argv[] )
    3333{
    34     psImage *outImage = NULL;
     34    psImage * outImage = NULL;
    3535    psImage *inImage1 = NULL;
    3636    psImage *inImage2 = NULL;
    37 
    38 
     37   
     38   
    3939    // Test A - Create input and output images
    40     printPositiveTestHeader(stdout, "psMatrix", "Create input and output images");
    41     outImage = (psImage*)psImageAlloc(2, 2, PS_TYPE_F64);
    42     inImage1 = (psImage*)psImageAlloc(2, 2, PS_TYPE_F64);
    43     inImage2 = (psImage*)psImageAlloc(2, 2, PS_TYPE_F64);
    44     inImage1->data.F64[0][0] = 2;
    45     inImage1->data.F64[0][1] = 3;
    46     inImage1->data.F64[1][0] = -1;
    47     inImage1->data.F64[1][1] = 2;
    48     inImage2->data.F64[0][0] = 4;
    49     inImage2->data.F64[0][1] = 1;
    50     inImage2->data.F64[1][0] = 0;
    51     inImage2->data.F64[1][1] = 6;
    52     PRINT_MATRIX(inImage1);
    53     printf("\n");
    54     PRINT_MATRIX(inImage2);
    55     printFooter(stdout, "psMatrix", "Create input and output images", true);
    56 
    57 
     40    printPositiveTestHeader( stdout, "psMatrix", "Create input and output images" );
     41    outImage = ( psImage* ) psImageAlloc( 2, 2, PS_TYPE_F64 );
     42    inImage1 = ( psImage* ) psImageAlloc( 2, 2, PS_TYPE_F64 );
     43    inImage2 = ( psImage* ) psImageAlloc( 2, 2, PS_TYPE_F64 );
     44    inImage1->data.F64[ 0 ][ 0 ] = 2;
     45    inImage1->data.F64[ 0 ][ 1 ] = 3;
     46    inImage1->data.F64[ 1 ][ 0 ] = -1;
     47    inImage1->data.F64[ 1 ][ 1 ] = 2;
     48    inImage2->data.F64[ 0 ][ 0 ] = 4;
     49    inImage2->data.F64[ 0 ][ 1 ] = 1;
     50    inImage2->data.F64[ 1 ][ 0 ] = 0;
     51    inImage2->data.F64[ 1 ][ 1 ] = 6;
     52    PRINT_MATRIX( inImage1 );
     53    printf( "\n" );
     54    PRINT_MATRIX( inImage2 );
     55    printFooter( stdout, "psMatrix", "Create input and output images", true );
     56   
     57   
    5858    // Test B - Multiply images
    59     printPositiveTestHeader(stdout, "psMatrix", "Multiply images");
    60     psMatrixMultiply(outImage, inImage1, inImage2);
    61     PRINT_MATRIX(outImage);
    62     printFooter(stdout, "psMatrix", "Multiply images", true);
    63 
    64 
     59    printPositiveTestHeader( stdout, "psMatrix", "Multiply images" );
     60    psMatrixMultiply( outImage, inImage1, inImage2 );
     61    PRINT_MATRIX( outImage );
     62    printFooter( stdout, "psMatrix", "Multiply images", true );
     63   
     64   
    6565    // Test C - Free input and output images
    66     printPositiveTestHeader(stdout, "psMatrix", "Free input and output images");
    67     psFree(outImage);
    68     psFree(inImage1);
    69     psFree(inImage2);
    70     psMemCheckLeaks(0, NULL, stdout);
    71     int nBad = psMemCheckCorruption(0);
    72     if(nBad) {
    73         printf("ERROR: Found %d bad memory blocks\n", nBad);
    74     }
    75     printFooter(stdout, "psMatrix" ,"Free input and output images", true);
    76 
     66    printPositiveTestHeader( stdout, "psMatrix", "Free input and output images" );
     67    psFree( outImage );
     68    psFree( inImage1 );
     69    psFree( inImage2 );
     70    int nLeaks = psMemCheckLeaks( 0, NULL, stdout );
     71    if ( nLeaks != 0 ) {
     72            printf( "ERROR: Found %d memory leaks\n", nLeaks );
     73        }
     74    int nBad = psMemCheckCorruption( 0 );
     75    if ( nBad ) {
     76            printf( "ERROR: Found %d bad memory blocks\n", nBad );
     77        }
     78    printFooter( stdout, "psMatrix" , "Free input and output images", true );
     79   
    7780    return 0;
    7881}
Note: See TracChangeset for help on using the changeset viewer.