Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ test: \
test_significant_tags \
test_sorted_node_store \
test_sorted_way_store \
test_osm_store \
test_tile_coordinates_set

test_append_vector: \
Expand Down Expand Up @@ -188,6 +189,10 @@ test_options_parser: \
test/options_parser.test.o
$(CXX) $(CXXFLAGS) -o test.options_parser $^ $(INC) $(LIB) $(LDFLAGS) && ./test.options_parser

test_osm_store: \
test/osm_store.test.o
$(CXX) $(CXXFLAGS) -o test.osm_store $^ $(INC) $(LIB) $(LDFLAGS) && ./test.osm_store

test_pooled_string: \
src/mmap_allocator.o \
src/pooled_string.o \
Expand Down
4 changes: 2 additions & 2 deletions include/osm_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ class UsedWays {
// Mark a way as used
void insert(WayID wayid) {
std::lock_guard<std::mutex> lock(mutex);
if (wayid>usedList.size()) usedList.resize(wayid+256);
if (wayid>=usedList.size()) usedList.resize(wayid+256);
usedList[wayid] = true;
}

// See if a way is used
bool at(WayID wayid) const {
return (wayid>usedList.size()) ? false : usedList[wayid];
return (wayid>=usedList.size()) ? false : usedList[wayid];
}

void clear() {
Expand Down
27 changes: 27 additions & 0 deletions test/osm_store.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
#include "external/minunit.h"
#include "osm_store.h"

MU_TEST(test_usedways_grows_for_first_index) {
UsedWays usedWays;
usedWays.insert(0);
mu_check(usedWays.at(0));
}

MU_TEST(test_usedways_grows_at_current_size) {
UsedWays usedWays;
usedWays.insert(0);
usedWays.insert(256);
mu_check(usedWays.at(256));
}

MU_TEST_SUITE(test_suite_osm_store) {
MU_RUN_TEST(test_usedways_grows_for_first_index);
MU_RUN_TEST(test_usedways_grows_at_current_size);
}

int main() {
MU_RUN_SUITE(test_suite_osm_store);
MU_REPORT();
return MU_EXIT_CODE;
}
Loading