Changeset 893 for trunk/psLib/test/dataManip/tst_psHist00.c
- Timestamp:
- Jun 6, 2004, 5:14:39 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psHist00.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psHist00.c
r887 r893 7 7 #include "psTest.h" 8 8 #include "psMemory.h" 9 #define MISC_FLOAT_NUMBER 345.010 #define MISC_INT_NUMBER 34511 9 #define LOWER 20.0 12 10 #define UPPER 30.0 13 #define NUM_BINS 20014 11 15 12 int main() … … 19 16 int memLeaks = 0; 20 17 int i = 0; 18 int nb = 0; 19 int numBins = 0; 21 20 int currentId = 0; 22 21 23 22 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 27 91 printPositiveTestHeader(stdout, 28 92 "psStats functions", 29 "Allocate the psHistogram structure. ");93 "Allocate the psHistogram structure. (UPPER<LOWER)"); 30 94 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"); 34 98 } 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 46 99 printFooter(stdout, 47 100 "psStats functions", 48 "Allocate the psHistogram structure. ",101 "Allocate the psHistogram structure. (UPPER<LOWER)", 49 102 testStatus); 50 103 … … 55 108 "psStats functions", 56 109 "Deallocate the psHistogram structure."); 57 psHistogramFree(myHist);58 110 59 111 psMemCheckCorruption(1);
Note:
See TracChangeset
for help on using the changeset viewer.
