[TD-225] update test cases.
This commit is contained in:
parent
cca7015150
commit
172f11cad4
|
@ -67,7 +67,7 @@ void tHistogramDestroy(SHistogramInfo** pHisto);
|
||||||
|
|
||||||
void tHistogramPrint(SHistogramInfo* pHisto);
|
void tHistogramPrint(SHistogramInfo* pHisto);
|
||||||
|
|
||||||
//int32_t histoBinarySearch(SHistBin* pEntry, int32_t len, double val);
|
int32_t histoBinarySearch(SHistBin* pEntry, int32_t len, double val);
|
||||||
|
|
||||||
SHeapEntry* tHeapCreate(int32_t numOfEntries);
|
SHeapEntry* tHeapCreate(int32_t numOfEntries);
|
||||||
void tHeapSort(SHeapEntry* pEntry, int32_t len);
|
void tHeapSort(SHeapEntry* pEntry, int32_t len);
|
||||||
|
|
|
@ -120,7 +120,6 @@
|
||||||
//}
|
//}
|
||||||
|
|
||||||
static int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val);
|
static int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val);
|
||||||
static int32_t histoBinarySearch(SHistBin* pEntry, int32_t len, double val);
|
|
||||||
|
|
||||||
SHistogramInfo* tHistogramCreate(int32_t numOfEntries) {
|
SHistogramInfo* tHistogramCreate(int32_t numOfEntries) {
|
||||||
/* need one redundant slot */
|
/* need one redundant slot */
|
||||||
|
|
|
@ -21,19 +21,19 @@ TEST(testCase, histogram_binary_search) {
|
||||||
pHisto->elems[i].val = i;
|
pHisto->elems[i].val = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, 1);
|
int32_t idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 1);
|
||||||
assert(idx == 1);
|
assert(idx == 1);
|
||||||
|
|
||||||
idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, 9);
|
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 9);
|
||||||
assert(idx == 9);
|
assert(idx == 9);
|
||||||
|
|
||||||
idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, 20);
|
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 20);
|
||||||
assert(idx == 10);
|
assert(idx == 10);
|
||||||
|
|
||||||
idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, -1);
|
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, -1);
|
||||||
assert(idx == 0);
|
assert(idx == 0);
|
||||||
|
|
||||||
idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, 3.9);
|
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 3.9);
|
||||||
assert(idx == 4);
|
assert(idx == 4);
|
||||||
|
|
||||||
free(pHisto);
|
free(pHisto);
|
||||||
|
|
Loading…
Reference in New Issue