Skip to content

Commit 76b032f

Browse files
authored
Merge pull request #1499 from joto/test-large-ids-nls
Test large ids (node location store)
2 parents 165065e + b506ab9 commit 76b032f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

tests/test-node-locations.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ TEST_CASE("node locations in more than one block", "[NoDB]")
3737
{
3838
node_locations_t nl;
3939

40-
std::size_t max_id = 0;
40+
osmid_t max_id = 0;
4141

4242
SECTION("max_id 0") {
4343
max_id = 0;
@@ -63,19 +63,33 @@ TEST_CASE("node locations in more than one block", "[NoDB]")
6363
max_id = 80;
6464
}
6565

66-
for (std::size_t id = 1; id <= max_id; ++id) {
66+
for (osmid_t id = 1; id <= max_id; ++id) {
6767
nl.set(id, {id + 0.1, id + 0.2});
6868
}
6969

70-
REQUIRE(nl.size() == max_id);
70+
REQUIRE(static_cast<osmid_t>(nl.size()) == max_id);
7171

72-
for (std::size_t id = 1; id <= max_id; ++id) {
72+
for (osmid_t id = 1; id <= max_id; ++id) {
7373
auto const location = nl.get(id);
7474
REQUIRE(location.lon() == id + 0.1);
7575
REQUIRE(location.lat() == id + 0.2);
7676
}
7777
}
7878

79+
TEST_CASE("huge ids should work", "[NoDB]")
80+
{
81+
node_locations_t nl;
82+
83+
REQUIRE(nl.set(1ULL, {1.0, 9.9}));
84+
REQUIRE(nl.set(1ULL << 16U, {1.1, 9.8}));
85+
REQUIRE(nl.set(1ULL << 32U, {1.2, 9.7}));
86+
REQUIRE(nl.set(1ULL << 48U, {1.3, 9.6}));
87+
88+
REQUIRE(nl.size() == 4);
89+
90+
REQUIRE(nl.get(1ULL << 48U) == osmium::Location{1.3, 9.6});
91+
}
92+
7993
TEST_CASE("full node locations store", "[NoDB]")
8094
{
8195
node_locations_t nl{30};

0 commit comments

Comments
 (0)