mirror of
https://github.com/typesense/typesense.git
synced 2025-05-24 07:40:35 +08:00
Add test case.
This commit is contained in:
parent
64ec856097
commit
596f77898e
@ -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 <high from positive_trie
|
||||
|
||||
|
@ -30,9 +30,14 @@ TEST_F(NumericRangeTrieTest, SearchRange) {
|
||||
uint32_t* ids = nullptr;
|
||||
uint32_t ids_length = 0;
|
||||
|
||||
trie->search_range(-32768, true, 32768, true, ids, ids_length);
|
||||
trie->search_range(32768, true, -32768, true, ids, ids_length);
|
||||
std::unique_ptr<uint32_t[]> 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]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user