Changeset 893 for trunk/psLib/test/dataManip/tst_psHist02.c
- Timestamp:
- Jun 6, 2004, 5:14:39 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psHist02.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psHist02.c
r887 r893 12 12 #define LOWER 20.0 13 13 #define UPPER 30.0 14 #define NUM_BINS 2015 14 #define NUM_DATA 10000 16 15 … … 18 17 { 19 18 psHistogram *myHist = NULL; 19 psHistogram *myHist2= NULL; 20 20 psVector *myData = NULL; 21 21 psVector *myMask = NULL; 22 22 int testStatus = true; 23 23 int memLeaks = 0; 24 int nb = 0; 25 int numBins = 0; 24 26 int i = 0; 25 27 int currentId = 0; … … 27 29 currentId = psMemGetId(); 28 30 31 /*********************************************************************/ 32 /* Allocate and initialize data structures */ 33 /*********************************************************************/ 29 34 myData = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 30 35 myData->n = myData->nalloc; … … 42 47 } 43 48 } 44 /*************************************************************************/ 45 /* Allocate and Perform Histogram, no mask */ 46 /*************************************************************************/ 49 50 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 = psHistogramVector(myHist, myData, NULL, 0); 69 70 for (i=0;i<numBins;i++) { 71 printf("Bin number %d bounds: (%f - %f) data (%d)\n", i, 72 myHist->bounds->data.F32[i], 73 myHist->bounds->data.F32[i+1], 74 myHist->nums->data.S32[i]); 75 } 76 psMemCheckCorruption(1); 77 psHistogramFree(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 = psHistogramVector(myHist, myData, myMask, 1); 94 95 for (i=0;i<numBins;i++) { 96 printf("Bin number %d bounds: (%f - %f) data (%d)\n", i, 97 myHist->bounds->data.F32[i], 98 myHist->bounds->data.F32[i+1], 99 myHist->nums->data.S32[i]); 100 } 101 psMemCheckCorruption(1); 102 psHistogramFree(myHist); 103 psMemCheckCorruption(1); 104 105 printFooter(stdout, 106 "psStats functions", 107 "Allocate and Perform Histogram with mask", 108 testStatus); 109 } 110 psVectorFree(myMask); 111 47 112 printPositiveTestHeader(stdout, 48 113 "psStats functions", 49 " Allocate and Perform Histogram, no mask");114 "Calling psHistogramVector() with various NULL inputs."); 50 115 51 myHist = psHistogramAlloc(LOWER, UPPER, NUM_BINS);52 myHist = psHistogramVector(myHist, myData, NULL, 0);116 // Verify the return value is null and program execution doesn't stop, 117 // if input parameter myHist is null. 53 118 54 for (i=0;i<NUM_BINS;i++) { 55 printf("Bin number %d bounds: (%f - %f) data (%d)\n", i, 56 myHist->bounds->data.F32[i], 57 myHist->bounds->data.F32[i+1], 58 myHist->nums->data.S32[i]); 119 myHist2 = psHistogramVector(NULL, myData, NULL, 0); 120 if (myHist2 != NULL) { 121 printf("ERROR: myHist2!=NULL\n"); 122 testStatus = false; 123 } 124 psVectorFree(myData); 125 126 127 // Verify the retrun value is the same as the input parameter myHist and 128 // program execution doesn't stop, if the input parameter myArray is 129 // null. 130 131 myHist = psHistogramAlloc(LOWER, UPPER, numBins); 132 myHist = psHistogramVector(myHist, NULL, NULL, 0); 133 if (myHist == NULL) { 134 printf("ERROR: myHist==NULL\n"); 135 testStatus = false; 59 136 } 60 137 psHistogramFree(myHist); 61 138 139 140 // Verify the return value is the same as the input parameter myHist and 141 // program execution doesn't stop, if the input parameter myArray has no 142 // elements. 143 // NOTE: This code segment is commented out because psVectorAlloc returns 144 // NULL if called with an N element data. 145 /* 146 myData = psVectorAlloc(0, PS_TYPE_F32); 147 myData->n = myData->nalloc; 148 myHist = psHistogramAlloc(LOWER, UPPER, numBins); 149 myHist = psHistogramVector(myHist, NULL, NULL, 0); 150 if (myHist == NULL) { 151 printf("ERROR: myHist==NULL\n"); 152 testStatus = false; 153 } 154 psHistogramFree(myHist); 155 psVectorFree(myData); 156 */ 62 157 printFooter(stdout, 63 158 "psStats functions", 64 "Allocate and Perform Histogram, no mask", 65 testStatus); 66 67 /*************************************************************************/ 68 /* Allocate and Perform Histogram with mask */ 69 /*************************************************************************/ 70 printPositiveTestHeader(stdout, 71 "psStats functions", 72 "Allocate and Perform Histogram with mask"); 73 74 myHist = psHistogramAlloc(LOWER, UPPER, NUM_BINS); 75 myHist = psHistogramVector(myHist, myData, myMask, 1); 76 77 for (i=0;i<NUM_BINS;i++) { 78 printf("Bin number %d bounds: (%f - %f) data (%d)\n", i, 79 myHist->bounds->data.F32[i], 80 myHist->bounds->data.F32[i+1], 81 myHist->nums->data.S32[i]); 82 } 83 84 printFooter(stdout, 85 "psStats functions", 86 "Allocate and Perform Histogram with mask", 159 "Calling psHistogramVector() with various NULL inputs.", 87 160 testStatus); 88 161 … … 93 166 "psStats functions", 94 167 "Deallocate the psHistogram structure."); 95 psHistogramFree(myHist);96 psVectorFree(myData);97 psVectorFree(myMask);98 168 99 169 psMemCheckCorruption(1);
Note:
See TracChangeset
for help on using the changeset viewer.
