Skip to content

Commit c0f0ded

Browse files
authored
Issue 457 (#458)
1 parent 4bb23e5 commit c0f0ded

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/containers/run.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void run_container_offset(const run_container_t *c,
131131
lo_cap = c->n_runs;
132132
hi_cap = 0;
133133
} else {
134-
split = c->runs[pivot].value <= top;
134+
split = c->runs[pivot].value < top;
135135
lo_cap = pivot + (split ? 1 : 0);
136136
hi_cap = c->n_runs - pivot;
137137
}

tests/toplevel_unit.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ bool roaring_iterator_sumall(uint32_t value, void *param) {
4646
*(uint32_t *)param += value;
4747
return true; // continue till the end
4848
}
49+
DEFINE_TEST(issue457) {
50+
roaring_bitmap_t *r1 = roaring_bitmap_from_range(65539, 65541, 1);
51+
roaring_bitmap_printf_describe(r1);
52+
assert_true(roaring_bitmap_get_cardinality(r1) == 2);
53+
roaring_bitmap_t *r2 = roaring_bitmap_add_offset(r1, -3);
54+
roaring_bitmap_printf_describe(r2);
55+
assert_true(roaring_bitmap_get_cardinality(r2) == 2);
56+
roaring_bitmap_printf(r2);
57+
roaring_bitmap_free(r1);
58+
roaring_bitmap_free(r2);
59+
}
4960

5061
DEFINE_TEST(issue429) {
5162
// This is a memory leak test, so we don't need to check the results.
@@ -4440,6 +4451,7 @@ int main() {
44404451
tellmeall();
44414452

44424453
const struct CMUnitTest tests[] = {
4454+
cmocka_unit_test(issue457),
44434455
cmocka_unit_test(convert_to_bitset),
44444456
cmocka_unit_test(issue440),
44454457
cmocka_unit_test(issue436),

0 commit comments

Comments
 (0)