IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 6, 2004, 12:34:06 PM (22 years ago)
Author:
desonia
Message:

astyle fixed?

File:
1 edited

Legend:

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

    r1365 r1406  
    22   This routine must ensure that the psHistogram structure is correctly
    33   populated by the procedure psGetArrayHistogram().
    4 
     4 
    55*****************************************************************************/
    66#include <stdio.h>
     
    2626    int i = 0;
    2727    int currentId = 0;
    28    
     28
    2929    currentId = psMemGetId();
    30    
     30
    3131    /*********************************************************************/
    3232    /*  Allocate and initialize data structures                          */
     
    3535    myData->n = myData->nalloc;
    3636    for ( i = 0;i < NUM_DATA;i++ ) {
    37             myData->data.F32[ i ] = LOWER + ( ( UPPER - LOWER ) / ( float ) NUM_DATA ) * ( float ) i;
    38         }
    39        
     37        myData->data.F32[ i ] = LOWER + ( ( UPPER - LOWER ) / ( float ) NUM_DATA ) * ( float ) i;
     38    }
     39
    4040    myMask = psVectorAlloc( NUM_DATA, PS_TYPE_U8 );
    4141    myMask->n = myMask->nalloc;
    4242    for ( i = 0;i < NUM_DATA;i++ ) {
    43             if ( i >= ( NUM_DATA / 2 ) ) {
    44                     myMask->data.U8[ i ] = 1;
    45                 } else {
    46                     myMask->data.U8[ i ] = 0;
    47                 }
     43        if ( i >= ( NUM_DATA / 2 ) ) {
     44            myMask->data.U8[ i ] = 1;
     45        } else {
     46            myMask->data.U8[ i ] = 0;
    4847        }
    49        
     48    }
     49
    5050    for ( nb = 0;nb < 4;nb++ ) {
    51             if ( nb == 0 )
    52                 numBins = 1;
    53             if ( nb == 1 )
    54                 numBins = 2;
    55             if ( nb == 2 )
    56                 numBins = 10;
    57             if ( nb == 3 )
    58                 numBins = 20;
    59                
    60             /*********************************************************************/
    61             /*  Allocate and Perform Histogram, no mask                          */
    62             /*********************************************************************/
    63             printPositiveTestHeader( stdout,
    64                                      "psStats functions",
    65                                      "Allocate and Perform Histogram, no mask" );
    66                                      
    67             myHist = psHistogramAlloc( LOWER, UPPER, numBins );
    68             myHist = psVectorHistogram( myHist, myData, NULL, 0 );
    69            
    70             for ( i = 0;i < numBins;i++ ) {
    71                     printf( "Bin number %d bounds: (%.2f - %.2f) data (%d)\n", i,
    72                             myHist->bounds->data.F32[ i ],
    73                             myHist->bounds->data.F32[ i + 1 ],
    74                             myHist->nums->data.U32[ i ] );
    75                 }
    76             psMemCheckCorruption( 1 );
    77             psFree( myHist );
    78             psMemCheckCorruption( 1 );
    79            
    80             printFooter( stdout,
    81                          "psStats functions",
    82                          "Allocate and Perform Histogram, no mask",
    83                          testStatus );
    84                          
    85             /*********************************************************************/
    86             /*  Allocate and Perform Histogram with mask                         */
    87             /*********************************************************************/
    88             printPositiveTestHeader( stdout,
    89                                      "psStats functions",
    90                                      "Allocate and Perform Histogram with mask" );
    91                                      
    92             myHist = psHistogramAlloc( LOWER, UPPER, numBins );
    93             myHist = psVectorHistogram( myHist, myData, myMask, 1 );
    94            
    95             for ( i = 0;i < numBins;i++ ) {
    96                     printf( "Bin number %d bounds: (%6.3f - %6.3f) data (%d)\n", i,
    97                             myHist->bounds->data.F32[ i ],
    98                             myHist->bounds->data.F32[ i + 1 ],
    99                             myHist->nums->data.U32[ i ] );
    100                 }
    101             psMemCheckCorruption( 1 );
    102             psFree( myHist );
    103             psMemCheckCorruption( 1 );
    104            
    105             printFooter( stdout,
    106                          "psStats functions",
    107                          "Allocate and Perform Histogram with mask",
    108                          testStatus );
     51        if ( nb == 0 )
     52            numBins = 1;
     53        if ( nb == 1 )
     54            numBins = 2;
     55        if ( nb == 2 )
     56            numBins = 10;
     57        if ( nb == 3 )
     58            numBins = 20;
     59
     60        /*********************************************************************/
     61        /*  Allocate and Perform Histogram, no mask                          */
     62        /*********************************************************************/
     63        printPositiveTestHeader( stdout,
     64                                 "psStats functions",
     65                                 "Allocate and Perform Histogram, no mask" );
     66
     67        myHist = psHistogramAlloc( LOWER, UPPER, numBins );
     68        myHist = psVectorHistogram( myHist, myData, NULL, 0 );
     69
     70        for ( i = 0;i < numBins;i++ ) {
     71            printf( "Bin number %d bounds: (%.2f - %.2f) data (%d)\n", i,
     72                    myHist->bounds->data.F32[ i ],
     73                    myHist->bounds->data.F32[ i + 1 ],
     74                    myHist->nums->data.U32[ i ] );
    10975        }
     76        psMemCheckCorruption( 1 );
     77        psFree( myHist );
     78        psMemCheckCorruption( 1 );
     79
     80        printFooter( stdout,
     81                     "psStats functions",
     82                     "Allocate and Perform Histogram, no mask",
     83                     testStatus );
     84
     85        /*********************************************************************/
     86        /*  Allocate and Perform Histogram with mask                         */
     87        /*********************************************************************/
     88        printPositiveTestHeader( stdout,
     89                                 "psStats functions",
     90                                 "Allocate and Perform Histogram with mask" );
     91
     92        myHist = psHistogramAlloc( LOWER, UPPER, numBins );
     93        myHist = psVectorHistogram( myHist, myData, myMask, 1 );
     94
     95        for ( i = 0;i < numBins;i++ ) {
     96            printf( "Bin number %d bounds: (%6.3f - %6.3f) data (%d)\n", i,
     97                    myHist->bounds->data.F32[ i ],
     98                    myHist->bounds->data.F32[ i + 1 ],
     99                    myHist->nums->data.U32[ i ] );
     100        }
     101        psMemCheckCorruption( 1 );
     102        psFree( myHist );
     103        psMemCheckCorruption( 1 );
     104
     105        printFooter( stdout,
     106                     "psStats functions",
     107                     "Allocate and Perform Histogram with mask",
     108                     testStatus );
     109    }
    110110    psFree( myMask );
    111    
     111
    112112    printPositiveTestHeader( stdout,
    113113                             "psStats functions",
    114114                             "Calling psVectorHistogram() with various NULL inputs." );
    115                              
     115
    116116    // Verify the return value is null and program execution doesn't stop,
    117117    // if input parameter myHist is null.
    118    
     118
    119119    myHist2 = psVectorHistogram( NULL, myData, NULL, 0 );
    120120    if ( myHist2 != NULL ) {
    121             printf( "ERROR: myHist2!=NULL\n" );
    122             testStatus = false;
    123         }
     121        printf( "ERROR: myHist2!=NULL\n" );
     122        testStatus = false;
     123    }
    124124    psFree( myData );
    125    
    126    
     125
     126
    127127    // Verify the retrun value is the same as the input parameter myHist and
    128128    // program execution doesn't stop, if the input parameter myArray is
    129129    // null.
    130    
     130
    131131    myHist = psHistogramAlloc( LOWER, UPPER, numBins );
    132132    myHist = psVectorHistogram( myHist, NULL, NULL, 0 );
    133133    if ( myHist == NULL ) {
    134             printf( "ERROR: myHist==NULL\n" );
    135             testStatus = false;
    136         }
     134        printf( "ERROR: myHist==NULL\n" );
     135        testStatus = false;
     136    }
    137137    psFree( myHist );
    138    
    139    
     138
     139
    140140    // Verify the return value is the same as the input parameter myHist and
    141141    // program execution doesn't stop, if the input parameter myArray has no
     
    159159                 "Calling psVectorHistogram() with various NULL inputs.",
    160160                 testStatus );
    161                  
     161
    162162    /*************************************************************************/
    163163    /*  Deallocate data structures                                   */
     
    166166                             "psStats functions",
    167167                             "Deallocate the psHistogram structure." );
    168                              
     168
    169169    psMemCheckCorruption( 1 );
    170170    memLeaks = psMemCheckLeaks( currentId, NULL, NULL );
    171171    if ( 0 != memLeaks ) {
    172             psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
    173         }
     172        psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
     173    }
    174174    psMemCheckCorruption( 1 );
    175    
     175
    176176    printFooter( stdout,
    177177                 "psStats functions",
    178178                 "Deallocate the psHistogram structure.",
    179179                 testStatus );
    180                  
     180
    181181    return ( !testStatus );
    182182}
Note: See TracChangeset for help on using the changeset viewer.