Skip to content

Commit 4acdcfd

Browse files
committed
Fix bug in members database test case
The members list has to be sorted to use equal_range on it. Fixes #351
1 parent 04506b2 commit 4acdcfd

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

include/osmium/relations/members_database.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,11 @@ namespace osmium {
267267
/**
268268
* Remove the entry with the specified member_id and relation_id
269269
* from the database. If the entry doesn't exist, nothing happens.
270+
*
271+
* @pre You have to call prepare_for_lookup() before using this.
270272
*/
271273
void remove(osmium::object_id_type member_id, osmium::object_id_type relation_id) {
274+
assert(!m_init_phase && "Call MembersDatabase::prepare_for_lookup() before calling remove().");
272275
const auto range = find(member_id);
273276

274277
if (range.empty()) {
@@ -294,6 +297,8 @@ namespace osmium {
294297
* return a pointer to it. Returns nullptr if there is no object
295298
* with that id in the database.
296299
*
300+
* @pre You have to call prepare_for_lookup() before using this.
301+
*
297302
* Complexity: Logarithmic in the number of members tracked (as
298303
* returned by size()).
299304
*/
@@ -354,6 +359,7 @@ namespace osmium {
354359
* as a parameter.
355360
* @returns true if the object was actually added, false if no
356361
* relation needed this object.
362+
* @pre You have to call prepare_for_lookup() before using this.
357363
*/
358364
template <typename TFunc>
359365
bool add(const TObject& object, TFunc&& func) {
@@ -390,6 +396,8 @@ namespace osmium {
390396
* return a pointer to it. Returns nullptr if there is no object
391397
* with that id in the database.
392398
*
399+
* @pre You have to call prepare_for_lookup() before using this.
400+
*
393401
* Complexity: Logarithmic in the number of members tracked (as
394402
* returned by size()).
395403
*/

test/t/relations/test_members_database.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ TEST_CASE("Remove non-existing object from members database doesn't do anything"
187187
}
188188
}
189189

190+
mdb.prepare_for_lookup();
191+
190192
REQUIRE(mdb.size() == 6);
191193
mdb.remove(100, 100);
192194
REQUIRE(mdb.size() == 6);

0 commit comments

Comments
 (0)