From 06b46ab96100cba9b99022ded1daa5e713efdb55 Mon Sep 17 00:00:00 2001 From: Harpreet Sangar Date: Mon, 29 May 2023 16:30:12 +0530 Subject: [PATCH] Add test case. --- src/numeric_range_trie.cpp | 5 ++++- test/numeric_range_trie_test.cpp | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/numeric_range_trie.cpp b/src/numeric_range_trie.cpp index 50cf3315..53090b5d 100644 --- a/src/numeric_range_trie.cpp +++ b/src/numeric_range_trie.cpp @@ -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 diff --git a/test/numeric_range_trie_test.cpp b/test/numeric_range_trie_test.cpp index 690209a8..bc47f35a 100644 --- a/test/numeric_range_trie_test.cpp +++ b/test/numeric_range_trie_test.cpp @@ -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); }