@@ -97,7 +97,7 @@ DEFINE_TEST(test_64deseroverlappingkeys) {
97
97
// Container count - 1
98
98
1 , 0 ,
99
99
// Run Flag Bitset (no runs)
100
- 0 , 0 ,
100
+ 0 ,
101
101
// Upper 16 bits of the first container
102
102
0 , 0 ,
103
103
// Cardinality - 1 of the first container
@@ -125,6 +125,56 @@ DEFINE_TEST(test_64deseroverlappingkeys) {
125
125
roaring64_bitmap_free (r);
126
126
}
127
127
}
128
+
129
+ DEFINE_TEST (test_64deseroverlappingupper32) {
130
+ // Two bitmaps, with a single array container each, at the same key (0).
131
+ // clang-format off
132
+ char simple_bitmap[] = {
133
+ // Number of 32 bit bitmaps
134
+ 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
135
+ // Top 32 bits of the first bitmap
136
+ 0 , 0 , 0 , 0 ,
137
+ // Serial Cookie
138
+ 0x3B , 0x30 ,
139
+ // Container count - 1
140
+ 0 , 0 ,
141
+ // Run Flag Bitset (not a run)
142
+ 0 ,
143
+ // Upper 16 bits of the only container
144
+ 0 , 0 ,
145
+ // Cardinality - 1 of the only container
146
+ 0 , 0 ,
147
+ // Only value of first container
148
+ 0 , 0 ,
149
+ // Top 32 bits of the second bitmap
150
+ 0 , 0 , 0 , 0 ,
151
+ // Serial Cookie
152
+ 0x3B , 0x30 ,
153
+ // Container count - 1
154
+ 0 , 0 ,
155
+ // Run Flag Bitset (not a run)
156
+ 0 ,
157
+ // Upper 16 bits of the only container
158
+ 0 , 0 ,
159
+ // Cardinality - 1 of the only container
160
+ 0 , 0 ,
161
+ // Only value of only container
162
+ 0 , 0 ,
163
+ };
164
+ // clang-format on
165
+
166
+ roaring64_bitmap_t * r = roaring64_bitmap_portable_deserialize_safe (
167
+ simple_bitmap, sizeof (simple_bitmap));
168
+ const char * reason = nullptr ;
169
+ if (r != nullptr ) {
170
+ if (roaring64_bitmap_internal_validate (r, &reason)) {
171
+ fail_msg (
172
+ " Validation must fail if a bitmap was returned, duplicate keys "
173
+ " are not allowed." );
174
+ }
175
+ roaring64_bitmap_free (r);
176
+ }
177
+ }
128
178
} // namespace
129
179
130
180
int main () {
@@ -142,6 +192,7 @@ int main() {
142
192
cmocka_unit_test (test_64mapsizetoosmall),
143
193
cmocka_unit_test (test_64mapspreadvals),
144
194
cmocka_unit_test (test_64deseroverlappingkeys),
195
+ cmocka_unit_test (test_64deseroverlappingupper32),
145
196
};
146
197
return cmocka_run_group_tests (tests, NULL , NULL );
147
198
#endif // CROARING_IS_BIG_ENDIAN
0 commit comments