IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 6, 2004, 5:14:39 PM (22 years ago)
Author:
gusciora
Message:

...

File:
1 edited

Legend:

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

    r887 r893  
    77#include "psTest.h"
    88#include "psMemory.h"
    9 #define MISC_FLOAT_NUMBER 345.0
    10 #define MISC_INT_NUMBER 345
    119#define LOWER 20.0
    1210#define UPPER 30.0
    13 #define NUM_BINS 200
    1411
    1512int main()
     
    1916    int memLeaks        = 0;
    2017    int i               = 0;
     18    int nb              = 0;
     19    int numBins         = 0;
    2120    int currentId       = 0;
    2221
    2322    currentId       = psMemGetId();
    24     /*************************************************************************/
    25     /*  Allocate and initialize data structures                      */
    26     /*************************************************************************/
     23    for (nb=0;nb<4;nb++) {
     24        if (nb == 0)
     25            numBins = 1;
     26        if (nb == 1)
     27            numBins = 2;
     28        if (nb == 2)
     29            numBins = 10;
     30        if (nb == 3)
     31            numBins = 20;
     32        /*********************************************************************/
     33        /*  Allocate and initialize data structures                          */
     34        /*********************************************************************/
     35        printPositiveTestHeader(stdout,
     36                                "psStats functions",
     37                                "Allocate the psHistogram structure.");
     38
     39        myHist = psHistogramAlloc(LOWER, UPPER, numBins);
     40
     41        if (myHist->nums->n != numBins) {
     42            printf("ERROR: myHist->nums->n is wrong size (%d)\n", myHist->nums->n);
     43            testStatus = false;
     44        }
     45
     46        if (myHist->bounds->n != numBins+1) {
     47            printf("ERROR: myHist->bounds->n is wrong size (%d)\n", myHist->bounds->n);
     48            testStatus = false;
     49        }
     50
     51        for (i=0;i<numBins;i++) {
     52            if (myHist->nums->data.S32[i] != 0) {
     53                printf("ERROR: myHist->nums->data.S32[%d] not initialized to 0.\n", i);
     54                testStatus = false;
     55            }
     56            myHist->nums->data.S32[i] = 0;
     57        }
     58
     59        if (myHist->minNum != 0) {
     60            printf("ERROR: myHist->minNum is %d\n", myHist->minNum);
     61            testStatus = false;
     62        }
     63
     64        if (myHist->maxNum != 0) {
     65            printf("myHist->maxNum is %d\n", myHist->maxNum);
     66            testStatus = false;
     67        }
     68
     69        if (myHist->uniform != 1) {
     70            printf("ERROR: myHist->uniform is %d\n", myHist->uniform);
     71            testStatus = false;
     72        }
     73
     74        for (i=0;i<numBins;i++) {
     75            printf("Bin number %d bounds: (%f - %f)\n", i,
     76                   myHist->bounds->data.F32[i],
     77                   myHist->bounds->data.F32[i+1]);
     78        }
     79
     80        psMemCheckCorruption(1);
     81        psHistogramFree(myHist);
     82        psMemCheckCorruption(1);
     83
     84        printFooter(stdout,
     85                    "psStats functions",
     86                    "Allocate the psHistogram structure.",
     87                    testStatus);
     88    }
     89
     90
    2791    printPositiveTestHeader(stdout,
    2892                            "psStats functions",
    29                             "Allocate the psHistogram structure.");
     93                            "Allocate the psHistogram structure. (UPPER<LOWER)");
    3094
    31     myHist = psHistogramAlloc(LOWER, UPPER, NUM_BINS);
    32     for (i=0;i<NUM_BINS;i++) {
    33         myHist->nums->data.S32[i] = MISC_INT_NUMBER;
     95    myHist = psHistogramAlloc(UPPER, LOWER, numBins);
     96    if (myHist != NULL) {
     97        printf("ERROR: myHist != NULL\n");
    3498    }
    35     for (i=0;i<NUM_BINS;i++) {
    36         printf("Bin number %d bounds: (%f - %f)\n", i,
    37                myHist->bounds->data.F32[i],
    38                myHist->bounds->data.F32[i+1]);
    39     }
    40     printf("myHist->minNum is %d\n", myHist->minNum);
    41     printf("myHist->maxNum is %d\n", myHist->maxNum);
    42     printf("myHist->uniform is %d\n", myHist->uniform);
    43 
    44     psMemCheckCorruption(1);
    45 
    4699    printFooter(stdout,
    47100                "psStats functions",
    48                 "Allocate the psHistogram structure.",
     101                "Allocate the psHistogram structure. (UPPER<LOWER)",
    49102                testStatus);
    50103
     
    55108                            "psStats functions",
    56109                            "Deallocate the psHistogram structure.");
    57     psHistogramFree(myHist);
    58110
    59111    psMemCheckCorruption(1);
Note: See TracChangeset for help on using the changeset viewer.