diff --git a/src/numeric_range_trie.cpp b/src/numeric_range_trie.cpp index 254bffd5..be0c7f2c 100644 --- a/src/numeric_range_trie.cpp +++ b/src/numeric_range_trie.cpp @@ -20,6 +20,10 @@ void NumericTrie::insert(const int32_t& value, const uint32_t& seq_id) { void NumericTrie::search_range(const int32_t& low, const bool& low_inclusive, const int32_t& high, const bool& high_inclusive, uint32_t*& ids, uint32_t& ids_length) { + if (low >= high) { + return; + } + if (low < 0 && high >= 0) { // Have to combine the results of >low from negative_trie and search_range(-32768, true, 32768, true, ids, ids_length); + trie->search_range(32768, true, -32768, true, ids, ids_length); std::unique_ptr ids_guard(ids); + ASSERT_EQ(0, ids_length); + + trie->search_range(-32768, true, 32768, true, ids, ids_length); + ids_guard.reset(ids); + ASSERT_EQ(pairs.size(), ids_length); for (uint32_t i = 0; i < pairs.size(); i++) { ASSERT_EQ(pairs[i].second, ids[i]);