1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
diff --git a/include/mdds/flat_segment_tree_def.inl b/include/mdds/flat_segment_tree_def.inl
index 58de366..00cc1c6 100644
--- a/include/mdds/flat_segment_tree_def.inl
+++ b/include/mdds/flat_segment_tree_def.inl
@@ -778,7 +778,7 @@ bool flat_segment_tree<_Key, _Value>::adjust_segment_range(key_type& start_key,
// Invalid order of segment range.
return false;
- if (end_key < m_left_leaf->value_leaf.key || start_key > m_right_leaf->value_leaf.key)
+ if (end_key < m_left_leaf->value_leaf.key || start_key >= m_right_leaf->value_leaf.key)
// The new segment does not overlap the current interval.
return false;
diff --git a/src/flat_segment_tree_test.cpp b/src/flat_segment_tree_test.cpp
index bb29918..b94f0fd 100644
--- a/src/flat_segment_tree_test.cpp
+++ b/src/flat_segment_tree_test.cpp
@@ -1986,6 +1986,22 @@ void fst_test_insert_out_of_bound()
pos = ret.first;
}
+void fst_test_insert_out_of_bound_2()
+{
+ stack_printer __stack_printer__("::fst_test_insert_out_of_bound_2");
+
+ typedef flat_segment_tree<int, bool> db_type;
+ db_type db(0, 256, false);
+
+ // The range is entirely out-of-bound, but the start range equals the
+ // upper bound of the valid range.
+ auto ret = db.insert_back(256, 1024, true);
+
+ // Insertion never took place.
+ assert(ret.first == db.end());
+ assert(!ret.second);
+}
+
void fst_test_segment_iterator()
{
stack_printer __stack_printer__("::fst_test_segment_iterator");
@@ -2115,6 +2131,7 @@ int main (int argc, char **argv)
fst_test_assignment();
fst_test_non_numeric_value();
fst_test_insert_out_of_bound();
+ fst_test_insert_out_of_bound_2();
fst_test_segment_iterator();
}
|