Add test case.

This commit is contained in:
Harpreet Sangar 2023-05-29 16:30:12 +05:30
parent 8520e785cc
commit 06b46ab961
2 changed files with 9 additions and 1 deletions

View File

@ -57,7 +57,10 @@ void NumericTrie::search_greater(const int32_t& value, const bool& inclusive, ui
if (value >= 0) {
uint32_t* positive_ids = nullptr;
positive_trie->search_greater(inclusive ? value : value + 1, positive_ids, ids_length);
uint32_t positive_ids_length = 0;
positive_trie->search_greater(inclusive ? value : value + 1, positive_ids, positive_ids_length);
ids_length = positive_ids_length;
ids = positive_ids;
} else {
// Have to combine the results of >value from negative_trie and all the ids in positive_trie

View File

@ -188,4 +188,9 @@ TEST_F(NumericRangeTrieTest, SearchGreater) {
for (uint32_t i = 5, j = 0; i < pairs.size(); i++, j++) {
ASSERT_EQ(pairs[i].second, ids[j]);
}
trie->search_greater(100000, false, ids, ids_length);
ids_guard.reset(ids);
ASSERT_EQ(0, ids_length);
}