pull in latest osmcode/libosmium changes
This commit is contained in:
+56
-32
@@ -8,6 +8,7 @@
|
||||
|
||||
message(STATUS "Configuring unit tests")
|
||||
|
||||
include(CMakeParseArguments)
|
||||
include_directories(include)
|
||||
|
||||
add_library(testlib STATIC test_main.cpp)
|
||||
@@ -19,40 +20,62 @@ set(ALL_TESTS "")
|
||||
#
|
||||
# Define function for adding tests
|
||||
#
|
||||
# Call with parameters:
|
||||
# TGROUP - test group (directory)
|
||||
# TNAME - name of test
|
||||
# ARGV2 - flag to enable test (optional)
|
||||
# ARGV3 - libraries to add (optional)
|
||||
# add_unit_tests(group name [ENABLE_IF bool] [LIBS libs] [LABELS labels])
|
||||
#
|
||||
# group - test group (directory)
|
||||
# name - name of test
|
||||
# bool - boolean variable telling whether the test should be run (optional)
|
||||
# libs - lib or libs that should be used when compiling test (optional)
|
||||
# labels - additional labels this test should get (optional)
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
function(add_unit_test TGROUP TNAME)
|
||||
set(ALL_TESTS "${ALL_TESTS};${TGROUP}/${TNAME}" PARENT_SCOPE)
|
||||
if((${ARGC} EQUAL 2) OR (${ARGV2}))
|
||||
function(add_unit_test _tgroup _tname)
|
||||
set(_testid "${_tgroup}_${_tname}")
|
||||
set(_tpath "${_tgroup}/${_tname}")
|
||||
|
||||
set(ALL_TESTS "${ALL_TESTS};${_tpath}" PARENT_SCOPE)
|
||||
|
||||
cmake_parse_arguments(_param "" "ENABLE_IF" "LIBS;LABELS" ${ARGN})
|
||||
|
||||
if(Osmium_DEBUG)
|
||||
message("${_testid} ENABLE_IF=[${_param_ENABLE_IF}] LIBS=[${_param_LIBS}] LABELS=[${_param_LABELS}]")
|
||||
endif()
|
||||
|
||||
if((NOT(DEFINED _param_ENABLE_IF)) OR (_param_ENABLE_IF))
|
||||
if(Osmium_DEBUG)
|
||||
message("Adding test ${TGROUP}/${TNAME}")
|
||||
message("Adding test: ${_tpath}")
|
||||
endif()
|
||||
set(TESTNAME "${TGROUP}_${TNAME}")
|
||||
add_executable(${TESTNAME} t/${TGROUP}/${TNAME}.cpp)
|
||||
target_link_libraries(${TESTNAME} testlib)
|
||||
if((${ARGV2}) AND (DEFINED ARGV3))
|
||||
add_executable(${_testid} t/${_tpath}.cpp)
|
||||
target_link_libraries(${_testid} testlib)
|
||||
|
||||
if(DEFINED _param_LIBS)
|
||||
if(Osmium_DEBUG)
|
||||
message(" Adding libs ${ARGV3}")
|
||||
message(" Adding libs: ${_param_LIBS}")
|
||||
endif()
|
||||
target_link_libraries(${TESTNAME} ${ARGV3})
|
||||
target_link_libraries(${_testid} ${_param_LIBS})
|
||||
endif()
|
||||
add_test(NAME ${TESTNAME}
|
||||
|
||||
add_test(NAME ${_testid}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${TESTNAME}
|
||||
COMMAND ${_testid}
|
||||
)
|
||||
set_tests_properties(${TESTNAME} PROPERTIES
|
||||
LABELS "unit;fast;${TGROUP}"
|
||||
|
||||
set(_labels "unit;fast;${_tgroup}")
|
||||
if(DEFINED _param_LABELS)
|
||||
if(Osmium_DEBUG)
|
||||
message(" Adding labels: ${_param_LABELS}")
|
||||
endif()
|
||||
set(_labels "${_labels};${_param_LABELS}")
|
||||
endif()
|
||||
|
||||
set_tests_properties(${_testid} PROPERTIES
|
||||
LABELS "${_labels}"
|
||||
ENVIRONMENT "OSMIUM_TEST_DATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
else()
|
||||
message("Skipped test ${TGROUP}/${TNAME} because a dependency was not found")
|
||||
message("Skipped test ${_tpath} because a dependency was not found")
|
||||
set(OSMIUM_SKIPPED_TESTS
|
||||
"${OSMIUM_SKIPPED_TESTS} ${TGROUP}/${TNAME}"
|
||||
"${OSMIUM_SKIPPED_TESTS} ${_tpath}"
|
||||
CACHE STRING "Tests that were skipped because of missing dependecies")
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -85,31 +108,32 @@ else()
|
||||
set(GEOS_AND_PROJ_FOUND FALSE)
|
||||
endif()
|
||||
add_unit_test(geom test_factory_with_projection
|
||||
${GEOS_AND_PROJ_FOUND}
|
||||
"${GEOS_LIBRARY};${PROJ_LIBRARY}")
|
||||
ENABLE_IF ${GEOS_AND_PROJ_FOUND}
|
||||
LIBS ${GEOS_LIBRARY} ${PROJ_LIBRARY})
|
||||
|
||||
add_unit_test(geom test_geojson)
|
||||
add_unit_test(geom test_geos ${GEOS_FOUND} ${GEOS_LIBRARY})
|
||||
add_unit_test(geom test_geos_wkb ${GEOS_FOUND} ${GEOS_LIBRARY})
|
||||
add_unit_test(geom test_geos ENABLE_IF ${GEOS_FOUND} LIBS ${GEOS_LIBRARY})
|
||||
add_unit_test(geom test_geos_wkb ENABLE_IF ${GEOS_FOUND} LIBS ${GEOS_LIBRARY})
|
||||
add_unit_test(geom test_mercator)
|
||||
add_unit_test(geom test_ogr ${GDAL_FOUND} ${GDAL_LIBRARY})
|
||||
add_unit_test(geom test_projection ${PROJ_FOUND} ${PROJ_LIBRARY})
|
||||
add_unit_test(geom test_ogr ENABLE_IF ${GDAL_FOUND} LIBS ${GDAL_LIBRARY})
|
||||
add_unit_test(geom test_projection ENABLE_IF ${PROJ_FOUND} LIBS ${PROJ_LIBRARY})
|
||||
add_unit_test(geom test_wkb)
|
||||
add_unit_test(geom test_wkt)
|
||||
|
||||
add_unit_test(index test_id_to_location ${SPARSEHASH_FOUND})
|
||||
add_unit_test(index test_id_to_location ENABLE_IF ${SPARSEHASH_FOUND})
|
||||
add_unit_test(index test_typed_mmap)
|
||||
add_unit_test(index test_typed_mmap_grow LABELS "fails_on_windows")
|
||||
|
||||
add_unit_test(io test_bzip2 ${BZIP2_FOUND} ${BZIP2_LIBRARIES})
|
||||
add_unit_test(io test_bzip2 ENABLE_IF ${BZIP2_FOUND} LIBS ${BZIP2_LIBRARIES})
|
||||
add_unit_test(io test_file_formats)
|
||||
add_unit_test(io test_reader TRUE "${OSMIUM_XML_LIBRARIES}")
|
||||
add_unit_test(io test_output_iterator ${Threads_FOUND} ${CMAKE_THREAD_LIBS_INIT})
|
||||
add_unit_test(io test_reader LIBS "${OSMIUM_XML_LIBRARIES}")
|
||||
add_unit_test(io test_output_iterator ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
add_unit_test(tags test_filter)
|
||||
add_unit_test(tags test_operators)
|
||||
add_unit_test(tags test_tag_list)
|
||||
|
||||
add_unit_test(thread test_pool ${Threads_FOUND} ${CMAKE_THREAD_LIBS_INIT})
|
||||
add_unit_test(thread test_pool ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
add_unit_test(util test_cast_with_assert)
|
||||
add_unit_test(util test_double)
|
||||
|
||||
+96
-2
@@ -285,7 +285,6 @@ TEST_CASE("Reading OSM XML 121") {
|
||||
}, osmium::gzip_error);
|
||||
}
|
||||
|
||||
#if 0
|
||||
SECTION("Using Reader") {
|
||||
REQUIRE_THROWS_AS({
|
||||
osmium::io::Reader reader(filename("121-truncated_gzip_file", "osm.gz"));
|
||||
@@ -294,10 +293,105 @@ TEST_CASE("Reading OSM XML 121") {
|
||||
reader.close();
|
||||
}, osmium::gzip_error);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// =============================================
|
||||
|
||||
TEST_CASE("Reading OSM XML 122") {
|
||||
|
||||
SECTION("Direct") {
|
||||
REQUIRE_THROWS_AS( {
|
||||
read_xml("122-no_osm_element");
|
||||
}, osmium::xml_error);
|
||||
}
|
||||
|
||||
SECTION("Using Reader") {
|
||||
REQUIRE_THROWS_AS({
|
||||
osmium::io::Reader reader(filename("122-no_osm_element"));
|
||||
osmium::io::Header header = reader.header();
|
||||
osmium::memory::Buffer buffer = reader.read();
|
||||
reader.close();
|
||||
}, osmium::xml_error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// =============================================
|
||||
|
||||
TEST_CASE("Reading OSM XML 140") {
|
||||
|
||||
SECTION("Using Reader") {
|
||||
osmium::io::Reader reader(filename("140-unicode"));
|
||||
osmium::memory::Buffer buffer = reader.read();
|
||||
reader.close();
|
||||
|
||||
int count = 0;
|
||||
for (auto it = buffer.begin<osmium::Node>(); it != buffer.end<osmium::Node>(); ++it) {
|
||||
++count;
|
||||
REQUIRE(it->id() == count);
|
||||
const osmium::TagList& t = it->tags();
|
||||
|
||||
const char* uc = t["unicode_char"];
|
||||
|
||||
auto len = atoi(t["unicode_utf8_length"]);
|
||||
REQUIRE(len == strlen(uc));
|
||||
|
||||
REQUIRE(!strcmp(uc, t["unicode_xml"]));
|
||||
|
||||
// workaround for missing support for u8 string literals on Windows
|
||||
#if !defined(_MSC_VER)
|
||||
switch (count) {
|
||||
case 1:
|
||||
REQUIRE(!strcmp(uc, u8"a"));
|
||||
break;
|
||||
case 2:
|
||||
REQUIRE(!strcmp(uc, u8"\u00e4"));
|
||||
break;
|
||||
case 3:
|
||||
REQUIRE(!strcmp(uc, u8"\u30dc"));
|
||||
break;
|
||||
case 4:
|
||||
REQUIRE(!strcmp(uc, u8"\U0001d11e"));
|
||||
break;
|
||||
case 5:
|
||||
REQUIRE(!strcmp(uc, u8"\U0001f6eb"));
|
||||
break;
|
||||
default:
|
||||
REQUIRE(false); // should not be here
|
||||
}
|
||||
#endif
|
||||
}
|
||||
REQUIRE(count == 5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// =============================================
|
||||
|
||||
TEST_CASE("Reading OSM XML 141") {
|
||||
|
||||
SECTION("Using Reader") {
|
||||
osmium::io::Reader reader(filename("141-entities"));
|
||||
osmium::memory::Buffer buffer = reader.read();
|
||||
reader.close();
|
||||
REQUIRE(buffer.committed() > 0);
|
||||
REQUIRE(buffer.get<osmium::memory::Item>(0).type() == osmium::item_type::node);
|
||||
|
||||
const osmium::Node& node = buffer.get<osmium::Node>(0);
|
||||
const osmium::TagList& tags = node.tags();
|
||||
|
||||
REQUIRE(!strcmp(tags["less-than"], "<"));
|
||||
REQUIRE(!strcmp(tags["greater-than"], ">"));
|
||||
REQUIRE(!strcmp(tags["apostrophe"], "'"));
|
||||
REQUIRE(!strcmp(tags["ampersand"], "&"));
|
||||
REQUIRE(!strcmp(tags["quote"], "\""));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// =============================================
|
||||
|
||||
TEST_CASE("Reading OSM XML 200") {
|
||||
|
||||
+16
-16
@@ -4,22 +4,22 @@
|
||||
|
||||
TEST_CASE("area_id") {
|
||||
|
||||
SECTION("object_id_to_area_id_conversion") {
|
||||
REQUIRE( 46 == osmium::object_id_to_area_id( 23, osmium::item_type::way));
|
||||
REQUIRE( 47 == osmium::object_id_to_area_id( 23, osmium::item_type::relation));
|
||||
REQUIRE( 0 == osmium::object_id_to_area_id( 0, osmium::item_type::way));
|
||||
REQUIRE( 1 == osmium::object_id_to_area_id( 0, osmium::item_type::relation));
|
||||
REQUIRE(-24 == osmium::object_id_to_area_id(-12, osmium::item_type::way));
|
||||
REQUIRE(-25 == osmium::object_id_to_area_id(-12, osmium::item_type::relation));
|
||||
}
|
||||
SECTION("object_id_to_area_id_conversion") {
|
||||
REQUIRE( 46 == osmium::object_id_to_area_id( 23, osmium::item_type::way));
|
||||
REQUIRE( 47 == osmium::object_id_to_area_id( 23, osmium::item_type::relation));
|
||||
REQUIRE( 0 == osmium::object_id_to_area_id( 0, osmium::item_type::way));
|
||||
REQUIRE( 1 == osmium::object_id_to_area_id( 0, osmium::item_type::relation));
|
||||
REQUIRE(-24 == osmium::object_id_to_area_id(-12, osmium::item_type::way));
|
||||
REQUIRE(-25 == osmium::object_id_to_area_id(-12, osmium::item_type::relation));
|
||||
}
|
||||
|
||||
SECTION("area_id_to_object_id_conversion") {
|
||||
REQUIRE( 23 == osmium::area_id_to_object_id( 46));
|
||||
REQUIRE( 23 == osmium::area_id_to_object_id( 47));
|
||||
REQUIRE( 0 == osmium::area_id_to_object_id( 0));
|
||||
REQUIRE( 0 == osmium::area_id_to_object_id( 1));
|
||||
REQUIRE(-12 == osmium::area_id_to_object_id(-24));
|
||||
REQUIRE(-12 == osmium::area_id_to_object_id(-25));
|
||||
}
|
||||
SECTION("area_id_to_object_id_conversion") {
|
||||
REQUIRE( 23 == osmium::area_id_to_object_id( 46));
|
||||
REQUIRE( 23 == osmium::area_id_to_object_id( 47));
|
||||
REQUIRE( 0 == osmium::area_id_to_object_id( 0));
|
||||
REQUIRE( 0 == osmium::area_id_to_object_id( 1));
|
||||
REQUIRE(-12 == osmium::area_id_to_object_id(-24));
|
||||
REQUIRE(-12 == osmium::area_id_to_object_id(-25));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+84
-84
@@ -6,110 +6,110 @@ using osmium::area::detail::NodeRefSegment;
|
||||
|
||||
TEST_CASE("NodeRefSegmentClass") {
|
||||
|
||||
SECTION("instantiation_with_default_parameters") {
|
||||
NodeRefSegment s;
|
||||
REQUIRE(s.first().ref() == 0);
|
||||
REQUIRE(s.first().location() == osmium::Location());
|
||||
REQUIRE(s.second().ref() == 0);
|
||||
REQUIRE(s.second().location() == osmium::Location());
|
||||
}
|
||||
SECTION("instantiation_with_default_parameters") {
|
||||
NodeRefSegment s;
|
||||
REQUIRE(s.first().ref() == 0);
|
||||
REQUIRE(s.first().location() == osmium::Location());
|
||||
REQUIRE(s.second().ref() == 0);
|
||||
REQUIRE(s.second().location() == osmium::Location());
|
||||
}
|
||||
|
||||
SECTION("instantiation") {
|
||||
osmium::NodeRef nr1(1, { 1.2, 3.4 });
|
||||
osmium::NodeRef nr2(2, { 1.4, 3.1 });
|
||||
osmium::NodeRef nr3(3, { 1.2, 3.6 });
|
||||
osmium::NodeRef nr4(4, { 1.2, 3.7 });
|
||||
SECTION("instantiation") {
|
||||
osmium::NodeRef nr1(1, { 1.2, 3.4 });
|
||||
osmium::NodeRef nr2(2, { 1.4, 3.1 });
|
||||
osmium::NodeRef nr3(3, { 1.2, 3.6 });
|
||||
osmium::NodeRef nr4(4, { 1.2, 3.7 });
|
||||
|
||||
NodeRefSegment s1(nr1, nr2, nullptr, nullptr);
|
||||
REQUIRE(s1.first().ref() == 1);
|
||||
REQUIRE(s1.second().ref() == 2);
|
||||
NodeRefSegment s1(nr1, nr2, nullptr, nullptr);
|
||||
REQUIRE(s1.first().ref() == 1);
|
||||
REQUIRE(s1.second().ref() == 2);
|
||||
|
||||
NodeRefSegment s2(nr2, nr3, nullptr, nullptr);
|
||||
REQUIRE(s2.first().ref() == 3);
|
||||
REQUIRE(s2.second().ref() == 2);
|
||||
NodeRefSegment s2(nr2, nr3, nullptr, nullptr);
|
||||
REQUIRE(s2.first().ref() == 3);
|
||||
REQUIRE(s2.second().ref() == 2);
|
||||
|
||||
NodeRefSegment s3(nr3, nr4, nullptr, nullptr);
|
||||
REQUIRE(s3.first().ref() == 3);
|
||||
REQUIRE(s3.second().ref() == 4);
|
||||
}
|
||||
NodeRefSegment s3(nr3, nr4, nullptr, nullptr);
|
||||
REQUIRE(s3.first().ref() == 3);
|
||||
REQUIRE(s3.second().ref() == 4);
|
||||
}
|
||||
|
||||
SECTION("intersection") {
|
||||
NodeRefSegment s1({ 1, {0.0, 0.0}}, { 2, {2.0, 2.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s2({ 3, {0.0, 2.0}}, { 4, {2.0, 0.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s3({ 5, {2.0, 0.0}}, { 6, {4.0, 2.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s4({ 7, {1.0, 0.0}}, { 8, {3.0, 2.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s5({ 9, {0.0, 4.0}}, {10, {4.0, 0.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s6({11, {0.0, 0.0}}, {12, {1.0, 1.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s7({13, {1.0, 1.0}}, {14, {3.0, 3.0}}, nullptr, nullptr);
|
||||
SECTION("intersection") {
|
||||
NodeRefSegment s1({ 1, {0.0, 0.0}}, { 2, {2.0, 2.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s2({ 3, {0.0, 2.0}}, { 4, {2.0, 0.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s3({ 5, {2.0, 0.0}}, { 6, {4.0, 2.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s4({ 7, {1.0, 0.0}}, { 8, {3.0, 2.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s5({ 9, {0.0, 4.0}}, {10, {4.0, 0.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s6({11, {0.0, 0.0}}, {12, {1.0, 1.0}}, nullptr, nullptr);
|
||||
NodeRefSegment s7({13, {1.0, 1.0}}, {14, {3.0, 3.0}}, nullptr, nullptr);
|
||||
|
||||
REQUIRE(calculate_intersection(s1, s2) == osmium::Location(1.0, 1.0));
|
||||
REQUIRE(calculate_intersection(s1, s3) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s2, s3) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s1, s4) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s1, s5) == osmium::Location(2.0, 2.0));
|
||||
REQUIRE(calculate_intersection(s1, s1) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s1, s6) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s1, s7) == osmium::Location());
|
||||
}
|
||||
REQUIRE(calculate_intersection(s1, s2) == osmium::Location(1.0, 1.0));
|
||||
REQUIRE(calculate_intersection(s1, s3) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s2, s3) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s1, s4) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s1, s5) == osmium::Location(2.0, 2.0));
|
||||
REQUIRE(calculate_intersection(s1, s1) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s1, s6) == osmium::Location());
|
||||
REQUIRE(calculate_intersection(s1, s7) == osmium::Location());
|
||||
}
|
||||
|
||||
SECTION("to_left_of") {
|
||||
osmium::Location loc { 2.0, 2.0 };
|
||||
SECTION("to_left_of") {
|
||||
osmium::Location loc { 2.0, 2.0 };
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {0.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {4.0, 0.0}}, {1, {4.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 0.0}}, {1, {1.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {0.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {4.0, 0.0}}, {1, {4.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 0.0}}, {1, {1.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {1.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {2.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {3.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {4.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {4.0, 3.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {1.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {2.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {3.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {4.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {4.0, 3.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 3.0}}, {1, {2.0, 0.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 3.0}}, {1, {3.0, 1.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 3.0}}, {1, {3.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 3.0}}, {1, {2.0, 0.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 3.0}}, {1, {3.0, 1.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 3.0}}, {1, {3.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {2.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {2.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {2.0, 0.0}}, {1, {2.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {2.0, 0.0}}, {1, {2.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {2.0, 2.0}}, {1, {2.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {2.0, 0.0}}, {1, {2.0, 4.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {2.0, 0.0}}, {1, {2.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {2.0, 2.0}}, {1, {2.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {0.0, 1.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 0.0}}, {1, {0.0, 1.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {0.0, 1.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 0.0}}, {1, {0.0, 1.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {1.0, 3.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {2.0, 0.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {3.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {1.0, 3.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {2.0, 0.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {3.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 0.0}}, {1, {1.0, 2.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {1.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {1.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {1.0, 0.0}}, {1, {1.0, 2.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {1.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {1.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {0.0, 2.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {4.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 0.0}}, {1, {0.0, 2.0}}, nullptr, nullptr).to_left_of(loc));
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 2.0}}, {1, {4.0, 4.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 1.0}}, {1, {2.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {2.0, 2.0}}, {1, {4.0, 0.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
}
|
||||
REQUIRE(NodeRefSegment({0, {0.0, 1.0}}, {1, {2.0, 2.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
REQUIRE(NodeRefSegment({0, {2.0, 2.0}}, {1, {4.0, 0.0}}, nullptr, nullptr).to_left_of(loc) == false);
|
||||
}
|
||||
|
||||
SECTION("ordering") {
|
||||
osmium::NodeRef node_ref1(1, { 1.0, 3.0 });
|
||||
osmium::NodeRef node_ref2(2, { 1.4, 2.9 });
|
||||
osmium::NodeRef node_ref3(3, { 1.2, 3.0 });
|
||||
osmium::NodeRef node_ref4(4, { 1.2, 3.3 });
|
||||
SECTION("ordering") {
|
||||
osmium::NodeRef node_ref1(1, { 1.0, 3.0 });
|
||||
osmium::NodeRef node_ref2(2, { 1.4, 2.9 });
|
||||
osmium::NodeRef node_ref3(3, { 1.2, 3.0 });
|
||||
osmium::NodeRef node_ref4(4, { 1.2, 3.3 });
|
||||
|
||||
REQUIRE(node_ref1 < node_ref2);
|
||||
REQUIRE(node_ref2 < node_ref3);
|
||||
REQUIRE(node_ref1 < node_ref3);
|
||||
REQUIRE(node_ref1 >= node_ref1);
|
||||
REQUIRE(node_ref1 < node_ref2);
|
||||
REQUIRE(node_ref2 < node_ref3);
|
||||
REQUIRE(node_ref1 < node_ref3);
|
||||
REQUIRE(node_ref1 >= node_ref1);
|
||||
|
||||
REQUIRE( osmium::location_less()(node_ref1, node_ref2));
|
||||
REQUIRE(!osmium::location_less()(node_ref2, node_ref3));
|
||||
REQUIRE( osmium::location_less()(node_ref1, node_ref3));
|
||||
REQUIRE( osmium::location_less()(node_ref3, node_ref4));
|
||||
REQUIRE(!osmium::location_less()(node_ref1, node_ref1));
|
||||
}
|
||||
REQUIRE( osmium::location_less()(node_ref1, node_ref2));
|
||||
REQUIRE(!osmium::location_less()(node_ref2, node_ref3));
|
||||
REQUIRE( osmium::location_less()(node_ref1, node_ref3));
|
||||
REQUIRE( osmium::location_less()(node_ref3, node_ref4));
|
||||
REQUIRE(!osmium::location_less()(node_ref1, node_ref1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+69
-59
@@ -7,75 +7,85 @@
|
||||
|
||||
TEST_CASE("Box") {
|
||||
|
||||
SECTION("instantiation") {
|
||||
osmium::Box b;
|
||||
REQUIRE(!b);
|
||||
REQUIRE(!b.bottom_left());
|
||||
REQUIRE(!b.top_right());
|
||||
REQUIRE_THROWS_AS(b.size(), osmium::invalid_location);
|
||||
}
|
||||
SECTION("instantiation") {
|
||||
osmium::Box b;
|
||||
REQUIRE(!b);
|
||||
REQUIRE(!b.bottom_left());
|
||||
REQUIRE(!b.top_right());
|
||||
REQUIRE_THROWS_AS(b.size(), osmium::invalid_location);
|
||||
}
|
||||
|
||||
SECTION("instantiation_and_extend_with_undefined") {
|
||||
osmium::Box b;
|
||||
REQUIRE(!b);
|
||||
b.extend(osmium::Location());
|
||||
REQUIRE(!b.bottom_left());
|
||||
REQUIRE(!b.top_right());
|
||||
}
|
||||
SECTION("instantiation_and_extend_with_undefined") {
|
||||
osmium::Box b;
|
||||
REQUIRE(!b);
|
||||
b.extend(osmium::Location());
|
||||
REQUIRE(!b.bottom_left());
|
||||
REQUIRE(!b.top_right());
|
||||
}
|
||||
|
||||
SECTION("instantiation_and_extend") {
|
||||
osmium::Box b;
|
||||
b.extend(osmium::Location(1.2, 3.4));
|
||||
REQUIRE(!!b);
|
||||
REQUIRE(!!b.bottom_left());
|
||||
REQUIRE(!!b.top_right());
|
||||
b.extend(osmium::Location(3.4, 4.5));
|
||||
b.extend(osmium::Location(5.6, 7.8));
|
||||
REQUIRE(b.bottom_left() == osmium::Location(1.2, 3.4));
|
||||
REQUIRE(b.top_right() == osmium::Location(5.6, 7.8));
|
||||
SECTION("instantiation_and_extend") {
|
||||
osmium::Box b;
|
||||
osmium::Location loc1 { 1.2, 3.4 };
|
||||
b.extend(loc1);
|
||||
REQUIRE(!!b);
|
||||
REQUIRE(!!b.bottom_left());
|
||||
REQUIRE(!!b.top_right());
|
||||
REQUIRE(b.contains(loc1));
|
||||
|
||||
// extend with undefined doesn't change anything
|
||||
b.extend(osmium::Location());
|
||||
REQUIRE(b.bottom_left() == osmium::Location(1.2, 3.4));
|
||||
REQUIRE(b.top_right() == osmium::Location(5.6, 7.8));
|
||||
}
|
||||
osmium::Location loc2 { 3.4, 4.5 };
|
||||
osmium::Location loc3 { 5.6, 7.8 };
|
||||
|
||||
SECTION("output_defined") {
|
||||
osmium::Box b;
|
||||
b.extend(osmium::Location(1.2, 3.4));
|
||||
b.extend(osmium::Location(5.6, 7.8));
|
||||
std::stringstream out;
|
||||
out << b;
|
||||
REQUIRE(out.str() == "(1.2,3.4,5.6,7.8)");
|
||||
REQUIRE(b.size() == Approx(19.36).epsilon(0.000001));
|
||||
}
|
||||
b.extend(loc2);
|
||||
b.extend(loc3);
|
||||
REQUIRE(b.bottom_left() == osmium::Location(1.2, 3.4));
|
||||
REQUIRE(b.top_right() == osmium::Location(5.6, 7.8));
|
||||
|
||||
SECTION("output_undefined") {
|
||||
osmium::Box b;
|
||||
std::stringstream out;
|
||||
out << b;
|
||||
REQUIRE(out.str() == "(undefined)");
|
||||
}
|
||||
// extend with undefined doesn't change anything
|
||||
b.extend(osmium::Location());
|
||||
REQUIRE(b.bottom_left() == osmium::Location(1.2, 3.4));
|
||||
REQUIRE(b.top_right() == osmium::Location(5.6, 7.8));
|
||||
|
||||
SECTION("box_inside_box") {
|
||||
osmium::Box outer;
|
||||
outer.extend(osmium::Location(1, 1));
|
||||
outer.extend(osmium::Location(10, 10));
|
||||
REQUIRE(b.contains(loc1));
|
||||
REQUIRE(b.contains(loc2));
|
||||
REQUIRE(b.contains(loc3));
|
||||
}
|
||||
|
||||
osmium::Box inner;
|
||||
inner.extend(osmium::Location(2, 2));
|
||||
inner.extend(osmium::Location(4, 4));
|
||||
SECTION("output_defined") {
|
||||
osmium::Box b;
|
||||
b.extend(osmium::Location(1.2, 3.4));
|
||||
b.extend(osmium::Location(5.6, 7.8));
|
||||
std::stringstream out;
|
||||
out << b;
|
||||
REQUIRE(out.str() == "(1.2,3.4,5.6,7.8)");
|
||||
REQUIRE(b.size() == Approx(19.36).epsilon(0.000001));
|
||||
}
|
||||
|
||||
osmium::Box overlap;
|
||||
overlap.extend(osmium::Location(3, 3));
|
||||
overlap.extend(osmium::Location(5, 5));
|
||||
SECTION("output_undefined") {
|
||||
osmium::Box b;
|
||||
std::stringstream out;
|
||||
out << b;
|
||||
REQUIRE(out.str() == "(undefined)");
|
||||
}
|
||||
|
||||
REQUIRE( osmium::geom::contains(inner, outer));
|
||||
REQUIRE(!osmium::geom::contains(outer, inner));
|
||||
SECTION("box_inside_box") {
|
||||
osmium::Box outer;
|
||||
outer.extend(osmium::Location(1, 1));
|
||||
outer.extend(osmium::Location(10, 10));
|
||||
|
||||
REQUIRE(!osmium::geom::contains(overlap, inner));
|
||||
REQUIRE(!osmium::geom::contains(inner, overlap));
|
||||
}
|
||||
osmium::Box inner;
|
||||
inner.extend(osmium::Location(2, 2));
|
||||
inner.extend(osmium::Location(4, 4));
|
||||
|
||||
osmium::Box overlap;
|
||||
overlap.extend(osmium::Location(3, 3));
|
||||
overlap.extend(osmium::Location(5, 5));
|
||||
|
||||
REQUIRE( osmium::geom::contains(inner, outer));
|
||||
REQUIRE(!osmium::geom::contains(outer, inner));
|
||||
|
||||
REQUIRE(!osmium::geom::contains(overlap, inner));
|
||||
REQUIRE(!osmium::geom::contains(inner, overlap));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+18
-18
@@ -4,28 +4,28 @@
|
||||
|
||||
TEST_CASE("entity_bits") {
|
||||
|
||||
SECTION("can_be_set_and_checked") {
|
||||
osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::node | osmium::osm_entity_bits::way;
|
||||
REQUIRE(entities == (osmium::osm_entity_bits::node | osmium::osm_entity_bits::way));
|
||||
SECTION("can_be_set_and_checked") {
|
||||
osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::node | osmium::osm_entity_bits::way;
|
||||
REQUIRE(entities == (osmium::osm_entity_bits::node | osmium::osm_entity_bits::way));
|
||||
|
||||
entities |= osmium::osm_entity_bits::relation;
|
||||
REQUIRE((entities & osmium::osm_entity_bits::object));
|
||||
entities |= osmium::osm_entity_bits::relation;
|
||||
REQUIRE((entities & osmium::osm_entity_bits::object));
|
||||
|
||||
entities |= osmium::osm_entity_bits::area;
|
||||
REQUIRE(entities == osmium::osm_entity_bits::object);
|
||||
entities |= osmium::osm_entity_bits::area;
|
||||
REQUIRE(entities == osmium::osm_entity_bits::object);
|
||||
|
||||
REQUIRE(! (entities & osmium::osm_entity_bits::changeset));
|
||||
REQUIRE(! (entities & osmium::osm_entity_bits::changeset));
|
||||
|
||||
entities &= osmium::osm_entity_bits::node;
|
||||
REQUIRE((entities & osmium::osm_entity_bits::node));
|
||||
REQUIRE(! (entities & osmium::osm_entity_bits::way));
|
||||
REQUIRE(entities == osmium::osm_entity_bits::node);
|
||||
entities &= osmium::osm_entity_bits::node;
|
||||
REQUIRE((entities & osmium::osm_entity_bits::node));
|
||||
REQUIRE(! (entities & osmium::osm_entity_bits::way));
|
||||
REQUIRE(entities == osmium::osm_entity_bits::node);
|
||||
|
||||
REQUIRE(osmium::osm_entity_bits::node == osmium::osm_entity_bits::from_item_type(osmium::item_type::node));
|
||||
REQUIRE(osmium::osm_entity_bits::way == osmium::osm_entity_bits::from_item_type(osmium::item_type::way));
|
||||
REQUIRE(osmium::osm_entity_bits::relation == osmium::osm_entity_bits::from_item_type(osmium::item_type::relation));
|
||||
REQUIRE(osmium::osm_entity_bits::changeset == osmium::osm_entity_bits::from_item_type(osmium::item_type::changeset));
|
||||
REQUIRE(osmium::osm_entity_bits::area == osmium::osm_entity_bits::from_item_type(osmium::item_type::area));
|
||||
}
|
||||
REQUIRE(osmium::osm_entity_bits::node == osmium::osm_entity_bits::from_item_type(osmium::item_type::node));
|
||||
REQUIRE(osmium::osm_entity_bits::way == osmium::osm_entity_bits::from_item_type(osmium::item_type::way));
|
||||
REQUIRE(osmium::osm_entity_bits::relation == osmium::osm_entity_bits::from_item_type(osmium::item_type::relation));
|
||||
REQUIRE(osmium::osm_entity_bits::changeset == osmium::osm_entity_bits::from_item_type(osmium::item_type::changeset));
|
||||
REQUIRE(osmium::osm_entity_bits::area == osmium::osm_entity_bits::from_item_type(osmium::item_type::area));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+117
-117
@@ -10,145 +10,145 @@ TEST_CASE("Location") {
|
||||
// fails on MSVC and doesn't really matter
|
||||
// static_assert(std::is_literal_type<osmium::Location>::value, "osmium::Location not literal type");
|
||||
|
||||
SECTION("instantiation_with_default_parameters") {
|
||||
osmium::Location loc;
|
||||
REQUIRE(!loc);
|
||||
REQUIRE_THROWS_AS(loc.lon(), osmium::invalid_location);
|
||||
REQUIRE_THROWS_AS(loc.lat(), osmium::invalid_location);
|
||||
}
|
||||
SECTION("instantiation_with_default_parameters") {
|
||||
osmium::Location loc;
|
||||
REQUIRE(!loc);
|
||||
REQUIRE_THROWS_AS(loc.lon(), osmium::invalid_location);
|
||||
REQUIRE_THROWS_AS(loc.lat(), osmium::invalid_location);
|
||||
}
|
||||
|
||||
SECTION("instantiation_with_double_parameters") {
|
||||
osmium::Location loc1(1.2, 4.5);
|
||||
REQUIRE(!!loc1);
|
||||
REQUIRE(12000000 == loc1.x());
|
||||
REQUIRE(45000000 == loc1.y());
|
||||
REQUIRE(1.2 == loc1.lon());
|
||||
REQUIRE(4.5 == loc1.lat());
|
||||
SECTION("instantiation_with_double_parameters") {
|
||||
osmium::Location loc1(1.2, 4.5);
|
||||
REQUIRE(!!loc1);
|
||||
REQUIRE(12000000 == loc1.x());
|
||||
REQUIRE(45000000 == loc1.y());
|
||||
REQUIRE(1.2 == loc1.lon());
|
||||
REQUIRE(4.5 == loc1.lat());
|
||||
|
||||
osmium::Location loc2(loc1);
|
||||
REQUIRE(4.5 == loc2.lat());
|
||||
osmium::Location loc2(loc1);
|
||||
REQUIRE(4.5 == loc2.lat());
|
||||
|
||||
osmium::Location loc3 = loc1;
|
||||
REQUIRE(4.5 == loc3.lat());
|
||||
}
|
||||
osmium::Location loc3 = loc1;
|
||||
REQUIRE(4.5 == loc3.lat());
|
||||
}
|
||||
|
||||
SECTION("instantiation_with_double_parameters_constructor_with_universal_initializer") {
|
||||
osmium::Location loc { 2.2, 3.3 };
|
||||
REQUIRE(2.2 == loc.lon());
|
||||
REQUIRE(3.3 == loc.lat());
|
||||
}
|
||||
SECTION("instantiation_with_double_parameters_constructor_with_universal_initializer") {
|
||||
osmium::Location loc { 2.2, 3.3 };
|
||||
REQUIRE(2.2 == loc.lon());
|
||||
REQUIRE(3.3 == loc.lat());
|
||||
}
|
||||
|
||||
SECTION("instantiation_with_double_parameters_constructor_with_initializer_list") {
|
||||
osmium::Location loc({ 4.4, 5.5 });
|
||||
REQUIRE(4.4 == loc.lon());
|
||||
REQUIRE(5.5 == loc.lat());
|
||||
}
|
||||
SECTION("instantiation_with_double_parameters_constructor_with_initializer_list") {
|
||||
osmium::Location loc({ 4.4, 5.5 });
|
||||
REQUIRE(4.4 == loc.lon());
|
||||
REQUIRE(5.5 == loc.lat());
|
||||
}
|
||||
|
||||
SECTION("instantiation_with_double_parameters_operator_equal") {
|
||||
osmium::Location loc = { 5.5, 6.6 };
|
||||
REQUIRE(5.5 == loc.lon());
|
||||
REQUIRE(6.6 == loc.lat());
|
||||
}
|
||||
SECTION("instantiation_with_double_parameters_operator_equal") {
|
||||
osmium::Location loc = { 5.5, 6.6 };
|
||||
REQUIRE(5.5 == loc.lon());
|
||||
REQUIRE(6.6 == loc.lat());
|
||||
}
|
||||
|
||||
SECTION("equality") {
|
||||
osmium::Location loc1(1.2, 4.5);
|
||||
osmium::Location loc2(1.2, 4.5);
|
||||
osmium::Location loc3(1.5, 1.5);
|
||||
REQUIRE(loc1 == loc2);
|
||||
REQUIRE(loc1 != loc3);
|
||||
}
|
||||
SECTION("equality") {
|
||||
osmium::Location loc1(1.2, 4.5);
|
||||
osmium::Location loc2(1.2, 4.5);
|
||||
osmium::Location loc3(1.5, 1.5);
|
||||
REQUIRE(loc1 == loc2);
|
||||
REQUIRE(loc1 != loc3);
|
||||
}
|
||||
|
||||
SECTION("order") {
|
||||
REQUIRE(osmium::Location(-1.2, 10.0) < osmium::Location(1.2, 10.0));
|
||||
REQUIRE(osmium::Location(1.2, 10.0) > osmium::Location(-1.2, 10.0));
|
||||
SECTION("order") {
|
||||
REQUIRE(osmium::Location(-1.2, 10.0) < osmium::Location(1.2, 10.0));
|
||||
REQUIRE(osmium::Location(1.2, 10.0) > osmium::Location(-1.2, 10.0));
|
||||
|
||||
REQUIRE(osmium::Location(10.2, 20.0) < osmium::Location(11.2, 20.2));
|
||||
REQUIRE(osmium::Location(10.2, 20.2) < osmium::Location(11.2, 20.0));
|
||||
REQUIRE(osmium::Location(11.2, 20.2) > osmium::Location(10.2, 20.0));
|
||||
}
|
||||
REQUIRE(osmium::Location(10.2, 20.0) < osmium::Location(11.2, 20.2));
|
||||
REQUIRE(osmium::Location(10.2, 20.2) < osmium::Location(11.2, 20.0));
|
||||
REQUIRE(osmium::Location(11.2, 20.2) > osmium::Location(10.2, 20.0));
|
||||
}
|
||||
|
||||
SECTION("validity") {
|
||||
REQUIRE(osmium::Location(0.0, 0.0).valid());
|
||||
REQUIRE(osmium::Location(1.2, 4.5).valid());
|
||||
REQUIRE(osmium::Location(-1.2, 4.5).valid());
|
||||
REQUIRE(osmium::Location(-180.0, -90.0).valid());
|
||||
REQUIRE(osmium::Location(180.0, -90.0).valid());
|
||||
REQUIRE(osmium::Location(-180.0, 90.0).valid());
|
||||
REQUIRE(osmium::Location(180.0, 90.0).valid());
|
||||
SECTION("validity") {
|
||||
REQUIRE(osmium::Location(0.0, 0.0).valid());
|
||||
REQUIRE(osmium::Location(1.2, 4.5).valid());
|
||||
REQUIRE(osmium::Location(-1.2, 4.5).valid());
|
||||
REQUIRE(osmium::Location(-180.0, -90.0).valid());
|
||||
REQUIRE(osmium::Location(180.0, -90.0).valid());
|
||||
REQUIRE(osmium::Location(-180.0, 90.0).valid());
|
||||
REQUIRE(osmium::Location(180.0, 90.0).valid());
|
||||
|
||||
REQUIRE(!osmium::Location(200.0, 4.5).valid());
|
||||
REQUIRE(!osmium::Location(-1.2, -100.0).valid());
|
||||
REQUIRE(!osmium::Location(-180.0, 90.005).valid());
|
||||
}
|
||||
REQUIRE(!osmium::Location(200.0, 4.5).valid());
|
||||
REQUIRE(!osmium::Location(-1.2, -100.0).valid());
|
||||
REQUIRE(!osmium::Location(-180.0, 90.005).valid());
|
||||
}
|
||||
|
||||
|
||||
SECTION("output_to_iterator_comma_separator") {
|
||||
char buffer[100];
|
||||
osmium::Location loc(-3.2, 47.3);
|
||||
*loc.as_string(buffer, ',') = 0;
|
||||
REQUIRE(std::string("-3.2,47.3") == buffer);
|
||||
}
|
||||
SECTION("output_to_iterator_comma_separator") {
|
||||
char buffer[100];
|
||||
osmium::Location loc(-3.2, 47.3);
|
||||
*loc.as_string(buffer, ',') = 0;
|
||||
REQUIRE(std::string("-3.2,47.3") == buffer);
|
||||
}
|
||||
|
||||
SECTION("output_to_iterator_space_separator") {
|
||||
char buffer[100];
|
||||
osmium::Location loc(0.0, 7.0);
|
||||
*loc.as_string(buffer, ' ') = 0;
|
||||
REQUIRE(std::string("0 7") == buffer);
|
||||
}
|
||||
SECTION("output_to_iterator_space_separator") {
|
||||
char buffer[100];
|
||||
osmium::Location loc(0.0, 7.0);
|
||||
*loc.as_string(buffer, ' ') = 0;
|
||||
REQUIRE(std::string("0 7") == buffer);
|
||||
}
|
||||
|
||||
SECTION("output_to_iterator_check_precision") {
|
||||
char buffer[100];
|
||||
osmium::Location loc(-179.9999999, -90.0);
|
||||
*loc.as_string(buffer, ' ') = 0;
|
||||
REQUIRE(std::string("-179.9999999 -90") == buffer);
|
||||
}
|
||||
SECTION("output_to_iterator_check_precision") {
|
||||
char buffer[100];
|
||||
osmium::Location loc(-179.9999999, -90.0);
|
||||
*loc.as_string(buffer, ' ') = 0;
|
||||
REQUIRE(std::string("-179.9999999 -90") == buffer);
|
||||
}
|
||||
|
||||
SECTION("output_to_iterator_undefined_location") {
|
||||
char buffer[100];
|
||||
osmium::Location loc;
|
||||
REQUIRE_THROWS_AS(loc.as_string(buffer, ','), osmium::invalid_location);
|
||||
}
|
||||
SECTION("output_to_iterator_undefined_location") {
|
||||
char buffer[100];
|
||||
osmium::Location loc;
|
||||
REQUIRE_THROWS_AS(loc.as_string(buffer, ','), osmium::invalid_location);
|
||||
}
|
||||
|
||||
SECTION("output_to_string_comman_separator") {
|
||||
std::string s;
|
||||
osmium::Location loc(-3.2, 47.3);
|
||||
loc.as_string(std::back_inserter(s), ',');
|
||||
REQUIRE(s == "-3.2,47.3");
|
||||
}
|
||||
SECTION("output_to_string_comman_separator") {
|
||||
std::string s;
|
||||
osmium::Location loc(-3.2, 47.3);
|
||||
loc.as_string(std::back_inserter(s), ',');
|
||||
REQUIRE(s == "-3.2,47.3");
|
||||
}
|
||||
|
||||
SECTION("output_to_string_space_separator") {
|
||||
std::string s;
|
||||
osmium::Location loc(0.0, 7.0);
|
||||
loc.as_string(std::back_inserter(s), ' ');
|
||||
REQUIRE(s == "0 7");
|
||||
}
|
||||
SECTION("output_to_string_space_separator") {
|
||||
std::string s;
|
||||
osmium::Location loc(0.0, 7.0);
|
||||
loc.as_string(std::back_inserter(s), ' ');
|
||||
REQUIRE(s == "0 7");
|
||||
}
|
||||
|
||||
SECTION("output_to_string_check_precision") {
|
||||
std::string s;
|
||||
osmium::Location loc(-179.9999999, -90.0);
|
||||
loc.as_string(std::back_inserter(s), ' ');
|
||||
REQUIRE(s == "-179.9999999 -90");
|
||||
}
|
||||
SECTION("output_to_string_check_precision") {
|
||||
std::string s;
|
||||
osmium::Location loc(-179.9999999, -90.0);
|
||||
loc.as_string(std::back_inserter(s), ' ');
|
||||
REQUIRE(s == "-179.9999999 -90");
|
||||
}
|
||||
|
||||
SECTION("output_to_string_undefined_location") {
|
||||
std::string s;
|
||||
osmium::Location loc;
|
||||
REQUIRE_THROWS_AS(loc.as_string(std::back_inserter(s), ','), osmium::invalid_location);
|
||||
}
|
||||
SECTION("output_to_string_undefined_location") {
|
||||
std::string s;
|
||||
osmium::Location loc;
|
||||
REQUIRE_THROWS_AS(loc.as_string(std::back_inserter(s), ','), osmium::invalid_location);
|
||||
}
|
||||
|
||||
SECTION("output_defined") {
|
||||
osmium::Location p(-3.2, 47.3);
|
||||
std::stringstream out;
|
||||
out << p;
|
||||
REQUIRE(out.str() == "(-3.2,47.3)");
|
||||
}
|
||||
SECTION("output_defined") {
|
||||
osmium::Location p(-3.2, 47.3);
|
||||
std::stringstream out;
|
||||
out << p;
|
||||
REQUIRE(out.str() == "(-3.2,47.3)");
|
||||
}
|
||||
|
||||
SECTION("output_undefined") {
|
||||
osmium::Location p;
|
||||
std::stringstream out;
|
||||
out << p;
|
||||
REQUIRE(out.str() == "(undefined,undefined)");
|
||||
}
|
||||
SECTION("output_undefined") {
|
||||
osmium::Location p;
|
||||
std::stringstream out;
|
||||
out << p;
|
||||
REQUIRE(out.str() == "(undefined,undefined)");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+41
-41
@@ -4,54 +4,54 @@
|
||||
|
||||
TEST_CASE("NodeRef") {
|
||||
|
||||
SECTION("instantiation_with_default_parameters") {
|
||||
osmium::NodeRef node_ref;
|
||||
REQUIRE(node_ref.ref() == 0);
|
||||
SECTION("instantiation_with_default_parameters") {
|
||||
osmium::NodeRef node_ref;
|
||||
REQUIRE(node_ref.ref() == 0);
|
||||
// REQUIRE(!node_ref.has_location());
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("instantiation_with_id") {
|
||||
osmium::NodeRef node_ref(7);
|
||||
REQUIRE(node_ref.ref() == 7);
|
||||
}
|
||||
SECTION("instantiation_with_id") {
|
||||
osmium::NodeRef node_ref(7);
|
||||
REQUIRE(node_ref.ref() == 7);
|
||||
}
|
||||
|
||||
SECTION("equality") {
|
||||
osmium::NodeRef node_ref1(7, { 1.2, 3.4 });
|
||||
osmium::NodeRef node_ref2(7, { 1.4, 3.1 });
|
||||
osmium::NodeRef node_ref3(9, { 1.2, 3.4 });
|
||||
REQUIRE(node_ref1 == node_ref2);
|
||||
REQUIRE(node_ref1 != node_ref3);
|
||||
REQUIRE(!osmium::location_equal()(node_ref1, node_ref2));
|
||||
REQUIRE(!osmium::location_equal()(node_ref2, node_ref3));
|
||||
REQUIRE(osmium::location_equal()(node_ref1, node_ref3));
|
||||
}
|
||||
SECTION("equality") {
|
||||
osmium::NodeRef node_ref1(7, { 1.2, 3.4 });
|
||||
osmium::NodeRef node_ref2(7, { 1.4, 3.1 });
|
||||
osmium::NodeRef node_ref3(9, { 1.2, 3.4 });
|
||||
REQUIRE(node_ref1 == node_ref2);
|
||||
REQUIRE(node_ref1 != node_ref3);
|
||||
REQUIRE(!osmium::location_equal()(node_ref1, node_ref2));
|
||||
REQUIRE(!osmium::location_equal()(node_ref2, node_ref3));
|
||||
REQUIRE(osmium::location_equal()(node_ref1, node_ref3));
|
||||
}
|
||||
|
||||
SECTION("set_location") {
|
||||
osmium::NodeRef node_ref(7);
|
||||
REQUIRE(!node_ref.location().valid());
|
||||
REQUIRE(node_ref.location() == osmium::Location());
|
||||
node_ref.set_location(osmium::Location(13.5, -7.2));
|
||||
REQUIRE(node_ref.location().lon() == 13.5);
|
||||
REQUIRE(node_ref.location().valid());
|
||||
}
|
||||
SECTION("set_location") {
|
||||
osmium::NodeRef node_ref(7);
|
||||
REQUIRE(!node_ref.location().valid());
|
||||
REQUIRE(node_ref.location() == osmium::Location());
|
||||
node_ref.set_location(osmium::Location(13.5, -7.2));
|
||||
REQUIRE(node_ref.location().lon() == 13.5);
|
||||
REQUIRE(node_ref.location().valid());
|
||||
}
|
||||
|
||||
SECTION("ordering") {
|
||||
osmium::NodeRef node_ref1(1, { 1.0, 3.0 });
|
||||
osmium::NodeRef node_ref2(2, { 1.4, 2.9 });
|
||||
osmium::NodeRef node_ref3(3, { 1.2, 3.0 });
|
||||
osmium::NodeRef node_ref4(4, { 1.2, 3.3 });
|
||||
SECTION("ordering") {
|
||||
osmium::NodeRef node_ref1(1, { 1.0, 3.0 });
|
||||
osmium::NodeRef node_ref2(2, { 1.4, 2.9 });
|
||||
osmium::NodeRef node_ref3(3, { 1.2, 3.0 });
|
||||
osmium::NodeRef node_ref4(4, { 1.2, 3.3 });
|
||||
|
||||
REQUIRE(node_ref1 < node_ref2);
|
||||
REQUIRE(node_ref2 < node_ref3);
|
||||
REQUIRE(node_ref1 < node_ref3);
|
||||
REQUIRE(node_ref1 >= node_ref1);
|
||||
REQUIRE(node_ref1 < node_ref2);
|
||||
REQUIRE(node_ref2 < node_ref3);
|
||||
REQUIRE(node_ref1 < node_ref3);
|
||||
REQUIRE(node_ref1 >= node_ref1);
|
||||
|
||||
REQUIRE(osmium::location_less()(node_ref1, node_ref2));
|
||||
REQUIRE(!osmium::location_less()(node_ref2, node_ref3));
|
||||
REQUIRE(osmium::location_less()(node_ref1, node_ref3));
|
||||
REQUIRE(osmium::location_less()(node_ref3, node_ref4));
|
||||
REQUIRE(!osmium::location_less()(node_ref1, node_ref1));
|
||||
}
|
||||
REQUIRE(osmium::location_less()(node_ref1, node_ref2));
|
||||
REQUIRE(!osmium::location_less()(node_ref2, node_ref3));
|
||||
REQUIRE(osmium::location_less()(node_ref1, node_ref3));
|
||||
REQUIRE(osmium::location_less()(node_ref3, node_ref4));
|
||||
REQUIRE(!osmium::location_less()(node_ref1, node_ref1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+133
-133
@@ -6,142 +6,142 @@
|
||||
|
||||
TEST_CASE("Object_Comparisons") {
|
||||
|
||||
SECTION("order") {
|
||||
osmium::memory::Buffer buffer(10 * 1000);
|
||||
SECTION("order") {
|
||||
osmium::memory::Buffer buffer(10 * 1000);
|
||||
|
||||
{
|
||||
// add node 1
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
node_builder.add_user("testuser");
|
||||
buffer.commit();
|
||||
{
|
||||
// add node 1
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
node_builder.add_user("testuser");
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add node 2
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
node_builder.add_user("testuser");
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
auto it = buffer.begin();
|
||||
osmium::Node& node1 = static_cast<osmium::Node&>(*it);
|
||||
osmium::Node& node2 = static_cast<osmium::Node&>(*(++it));
|
||||
|
||||
node1.set_id(10);
|
||||
node1.set_version(1);
|
||||
node2.set_id(15);
|
||||
node2.set_version(2);
|
||||
REQUIRE(true == (node1 < node2));
|
||||
REQUIRE(false == (node1 > node2));
|
||||
node1.set_id(20);
|
||||
node1.set_version(1);
|
||||
node2.set_id(20);
|
||||
node2.set_version(2);
|
||||
REQUIRE(true == (node1 < node2));
|
||||
REQUIRE(false == (node1 > node2));
|
||||
node1.set_id(-10);
|
||||
node1.set_version(2);
|
||||
node2.set_id(-15);
|
||||
node2.set_version(1);
|
||||
REQUIRE(true == (node1 < node2));
|
||||
REQUIRE(false == (node1 > node2));
|
||||
}
|
||||
|
||||
{
|
||||
// add node 2
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
node_builder.add_user("testuser");
|
||||
buffer.commit();
|
||||
SECTION("order_types") {
|
||||
osmium::memory::Buffer buffer(10 * 1000);
|
||||
|
||||
{
|
||||
// add node 1
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
node.set_id(3);
|
||||
node.set_version(3);
|
||||
node_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add node 2
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
node.set_id(3);
|
||||
node.set_version(4);
|
||||
node_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add node 3
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
node.set_id(3);
|
||||
node.set_version(4);
|
||||
node_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add way
|
||||
osmium::builder::WayBuilder way_builder(buffer);
|
||||
osmium::Way& way = way_builder.object();
|
||||
REQUIRE(osmium::item_type::way == way.type());
|
||||
|
||||
way.set_id(2);
|
||||
way.set_version(2);
|
||||
way_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add relation
|
||||
osmium::builder::RelationBuilder relation_builder(buffer);
|
||||
osmium::Relation& relation = relation_builder.object();
|
||||
REQUIRE(osmium::item_type::relation == relation.type());
|
||||
|
||||
relation.set_id(1);
|
||||
relation.set_version(1);
|
||||
relation_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
auto it = buffer.begin();
|
||||
const osmium::Node& node1 = static_cast<const osmium::Node&>(*it);
|
||||
const osmium::Node& node2 = static_cast<const osmium::Node&>(*(++it));
|
||||
const osmium::Node& node3 = static_cast<const osmium::Node&>(*(++it));
|
||||
const osmium::Way& way = static_cast<const osmium::Way&>(*(++it));
|
||||
const osmium::Relation& relation = static_cast<const osmium::Relation&>(*(++it));
|
||||
|
||||
REQUIRE(true == (node1 < node2));
|
||||
REQUIRE(true == (node2 < way));
|
||||
REQUIRE(false == (node2 > way));
|
||||
REQUIRE(true == (way < relation));
|
||||
REQUIRE(true == (node1 < relation));
|
||||
|
||||
REQUIRE(true == osmium::object_order_type_id_version()(node1, node2));
|
||||
REQUIRE(true == osmium::object_order_type_id_reverse_version()(node2, node1));
|
||||
REQUIRE(true == osmium::object_order_type_id_version()(node1, way));
|
||||
REQUIRE(true == osmium::object_order_type_id_reverse_version()(node1, way));
|
||||
|
||||
REQUIRE(false == osmium::object_equal_type_id_version()(node1, node2));
|
||||
REQUIRE(true == osmium::object_equal_type_id_version()(node2, node3));
|
||||
|
||||
REQUIRE(true == osmium::object_equal_type_id()(node1, node2));
|
||||
REQUIRE(true == osmium::object_equal_type_id()(node2, node3));
|
||||
|
||||
REQUIRE(false == osmium::object_equal_type_id_version()(node1, way));
|
||||
REQUIRE(false == osmium::object_equal_type_id_version()(node1, relation));
|
||||
REQUIRE(false == osmium::object_equal_type_id()(node1, relation));
|
||||
}
|
||||
|
||||
auto it = buffer.begin();
|
||||
osmium::Node& node1 = static_cast<osmium::Node&>(*it);
|
||||
osmium::Node& node2 = static_cast<osmium::Node&>(*(++it));
|
||||
|
||||
node1.set_id(10);
|
||||
node1.set_version(1);
|
||||
node2.set_id(15);
|
||||
node2.set_version(2);
|
||||
REQUIRE(true == (node1 < node2));
|
||||
REQUIRE(false == (node1 > node2));
|
||||
node1.set_id(20);
|
||||
node1.set_version(1);
|
||||
node2.set_id(20);
|
||||
node2.set_version(2);
|
||||
REQUIRE(true == (node1 < node2));
|
||||
REQUIRE(false == (node1 > node2));
|
||||
node1.set_id(-10);
|
||||
node1.set_version(2);
|
||||
node2.set_id(-15);
|
||||
node2.set_version(1);
|
||||
REQUIRE(true == (node1 < node2));
|
||||
REQUIRE(false == (node1 > node2));
|
||||
}
|
||||
|
||||
SECTION("order_types") {
|
||||
osmium::memory::Buffer buffer(10 * 1000);
|
||||
|
||||
{
|
||||
// add node 1
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
node.set_id(3);
|
||||
node.set_version(3);
|
||||
node_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add node 2
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
node.set_id(3);
|
||||
node.set_version(4);
|
||||
node_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add node 3
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
node.set_id(3);
|
||||
node.set_version(4);
|
||||
node_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add way
|
||||
osmium::builder::WayBuilder way_builder(buffer);
|
||||
osmium::Way& way = way_builder.object();
|
||||
REQUIRE(osmium::item_type::way == way.type());
|
||||
|
||||
way.set_id(2);
|
||||
way.set_version(2);
|
||||
way_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add relation
|
||||
osmium::builder::RelationBuilder relation_builder(buffer);
|
||||
osmium::Relation& relation = relation_builder.object();
|
||||
REQUIRE(osmium::item_type::relation == relation.type());
|
||||
|
||||
relation.set_id(1);
|
||||
relation.set_version(1);
|
||||
relation_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
auto it = buffer.begin();
|
||||
const osmium::Node& node1 = static_cast<const osmium::Node&>(*it);
|
||||
const osmium::Node& node2 = static_cast<const osmium::Node&>(*(++it));
|
||||
const osmium::Node& node3 = static_cast<const osmium::Node&>(*(++it));
|
||||
const osmium::Way& way = static_cast<const osmium::Way&>(*(++it));
|
||||
const osmium::Relation& relation = static_cast<const osmium::Relation&>(*(++it));
|
||||
|
||||
REQUIRE(true == (node1 < node2));
|
||||
REQUIRE(true == (node2 < way));
|
||||
REQUIRE(false == (node2 > way));
|
||||
REQUIRE(true == (way < relation));
|
||||
REQUIRE(true == (node1 < relation));
|
||||
|
||||
REQUIRE(true == osmium::object_order_type_id_version()(node1, node2));
|
||||
REQUIRE(true == osmium::object_order_type_id_reverse_version()(node2, node1));
|
||||
REQUIRE(true == osmium::object_order_type_id_version()(node1, way));
|
||||
REQUIRE(true == osmium::object_order_type_id_reverse_version()(node1, way));
|
||||
|
||||
REQUIRE(false == osmium::object_equal_type_id_version()(node1, node2));
|
||||
REQUIRE(true == osmium::object_equal_type_id_version()(node2, node3));
|
||||
|
||||
REQUIRE(true == osmium::object_equal_type_id()(node1, node2));
|
||||
REQUIRE(true == osmium::object_equal_type_id()(node2, node3));
|
||||
|
||||
REQUIRE(false == osmium::object_equal_type_id_version()(node1, way));
|
||||
REQUIRE(false == osmium::object_equal_type_id_version()(node1, relation));
|
||||
REQUIRE(false == osmium::object_equal_type_id()(node1, relation));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+43
-30
@@ -6,40 +6,53 @@
|
||||
|
||||
TEST_CASE("Timestamp") {
|
||||
|
||||
SECTION("can be default initialized to invalid value") {
|
||||
osmium::Timestamp t;
|
||||
REQUIRE(0 == t);
|
||||
REQUIRE("" == t.to_iso());
|
||||
}
|
||||
SECTION("can be default initialized to invalid value") {
|
||||
osmium::Timestamp t;
|
||||
REQUIRE(0 == t);
|
||||
REQUIRE("" == t.to_iso());
|
||||
}
|
||||
|
||||
SECTION("invalid value is zero") {
|
||||
osmium::Timestamp t(static_cast<time_t>(0));
|
||||
REQUIRE(0 == t);
|
||||
REQUIRE("" == t.to_iso());
|
||||
}
|
||||
SECTION("invalid value is zero") {
|
||||
osmium::Timestamp t(static_cast<time_t>(0));
|
||||
REQUIRE(0 == t);
|
||||
REQUIRE("" == t.to_iso());
|
||||
}
|
||||
|
||||
SECTION("can be initialized from time_t") {
|
||||
osmium::Timestamp t(static_cast<time_t>(1));
|
||||
REQUIRE(1 == t);
|
||||
REQUIRE("1970-01-01T00:00:01Z" == t.to_iso());
|
||||
}
|
||||
SECTION("can be initialized from time_t") {
|
||||
osmium::Timestamp t(static_cast<time_t>(1));
|
||||
REQUIRE(1 == t);
|
||||
REQUIRE("1970-01-01T00:00:01Z" == t.to_iso());
|
||||
}
|
||||
|
||||
SECTION("can be initialized from string") {
|
||||
osmium::Timestamp t("2000-01-01T00:00:00Z");
|
||||
REQUIRE("2000-01-01T00:00:00Z" == t.to_iso());
|
||||
}
|
||||
SECTION("can be initialized from string") {
|
||||
osmium::Timestamp t("2000-01-01T00:00:00Z");
|
||||
REQUIRE("2000-01-01T00:00:00Z" == t.to_iso());
|
||||
}
|
||||
|
||||
SECTION("can be compared") {
|
||||
osmium::Timestamp t1(10);
|
||||
osmium::Timestamp t2(50);
|
||||
REQUIRE(t1 < t2);
|
||||
}
|
||||
SECTION("can be implicitly cast to time_t") {
|
||||
osmium::Timestamp t(4242);
|
||||
time_t x = t;
|
||||
REQUIRE(x == 4242);
|
||||
}
|
||||
|
||||
SECTION("can be written to stream") {
|
||||
std::stringstream ss;
|
||||
osmium::Timestamp t(1);
|
||||
ss << t;
|
||||
REQUIRE("1970-01-01T00:00:01Z" == ss.str());
|
||||
}
|
||||
SECTION("uint32_t can be initialized from Timestamp") {
|
||||
osmium::Timestamp t(4242);
|
||||
uint32_t x { t };
|
||||
|
||||
REQUIRE(x == 4242);
|
||||
}
|
||||
|
||||
SECTION("can be compared") {
|
||||
osmium::Timestamp t1(10);
|
||||
osmium::Timestamp t2(50);
|
||||
REQUIRE(t1 < t2);
|
||||
}
|
||||
|
||||
SECTION("can be written to stream") {
|
||||
std::stringstream ss;
|
||||
osmium::Timestamp t(1);
|
||||
ss << t;
|
||||
REQUIRE("1970-01-01T00:00:01Z" == ss.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+61
-61
@@ -58,78 +58,78 @@ void check_node_2(osmium::Node& node) {
|
||||
|
||||
TEST_CASE("Buffer_Node") {
|
||||
|
||||
SECTION("buffer_node") {
|
||||
constexpr size_t buffer_size = 10000;
|
||||
unsigned char data[buffer_size];
|
||||
SECTION("buffer_node") {
|
||||
constexpr size_t buffer_size = 10000;
|
||||
unsigned char data[buffer_size];
|
||||
|
||||
osmium::memory::Buffer buffer(data, buffer_size, 0);
|
||||
|
||||
{
|
||||
// add node 1
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
node.set_id(1);
|
||||
node.set_version(3);
|
||||
node.set_visible(true);
|
||||
node.set_changeset(333);
|
||||
node.set_uid(21);
|
||||
node.set_timestamp(123);
|
||||
node.set_location(osmium::Location(3.5, 4.7));
|
||||
|
||||
node_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
{
|
||||
// add node 2
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
node.set_id(2);
|
||||
node.set_version(3);
|
||||
node.set_visible(true);
|
||||
node.set_changeset(333);
|
||||
node.set_uid(21);
|
||||
node.set_timestamp(123);
|
||||
node.set_location(osmium::Location(3.5, 4.7));
|
||||
|
||||
node_builder.add_user("testuser");
|
||||
osmium::memory::Buffer buffer(data, buffer_size, 0);
|
||||
|
||||
{
|
||||
osmium::builder::TagListBuilder tag_builder(buffer, &node_builder);
|
||||
tag_builder.add_tag("amenity", "bank");
|
||||
tag_builder.add_tag("name", "OSM Savings");
|
||||
// add node 1
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
node.set_id(1);
|
||||
node.set_version(3);
|
||||
node.set_visible(true);
|
||||
node.set_changeset(333);
|
||||
node.set_uid(21);
|
||||
node.set_timestamp(123);
|
||||
node.set_location(osmium::Location(3.5, 4.7));
|
||||
|
||||
node_builder.add_user("testuser");
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
{
|
||||
// add node 2
|
||||
osmium::builder::NodeBuilder node_builder(buffer);
|
||||
osmium::Node& node = node_builder.object();
|
||||
REQUIRE(osmium::item_type::node == node.type());
|
||||
|
||||
REQUIRE(2 == std::distance(buffer.begin(), buffer.end()));
|
||||
int item_no = 0;
|
||||
for (osmium::memory::Item& item : buffer) {
|
||||
REQUIRE(osmium::item_type::node == item.type());
|
||||
node.set_id(2);
|
||||
node.set_version(3);
|
||||
node.set_visible(true);
|
||||
node.set_changeset(333);
|
||||
node.set_uid(21);
|
||||
node.set_timestamp(123);
|
||||
node.set_location(osmium::Location(3.5, 4.7));
|
||||
|
||||
osmium::Node& node = static_cast<osmium::Node&>(item);
|
||||
node_builder.add_user("testuser");
|
||||
|
||||
switch (item_no) {
|
||||
case 0:
|
||||
check_node_1(node);
|
||||
break;
|
||||
case 1:
|
||||
check_node_2(node);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
{
|
||||
osmium::builder::TagListBuilder tag_builder(buffer, &node_builder);
|
||||
tag_builder.add_tag("amenity", "bank");
|
||||
tag_builder.add_tag("name", "OSM Savings");
|
||||
}
|
||||
|
||||
buffer.commit();
|
||||
}
|
||||
|
||||
++item_no;
|
||||
REQUIRE(2 == std::distance(buffer.begin(), buffer.end()));
|
||||
int item_no = 0;
|
||||
for (osmium::memory::Item& item : buffer) {
|
||||
REQUIRE(osmium::item_type::node == item.type());
|
||||
|
||||
osmium::Node& node = static_cast<osmium::Node&>(item);
|
||||
|
||||
switch (item_no) {
|
||||
case 0:
|
||||
check_node_1(node);
|
||||
break;
|
||||
case 1:
|
||||
check_node_2(node);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
++item_no;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,32 +10,32 @@
|
||||
|
||||
TEST_CASE("Projection") {
|
||||
|
||||
SECTION("point_mercator") {
|
||||
osmium::geom::WKTFactory<osmium::geom::MercatorProjection> factory(2);
|
||||
SECTION("point_mercator") {
|
||||
osmium::geom::WKTFactory<osmium::geom::MercatorProjection> factory(2);
|
||||
|
||||
std::string wkt {factory.create_point(osmium::Location(3.2, 4.2))};
|
||||
REQUIRE(std::string{"POINT(356222.37 467961.14)"} == wkt);
|
||||
}
|
||||
std::string wkt {factory.create_point(osmium::Location(3.2, 4.2))};
|
||||
REQUIRE(std::string {"POINT(356222.37 467961.14)"} == wkt);
|
||||
}
|
||||
|
||||
SECTION("point_epsg_3857") {
|
||||
osmium::geom::WKTFactory<osmium::geom::Projection> factory(osmium::geom::Projection(3857), 2);
|
||||
SECTION("point_epsg_3857") {
|
||||
osmium::geom::WKTFactory<osmium::geom::Projection> factory(osmium::geom::Projection(3857), 2);
|
||||
|
||||
std::string wkt {factory.create_point(osmium::Location(3.2, 4.2))};
|
||||
REQUIRE(std::string{"POINT(356222.37 467961.14)"} == wkt);
|
||||
}
|
||||
std::string wkt {factory.create_point(osmium::Location(3.2, 4.2))};
|
||||
REQUIRE(std::string {"POINT(356222.37 467961.14)"} == wkt);
|
||||
}
|
||||
|
||||
SECTION("wkb_with_parameter") {
|
||||
osmium::geom::WKBFactory<osmium::geom::Projection> wkb_factory(osmium::geom::Projection(3857), osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
|
||||
osmium::geom::GEOSFactory<osmium::geom::Projection> geos_factory(osmium::geom::Projection(3857));
|
||||
SECTION("wkb_with_parameter") {
|
||||
osmium::geom::WKBFactory<osmium::geom::Projection> wkb_factory(osmium::geom::Projection(3857), osmium::geom::wkb_type::wkb, osmium::geom::out_type::hex);
|
||||
osmium::geom::GEOSFactory<osmium::geom::Projection> geos_factory(osmium::geom::Projection(3857));
|
||||
|
||||
std::string wkb = wkb_factory.create_point(osmium::Location(3.2, 4.2));
|
||||
std::unique_ptr<geos::geom::Point> geos_point = geos_factory.create_point(osmium::Location(3.2, 4.2));
|
||||
REQUIRE(geos_to_wkb(geos_point.get()) == wkb);
|
||||
}
|
||||
std::string wkb = wkb_factory.create_point(osmium::Location(3.2, 4.2));
|
||||
std::unique_ptr<geos::geom::Point> geos_point = geos_factory.create_point(osmium::Location(3.2, 4.2));
|
||||
REQUIRE(geos_to_wkb(geos_point.get()) == wkb);
|
||||
}
|
||||
|
||||
SECTION("cleanup") {
|
||||
// trying to make valgrind happy, but there is still a memory leak in proj library
|
||||
pj_deallocate_grids();
|
||||
}
|
||||
SECTION("cleanup") {
|
||||
// trying to make valgrind happy, but there is still a memory leak in proj library
|
||||
pj_deallocate_grids();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+25
-25
@@ -4,34 +4,34 @@
|
||||
|
||||
TEST_CASE("Mercator") {
|
||||
|
||||
SECTION("mercator_projection") {
|
||||
osmium::geom::MercatorProjection projection;
|
||||
REQUIRE(3857 == projection.epsg());
|
||||
REQUIRE("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs" == projection.proj_string());
|
||||
}
|
||||
SECTION("mercator_projection") {
|
||||
osmium::geom::MercatorProjection projection;
|
||||
REQUIRE(3857 == projection.epsg());
|
||||
REQUIRE("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs" == projection.proj_string());
|
||||
}
|
||||
|
||||
SECTION("low_level_mercator_functions") {
|
||||
osmium::geom::Coordinates c1(17.839, -3.249);
|
||||
osmium::geom::Coordinates r1 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c1));
|
||||
REQUIRE(r1.x == Approx(c1.x).epsilon(0.000001));
|
||||
REQUIRE(r1.y == Approx(c1.y).epsilon(0.000001));
|
||||
SECTION("low_level_mercator_functions") {
|
||||
osmium::geom::Coordinates c1(17.839, -3.249);
|
||||
osmium::geom::Coordinates r1 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c1));
|
||||
REQUIRE(r1.x == Approx(c1.x).epsilon(0.000001));
|
||||
REQUIRE(r1.y == Approx(c1.y).epsilon(0.000001));
|
||||
|
||||
osmium::geom::Coordinates c2(-89.2, 15.915);
|
||||
osmium::geom::Coordinates r2 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c2));
|
||||
REQUIRE(r2.x == Approx(c2.x).epsilon(0.000001));
|
||||
REQUIRE(r2.y == Approx(c2.y).epsilon(0.000001));
|
||||
osmium::geom::Coordinates c2(-89.2, 15.915);
|
||||
osmium::geom::Coordinates r2 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c2));
|
||||
REQUIRE(r2.x == Approx(c2.x).epsilon(0.000001));
|
||||
REQUIRE(r2.y == Approx(c2.y).epsilon(0.000001));
|
||||
|
||||
osmium::geom::Coordinates c3(180.0, 85.0);
|
||||
osmium::geom::Coordinates r3 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c3));
|
||||
REQUIRE(r3.x == Approx(c3.x).epsilon(0.000001));
|
||||
REQUIRE(r3.y == Approx(c3.y).epsilon(0.000001));
|
||||
}
|
||||
osmium::geom::Coordinates c3(180.0, 85.0);
|
||||
osmium::geom::Coordinates r3 = osmium::geom::mercator_to_lonlat(osmium::geom::lonlat_to_mercator(c3));
|
||||
REQUIRE(r3.x == Approx(c3.x).epsilon(0.000001));
|
||||
REQUIRE(r3.y == Approx(c3.y).epsilon(0.000001));
|
||||
}
|
||||
|
||||
SECTION("mercator_bounds") {
|
||||
osmium::Location mmax(180.0, osmium::geom::MERCATOR_MAX_LAT);
|
||||
osmium::geom::Coordinates c = osmium::geom::lonlat_to_mercator(mmax);
|
||||
REQUIRE(c.x == Approx(c.y).epsilon(0.001));
|
||||
REQUIRE(osmium::geom::detail::y_to_lat(osmium::geom::detail::lon_to_x(180.0)) == Approx(osmium::geom::MERCATOR_MAX_LAT).epsilon(0.0000001));
|
||||
}
|
||||
SECTION("mercator_bounds") {
|
||||
osmium::Location mmax(180.0, osmium::geom::MERCATOR_MAX_LAT);
|
||||
osmium::geom::Coordinates c = osmium::geom::lonlat_to_mercator(mmax);
|
||||
REQUIRE(c.x == Approx(c.y).epsilon(0.001));
|
||||
REQUIRE(osmium::geom::detail::y_to_lat(osmium::geom::detail::lon_to_x(180.0)) == Approx(osmium::geom::MERCATOR_MAX_LAT).epsilon(0.0000001));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+79
-79
@@ -58,113 +58,113 @@ void test_func_real(TIndex& index) {
|
||||
|
||||
TEST_CASE("IdToLocation") {
|
||||
|
||||
SECTION("Dummy") {
|
||||
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
SECTION("Dummy") {
|
||||
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
index_type index1;
|
||||
index_type index1;
|
||||
|
||||
REQUIRE(0 == index1.size());
|
||||
REQUIRE(0 == index1.used_memory());
|
||||
REQUIRE(0 == index1.size());
|
||||
REQUIRE(0 == index1.used_memory());
|
||||
|
||||
test_func_all<index_type>(index1);
|
||||
test_func_all<index_type>(index1);
|
||||
|
||||
REQUIRE(0 == index1.size());
|
||||
REQUIRE(0 == index1.used_memory());
|
||||
}
|
||||
REQUIRE(0 == index1.size());
|
||||
REQUIRE(0 == index1.used_memory());
|
||||
}
|
||||
|
||||
SECTION("DenseMemArray") {
|
||||
typedef osmium::index::map::DenseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
SECTION("DenseMemArray") {
|
||||
typedef osmium::index::map::DenseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
index_type index1;
|
||||
index1.reserve(1000);
|
||||
test_func_all<index_type>(index1);
|
||||
index_type index1;
|
||||
index1.reserve(1000);
|
||||
test_func_all<index_type>(index1);
|
||||
|
||||
index_type index2;
|
||||
index2.reserve(1000);
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
index_type index2;
|
||||
index2.reserve(1000);
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
SECTION("DenseMmapArray") {
|
||||
typedef osmium::index::map::DenseMmapArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
SECTION("DenseMmapArray") {
|
||||
typedef osmium::index::map::DenseMmapArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
index_type index1;
|
||||
test_func_all<index_type>(index1);
|
||||
index_type index1;
|
||||
test_func_all<index_type>(index1);
|
||||
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
#else
|
||||
# pragma message("not running 'DenseMapMmap' test case on this machine")
|
||||
#endif
|
||||
|
||||
SECTION("DenseFileArray") {
|
||||
typedef osmium::index::map::DenseFileArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
SECTION("DenseFileArray") {
|
||||
typedef osmium::index::map::DenseFileArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
index_type index1;
|
||||
test_func_all<index_type>(index1);
|
||||
index_type index1;
|
||||
test_func_all<index_type>(index1);
|
||||
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
|
||||
#ifdef OSMIUM_WITH_SPARSEHASH
|
||||
|
||||
SECTION("SparseMemTable") {
|
||||
typedef osmium::index::map::SparseMemTable<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
SECTION("SparseMemTable") {
|
||||
typedef osmium::index::map::SparseMemTable<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
index_type index1;
|
||||
test_func_all<index_type>(index1);
|
||||
index_type index1;
|
||||
test_func_all<index_type>(index1);
|
||||
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SECTION("SparseMemMap") {
|
||||
typedef osmium::index::map::SparseMemMap<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
SECTION("SparseMemMap") {
|
||||
typedef osmium::index::map::SparseMemMap<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
index_type index1;
|
||||
test_func_all<index_type>(index1);
|
||||
index_type index1;
|
||||
test_func_all<index_type>(index1);
|
||||
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
|
||||
SECTION("SparseMemArray") {
|
||||
typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
index_type index1;
|
||||
|
||||
REQUIRE(0 == index1.size());
|
||||
REQUIRE(0 == index1.used_memory());
|
||||
|
||||
test_func_all<index_type>(index1);
|
||||
|
||||
REQUIRE(2 == index1.size());
|
||||
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
|
||||
SECTION("Dynamic map choice") {
|
||||
typedef osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location> map_type;
|
||||
const auto& map_factory = osmium::index::MapFactory<osmium::unsigned_object_id_type, osmium::Location>::instance();
|
||||
|
||||
std::vector<std::string> map_type_names = map_factory.map_types();
|
||||
REQUIRE(map_type_names.size() >= 5);
|
||||
|
||||
for (const auto& map_type_name : map_type_names) {
|
||||
std::unique_ptr<map_type> index1 = map_factory.create_map(map_type_name);
|
||||
index1->reserve(1000);
|
||||
test_func_all<map_type>(*index1);
|
||||
|
||||
std::unique_ptr<map_type> index2 = map_factory.create_map(map_type_name);
|
||||
index2->reserve(1000);
|
||||
test_func_real<map_type>(*index2);
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
|
||||
SECTION("SparseMemArray") {
|
||||
typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
index_type index1;
|
||||
|
||||
REQUIRE(0 == index1.size());
|
||||
REQUIRE(0 == index1.used_memory());
|
||||
|
||||
test_func_all<index_type>(index1);
|
||||
|
||||
REQUIRE(2 == index1.size());
|
||||
|
||||
index_type index2;
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
|
||||
SECTION("Dynamic map choice") {
|
||||
typedef osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location> map_type;
|
||||
const auto& map_factory = osmium::index::MapFactory<osmium::unsigned_object_id_type, osmium::Location>::instance();
|
||||
|
||||
std::vector<std::string> map_type_names = map_factory.map_types();
|
||||
REQUIRE(map_type_names.size() >= 5);
|
||||
|
||||
for (const auto& map_type_name : map_type_names) {
|
||||
std::unique_ptr<map_type> index1 = map_factory.create_map(map_type_name);
|
||||
index1->reserve(1000);
|
||||
test_func_all<map_type>(*index1);
|
||||
|
||||
std::unique_ptr<map_type> index2 = map_factory.create_map(map_type_name);
|
||||
index2->reserve(1000);
|
||||
test_func_real<map_type>(*index2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+48
-71
@@ -3,97 +3,74 @@
|
||||
#include <osmium/index/detail/typed_mmap.hpp>
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32))
|
||||
#include "win_mkstemp.hpp"
|
||||
#include "win_mkstemp.hpp"
|
||||
#endif
|
||||
|
||||
TEST_CASE("TypedMmap") {
|
||||
|
||||
SECTION("Mmap") {
|
||||
uint64_t* data = osmium::detail::typed_mmap<uint64_t>::map(10);
|
||||
SECTION("Mmap") {
|
||||
uint64_t* data = osmium::detail::typed_mmap<uint64_t>::map(10);
|
||||
|
||||
data[0] = 4ul;
|
||||
data[3] = 9ul;
|
||||
data[9] = 25ul;
|
||||
data[0] = 4ul;
|
||||
data[3] = 9ul;
|
||||
data[9] = 25ul;
|
||||
|
||||
REQUIRE(4ul == data[0]);
|
||||
REQUIRE(9ul == data[3]);
|
||||
REQUIRE(25ul == data[9]);
|
||||
REQUIRE(4ul == data[0]);
|
||||
REQUIRE(9ul == data[3]);
|
||||
REQUIRE(25ul == data[9]);
|
||||
|
||||
osmium::detail::typed_mmap<uint64_t>::unmap(data, 10);
|
||||
}
|
||||
|
||||
SECTION("MmapSizeZero") {
|
||||
REQUIRE_THROWS_AS(osmium::detail::typed_mmap<uint64_t>::map(0), std::system_error);
|
||||
}
|
||||
|
||||
SECTION("MmapHugeSize") {
|
||||
// this is a horrible hack to only run the test on 64bit machines.
|
||||
if (sizeof(size_t) >= 8) {
|
||||
REQUIRE_THROWS_AS(osmium::detail::typed_mmap<uint64_t>::map(1ULL << (sizeof(size_t) * 6)), std::system_error);
|
||||
osmium::detail::typed_mmap<uint64_t>::unmap(data, 10);
|
||||
}
|
||||
|
||||
SECTION("MmapSizeZero") {
|
||||
REQUIRE_THROWS_AS(osmium::detail::typed_mmap<uint64_t>::map(0), std::system_error);
|
||||
}
|
||||
|
||||
SECTION("MmapHugeSize") {
|
||||
// this is a horrible hack to only run the test on 64bit machines.
|
||||
if (sizeof(size_t) >= 8) {
|
||||
REQUIRE_THROWS_AS(osmium::detail::typed_mmap<uint64_t>::map(1ULL << (sizeof(size_t) * 6)), std::system_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
SECTION("Remap") {
|
||||
uint64_t* data = osmium::detail::typed_mmap<uint64_t>::map(10);
|
||||
SECTION("Remap") {
|
||||
uint64_t* data = osmium::detail::typed_mmap<uint64_t>::map(10);
|
||||
|
||||
data[0] = 4ul;
|
||||
data[3] = 9ul;
|
||||
data[9] = 25ul;
|
||||
data[0] = 4ul;
|
||||
data[3] = 9ul;
|
||||
data[9] = 25ul;
|
||||
|
||||
uint64_t* new_data = osmium::detail::typed_mmap<uint64_t>::remap(data, 10, 1000);
|
||||
uint64_t* new_data = osmium::detail::typed_mmap<uint64_t>::remap(data, 10, 1000);
|
||||
|
||||
REQUIRE(4ul == new_data[0]);
|
||||
REQUIRE(9ul == new_data[3]);
|
||||
REQUIRE(25ul == new_data[9]);
|
||||
}
|
||||
REQUIRE(4ul == new_data[0]);
|
||||
REQUIRE(9ul == new_data[3]);
|
||||
REQUIRE(25ul == new_data[9]);
|
||||
}
|
||||
#else
|
||||
# pragma message("not running 'Remap' test case on this machine")
|
||||
#endif
|
||||
|
||||
SECTION("FileSize") {
|
||||
const int size = 100;
|
||||
char filename[] = "test_mmap_file_size_XXXXXX";
|
||||
const int fd = mkstemp(filename);
|
||||
REQUIRE(fd > 0);
|
||||
REQUIRE(0 == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
REQUIRE(0 == ftruncate(fd, size * sizeof(uint64_t)));
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
SECTION("FileSize") {
|
||||
const int size = 100;
|
||||
char filename[] = "test_mmap_file_size_XXXXXX";
|
||||
const int fd = mkstemp(filename);
|
||||
REQUIRE(fd > 0);
|
||||
REQUIRE(0 == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
REQUIRE(0 == ftruncate(fd, size * sizeof(uint64_t)));
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
|
||||
osmium::detail::typed_mmap<uint64_t>::grow_file(size / 2, fd);
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
osmium::detail::typed_mmap<uint64_t>::grow_file(size / 2, fd);
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
|
||||
osmium::detail::typed_mmap<uint64_t>::grow_file(size, fd);
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
osmium::detail::typed_mmap<uint64_t>::grow_file(size, fd);
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
|
||||
osmium::detail::typed_mmap<uint64_t>::grow_file(size * 2, fd);
|
||||
REQUIRE((size * 2) == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
osmium::detail::typed_mmap<uint64_t>::grow_file(size * 2, fd);
|
||||
REQUIRE((size * 2) == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
|
||||
REQUIRE(0 == close(fd));
|
||||
REQUIRE(0 == unlink(filename));
|
||||
}
|
||||
|
||||
SECTION("GrowAndMap") {
|
||||
const int size = 100;
|
||||
char filename[] = "test_mmap_grow_and_map_XXXXXX";
|
||||
const int fd = mkstemp(filename);
|
||||
REQUIRE(fd > 0);
|
||||
|
||||
uint64_t* data = osmium::detail::typed_mmap<uint64_t>::grow_and_map(size, fd);
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
|
||||
data[0] = 1ul;
|
||||
data[1] = 8ul;
|
||||
data[99] = 27ul;
|
||||
|
||||
REQUIRE(1ul == data[0]);
|
||||
REQUIRE(8ul == data[1]);
|
||||
REQUIRE(27ul == data[99]);
|
||||
|
||||
osmium::detail::typed_mmap<uint64_t>::unmap(data, size);
|
||||
|
||||
REQUIRE(0 == close(fd));
|
||||
REQUIRE(0 == unlink(filename));
|
||||
}
|
||||
REQUIRE(0 == close(fd));
|
||||
REQUIRE(0 == unlink(filename));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <osmium/index/detail/typed_mmap.hpp>
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32))
|
||||
#include "win_mkstemp.hpp"
|
||||
#endif
|
||||
|
||||
TEST_CASE("TypedMmapGrow") {
|
||||
|
||||
SECTION("GrowAndMap") {
|
||||
const int size = 100;
|
||||
char filename[] = "test_mmap_grow_and_map_XXXXXX";
|
||||
const int fd = mkstemp(filename);
|
||||
REQUIRE(fd > 0);
|
||||
|
||||
uint64_t* data = osmium::detail::typed_mmap<uint64_t>::grow_and_map(size, fd);
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
|
||||
data[0] = 1ul;
|
||||
data[1] = 8ul;
|
||||
data[99] = 27ul;
|
||||
|
||||
REQUIRE(1ul == data[0]);
|
||||
REQUIRE(8ul == data[1]);
|
||||
REQUIRE(27ul == data[99]);
|
||||
|
||||
osmium::detail::typed_mmap<uint64_t>::unmap(data, size);
|
||||
|
||||
REQUIRE(0 == close(fd));
|
||||
REQUIRE(0 == unlink(filename));
|
||||
}
|
||||
|
||||
}
|
||||
+15
-15
@@ -9,25 +9,25 @@
|
||||
|
||||
TEST_CASE("Bzip2") {
|
||||
|
||||
SECTION("read_compressed_file") {
|
||||
std::string input_file = with_data_dir("t/io/data_bzip2.txt.bz2");
|
||||
SECTION("read_compressed_file") {
|
||||
std::string input_file = with_data_dir("t/io/data_bzip2.txt.bz2");
|
||||
|
||||
int fd = ::open(input_file.c_str(), O_RDONLY);
|
||||
REQUIRE(fd > 0);
|
||||
int fd = ::open(input_file.c_str(), O_RDONLY);
|
||||
REQUIRE(fd > 0);
|
||||
|
||||
size_t size = 0;
|
||||
std::string all;
|
||||
{
|
||||
osmium::io::Bzip2Decompressor decomp(fd);
|
||||
for (std::string data = decomp.read(); !data.empty(); data = decomp.read()) {
|
||||
size += data.size();
|
||||
all += data;
|
||||
size_t size = 0;
|
||||
std::string all;
|
||||
{
|
||||
osmium::io::Bzip2Decompressor decomp(fd);
|
||||
for (std::string data = decomp.read(); !data.empty(); data = decomp.read()) {
|
||||
size += data.size();
|
||||
all += data;
|
||||
}
|
||||
}
|
||||
|
||||
REQUIRE(9 == size);
|
||||
REQUIRE("TESTDATA\n" == all);
|
||||
}
|
||||
|
||||
REQUIRE(9 == size);
|
||||
REQUIRE("TESTDATA\n" == all);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+210
-210
@@ -6,246 +6,246 @@
|
||||
|
||||
TEST_CASE("FileFormats") {
|
||||
|
||||
SECTION("default_file_format") {
|
||||
osmium::io::File f;
|
||||
REQUIRE(osmium::io::file_format::unknown == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
SECTION("default_file_format") {
|
||||
osmium::io::File f;
|
||||
REQUIRE(osmium::io::file_format::unknown == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
|
||||
SECTION("stdin_stdout_empty") {
|
||||
osmium::io::File f {""};
|
||||
REQUIRE(osmium::io::file_format::unknown == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
SECTION("stdin_stdout_empty") {
|
||||
osmium::io::File f {""};
|
||||
REQUIRE(osmium::io::file_format::unknown == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
|
||||
SECTION("stdin_stdout_dash") {
|
||||
osmium::io::File f {"-"};
|
||||
REQUIRE(osmium::io::file_format::unknown == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
SECTION("stdin_stdout_dash") {
|
||||
osmium::io::File f {"-"};
|
||||
REQUIRE(osmium::io::file_format::unknown == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
|
||||
SECTION("stdin_stdout_bz2") {
|
||||
osmium::io::File f {"-", "osm.bz2"};
|
||||
REQUIRE("" == f.filename());
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::bzip2 == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("stdin_stdout_bz2") {
|
||||
osmium::io::File f {"-", "osm.bz2"};
|
||||
REQUIRE("" == f.filename());
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::bzip2 == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_osm") {
|
||||
osmium::io::File f {"test.osm"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_osm") {
|
||||
osmium::io::File f {"test.osm"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_pbf") {
|
||||
osmium::io::File f {"test.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_pbf") {
|
||||
osmium::io::File f {"test.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_osm_pbf") {
|
||||
osmium::io::File f {"test.osm.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_osm_pbf") {
|
||||
osmium::io::File f {"test.osm.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_opl") {
|
||||
osmium::io::File f {"test.opl"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_opl") {
|
||||
osmium::io::File f {"test.opl"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_osm_opl") {
|
||||
osmium::io::File f {"test.osm.opl"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_osm_opl") {
|
||||
osmium::io::File f {"test.osm.opl"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_osm_gz") {
|
||||
osmium::io::File f {"test.osm.gz"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_osm_gz") {
|
||||
osmium::io::File f {"test.osm.gz"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_opl_bz2") {
|
||||
osmium::io::File f {"test.osm.opl.bz2"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::bzip2 == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_opl_bz2") {
|
||||
osmium::io::File f {"test.osm.opl.bz2"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::bzip2 == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_osc_gz") {
|
||||
osmium::io::File f {"test.osc.gz"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_osc_gz") {
|
||||
osmium::io::File f {"test.osc.gz"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_opl_gz") {
|
||||
osmium::io::File f {"test.osh.opl.gz"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_opl_gz") {
|
||||
osmium::io::File f {"test.osh.opl.gz"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("detect_file_format_by_suffix_osh_pbf") {
|
||||
osmium::io::File f {"test.osh.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("detect_file_format_by_suffix_osh_pbf") {
|
||||
osmium::io::File f {"test.osh.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_osm") {
|
||||
osmium::io::File f {"test", "osm"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_osm") {
|
||||
osmium::io::File f {"test", "osm"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_pbf") {
|
||||
osmium::io::File f {"test", "pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_pbf") {
|
||||
osmium::io::File f {"test", "pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_osm_pbf") {
|
||||
osmium::io::File f {"test", "osm.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_osm_pbf") {
|
||||
osmium::io::File f {"test", "osm.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_opl") {
|
||||
osmium::io::File f {"test", "opl"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_opl") {
|
||||
osmium::io::File f {"test", "opl"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_osm_opl") {
|
||||
osmium::io::File f {"test", "osm.opl"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_osm_opl") {
|
||||
osmium::io::File f {"test", "osm.opl"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_osm_gz") {
|
||||
osmium::io::File f {"test", "osm.gz"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_osm_gz") {
|
||||
osmium::io::File f {"test", "osm.gz"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_osm_opl_bz2") {
|
||||
osmium::io::File f {"test", "osm.opl.bz2"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::bzip2 == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_osm_opl_bz2") {
|
||||
osmium::io::File f {"test", "osm.opl.bz2"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::bzip2 == f.compression());
|
||||
REQUIRE(false == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_osc_gz") {
|
||||
osmium::io::File f {"test", "osc.gz"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_osc_gz") {
|
||||
osmium::io::File f {"test", "osc.gz"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_osh_opl_gz") {
|
||||
osmium::io::File f {"test", "osh.opl.gz"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_osh_opl_gz") {
|
||||
osmium::io::File f {"test", "osh.opl.gz"};
|
||||
REQUIRE(osmium::io::file_format::opl == f.format());
|
||||
REQUIRE(osmium::io::file_compression::gzip == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("override_file_format_by_suffix_osh_pbf") {
|
||||
osmium::io::File f {"test", "osh.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("override_file_format_by_suffix_osh_pbf") {
|
||||
osmium::io::File f {"test", "osh.pbf"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("format_options_pbf_history") {
|
||||
osmium::io::File f {"test", "pbf,history=true"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
SECTION("format_options_pbf_history") {
|
||||
osmium::io::File f {"test", "pbf,history=true"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE(true == f.has_multiple_object_versions());
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("format_options_pbf_foo") {
|
||||
osmium::io::File f {"test.osm", "pbf,foo=bar"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE("bar" == f.get("foo"));
|
||||
f.check();
|
||||
}
|
||||
SECTION("format_options_pbf_foo") {
|
||||
osmium::io::File f {"test.osm", "pbf,foo=bar"};
|
||||
REQUIRE(osmium::io::file_format::pbf == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE("bar" == f.get("foo"));
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("format_options_xml_abc_something") {
|
||||
osmium::io::File f {"test.bla", "xml,abc,some=thing"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE("true" == f.get("abc"));
|
||||
REQUIRE("thing" == f.get("some"));
|
||||
REQUIRE(2 == std::distance(f.begin(), f.end()));
|
||||
f.check();
|
||||
}
|
||||
SECTION("format_options_xml_abc_something") {
|
||||
osmium::io::File f {"test.bla", "xml,abc,some=thing"};
|
||||
REQUIRE(osmium::io::file_format::xml == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE("true" == f.get("abc"));
|
||||
REQUIRE("thing" == f.get("some"));
|
||||
REQUIRE(2 == std::distance(f.begin(), f.end()));
|
||||
f.check();
|
||||
}
|
||||
|
||||
SECTION("unknown_format_foo_bar") {
|
||||
osmium::io::File f {"test.foo.bar"};
|
||||
REQUIRE(osmium::io::file_format::unknown == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
SECTION("unknown_format_foo_bar") {
|
||||
osmium::io::File f {"test.foo.bar"};
|
||||
REQUIRE(osmium::io::file_format::unknown == f.format());
|
||||
REQUIRE(osmium::io::file_compression::none == f.compression());
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
|
||||
SECTION("unknown_format_foo") {
|
||||
osmium::io::File f {"test", "foo"};
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
SECTION("unknown_format_foo") {
|
||||
osmium::io::File f {"test", "foo"};
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
|
||||
SECTION("unknown_format_osm_foo") {
|
||||
osmium::io::File f {"test", "osm.foo"};
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
SECTION("unknown_format_osm_foo") {
|
||||
osmium::io::File f {"test", "osm.foo"};
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
|
||||
SECTION("unknown_format_bla_equals_foo") {
|
||||
osmium::io::File f {"test", "bla=foo"};
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
SECTION("unknown_format_bla_equals_foo") {
|
||||
osmium::io::File f {"test", "bla=foo"};
|
||||
REQUIRE_THROWS_AS(f.check(), std::runtime_error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+145
-145
@@ -25,192 +25,192 @@ void check_filter(const osmium::TagList& tag_list, const TFilter filter, const s
|
||||
|
||||
TEST_CASE("Filter") {
|
||||
|
||||
SECTION("KeyFilter_matches_some_tags") {
|
||||
osmium::tags::KeyFilter filter(false);
|
||||
filter.add(true, "highway").add(true, "railway");
|
||||
SECTION("KeyFilter_matches_some_tags") {
|
||||
osmium::tags::KeyFilter filter(false);
|
||||
filter.add(true, "highway").add(true, "railway");
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" }, // match
|
||||
{ "name", "Main Street" }, // no match
|
||||
{ "source", "GPS" } // no match
|
||||
});
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" }, // match
|
||||
{ "name", "Main Street" }, // no match
|
||||
{ "source", "GPS" } // no match
|
||||
});
|
||||
|
||||
std::vector<bool> results = { true, false, false };
|
||||
std::vector<bool> results = { true, false, false };
|
||||
|
||||
check_filter(tag_list, filter, results);
|
||||
}
|
||||
check_filter(tag_list, filter, results);
|
||||
}
|
||||
|
||||
SECTION("KeyFilter_iterator_filters_tags") {
|
||||
osmium::tags::KeyFilter filter(false);
|
||||
filter.add(true, "highway").add(true, "source");
|
||||
SECTION("KeyFilter_iterator_filters_tags") {
|
||||
osmium::tags::KeyFilter filter(false);
|
||||
filter.add(true, "highway").add(true, "source");
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" }, // match
|
||||
{ "name", "Main Street" }, // no match
|
||||
{ "source", "GPS" } // no match
|
||||
});
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" }, // match
|
||||
{ "name", "Main Street" }, // no match
|
||||
{ "source", "GPS" } // no match
|
||||
});
|
||||
|
||||
osmium::tags::KeyFilter::iterator it(filter, tl.begin(), tl.end());
|
||||
const osmium::tags::KeyFilter::iterator end(filter, tl.end(), tl.end());
|
||||
osmium::tags::KeyFilter::iterator it(filter, tl.begin(), tl.end());
|
||||
const osmium::tags::KeyFilter::iterator end(filter, tl.end(), tl.end());
|
||||
|
||||
REQUIRE(2 == std::distance(it, end));
|
||||
REQUIRE(2 == std::distance(it, end));
|
||||
|
||||
REQUIRE(it != end);
|
||||
REQUIRE(std::string("highway") == it->key());
|
||||
REQUIRE(std::string("primary") == it->value());
|
||||
++it;
|
||||
REQUIRE(std::string("source") == it->key());
|
||||
REQUIRE(std::string("GPS") == it->value());
|
||||
REQUIRE(++it == end);
|
||||
}
|
||||
REQUIRE(it != end);
|
||||
REQUIRE(std::string("highway") == it->key());
|
||||
REQUIRE(std::string("primary") == it->value());
|
||||
++it;
|
||||
REQUIRE(std::string("source") == it->key());
|
||||
REQUIRE(std::string("GPS") == it->value());
|
||||
REQUIRE(++it == end);
|
||||
}
|
||||
|
||||
SECTION("KeyValueFilter_matches_some_tags") {
|
||||
osmium::tags::KeyValueFilter filter(false);
|
||||
SECTION("KeyValueFilter_matches_some_tags") {
|
||||
osmium::tags::KeyValueFilter filter(false);
|
||||
|
||||
filter.add(true, "highway", "residential").add(true, "highway", "primary").add(true, "railway");
|
||||
filter.add(true, "highway", "residential").add(true, "highway", "primary").add(true, "railway");
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "railway", "tram" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "railway", "tram" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
|
||||
std::vector<bool> results = {true, true, false};
|
||||
std::vector<bool> results = {true, true, false};
|
||||
|
||||
check_filter(tag_list, filter, results);
|
||||
}
|
||||
check_filter(tag_list, filter, results);
|
||||
}
|
||||
|
||||
SECTION("KeyValueFilter_ordering_matters") {
|
||||
osmium::tags::KeyValueFilter filter1(false);
|
||||
filter1.add(true, "highway").add(false, "highway", "road");
|
||||
SECTION("KeyValueFilter_ordering_matters") {
|
||||
osmium::tags::KeyValueFilter filter1(false);
|
||||
filter1.add(true, "highway").add(false, "highway", "road");
|
||||
|
||||
osmium::tags::KeyValueFilter filter2(false);
|
||||
filter2.add(false, "highway", "road").add(true, "highway");
|
||||
osmium::tags::KeyValueFilter filter2(false);
|
||||
filter2.add(false, "highway", "road").add(true, "highway");
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
|
||||
const osmium::TagList& tag_list1 = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "road" },
|
||||
{ "name", "Main Street" }
|
||||
});
|
||||
const osmium::TagList& tag_list1 = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "road" },
|
||||
{ "name", "Main Street" }
|
||||
});
|
||||
|
||||
const osmium::TagList& tag_list2 = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" }
|
||||
});
|
||||
const osmium::TagList& tag_list2 = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" }
|
||||
});
|
||||
|
||||
check_filter(tag_list1, filter1, {true, false});
|
||||
check_filter(tag_list1, filter2, {false, false});
|
||||
check_filter(tag_list2, filter2, {true, false});
|
||||
}
|
||||
check_filter(tag_list1, filter1, {true, false});
|
||||
check_filter(tag_list1, filter2, {false, false});
|
||||
check_filter(tag_list2, filter2, {true, false});
|
||||
}
|
||||
|
||||
SECTION("KeyValueFilter_matches_against_taglist_with_any") {
|
||||
osmium::tags::KeyValueFilter filter(false);
|
||||
SECTION("KeyValueFilter_matches_against_taglist_with_any") {
|
||||
osmium::tags::KeyValueFilter filter(false);
|
||||
|
||||
filter.add(true, "highway", "primary").add(true, "name");
|
||||
filter.add(true, "highway", "primary").add(true, "name");
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "railway", "tram" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "railway", "tram" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
|
||||
REQUIRE( osmium::tags::match_any_of(tag_list, filter));
|
||||
REQUIRE(!osmium::tags::match_all_of(tag_list, filter));
|
||||
REQUIRE(!osmium::tags::match_none_of(tag_list, filter));
|
||||
}
|
||||
REQUIRE( osmium::tags::match_any_of(tag_list, filter));
|
||||
REQUIRE(!osmium::tags::match_all_of(tag_list, filter));
|
||||
REQUIRE(!osmium::tags::match_none_of(tag_list, filter));
|
||||
}
|
||||
|
||||
SECTION("KeyValueFilter_matches_against_taglist_with_all") {
|
||||
osmium::tags::KeyValueFilter filter(false);
|
||||
SECTION("KeyValueFilter_matches_against_taglist_with_all") {
|
||||
osmium::tags::KeyValueFilter filter(false);
|
||||
|
||||
filter.add(true, "highway", "primary").add(true, "name");
|
||||
filter.add(true, "highway", "primary").add(true, "name");
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" }
|
||||
});
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" }
|
||||
});
|
||||
|
||||
REQUIRE( osmium::tags::match_any_of(tag_list, filter));
|
||||
REQUIRE( osmium::tags::match_all_of(tag_list, filter));
|
||||
REQUIRE(!osmium::tags::match_none_of(tag_list, filter));
|
||||
}
|
||||
REQUIRE( osmium::tags::match_any_of(tag_list, filter));
|
||||
REQUIRE( osmium::tags::match_all_of(tag_list, filter));
|
||||
REQUIRE(!osmium::tags::match_none_of(tag_list, filter));
|
||||
}
|
||||
|
||||
SECTION("KeyValueFilter_matches_against_taglist_with_none") {
|
||||
osmium::tags::KeyValueFilter filter(false);
|
||||
SECTION("KeyValueFilter_matches_against_taglist_with_none") {
|
||||
osmium::tags::KeyValueFilter filter(false);
|
||||
|
||||
filter.add(true, "highway", "road").add(true, "source");
|
||||
filter.add(true, "highway", "road").add(true, "source");
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" }
|
||||
});
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" }
|
||||
});
|
||||
|
||||
REQUIRE(!osmium::tags::match_any_of(tag_list, filter));
|
||||
REQUIRE(!osmium::tags::match_all_of(tag_list, filter));
|
||||
REQUIRE( osmium::tags::match_none_of(tag_list, filter));
|
||||
}
|
||||
REQUIRE(!osmium::tags::match_any_of(tag_list, filter));
|
||||
REQUIRE(!osmium::tags::match_all_of(tag_list, filter));
|
||||
REQUIRE( osmium::tags::match_none_of(tag_list, filter));
|
||||
}
|
||||
|
||||
SECTION("KeyValueFilter_matches_against_taglist_with_any_called_with_rvalue") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "railway", "tram" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
SECTION("KeyValueFilter_matches_against_taglist_with_any_called_with_rvalue") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "railway", "tram" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
|
||||
REQUIRE(osmium::tags::match_any_of(tag_list,
|
||||
osmium::tags::KeyValueFilter().add(true, "highway", "primary").add(true, "name")));
|
||||
}
|
||||
REQUIRE(osmium::tags::match_any_of(tag_list,
|
||||
osmium::tags::KeyValueFilter().add(true, "highway", "primary").add(true, "name")));
|
||||
}
|
||||
|
||||
SECTION("RegexFilter_matches_some_tags") {
|
||||
osmium::tags::RegexFilter filter(false);
|
||||
filter.add(true, "highway", std::regex(".*_link"));
|
||||
SECTION("RegexFilter_matches_some_tags") {
|
||||
osmium::tags::RegexFilter filter(false);
|
||||
filter.add(true, "highway", std::regex(".*_link"));
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list1 = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary_link" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
const osmium::TagList& tag_list2 = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list1 = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary_link" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
const osmium::TagList& tag_list2 = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
|
||||
check_filter(tag_list1, filter, {true, false});
|
||||
check_filter(tag_list2, filter, {false, false});
|
||||
}
|
||||
check_filter(tag_list1, filter, {true, false});
|
||||
check_filter(tag_list2, filter, {false, false});
|
||||
}
|
||||
|
||||
SECTION("RegexFilter_matches_some_tags_with_lvalue_regex") {
|
||||
osmium::tags::RegexFilter filter(false);
|
||||
std::regex r(".*straße");
|
||||
filter.add(true, "name", r);
|
||||
SECTION("RegexFilter_matches_some_tags_with_lvalue_regex") {
|
||||
osmium::tags::RegexFilter filter(false);
|
||||
std::regex r(".*straße");
|
||||
filter.add(true, "name", r);
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Hauptstraße" }
|
||||
});
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Hauptstraße" }
|
||||
});
|
||||
|
||||
check_filter(tag_list, filter, {false, true});
|
||||
}
|
||||
check_filter(tag_list, filter, {false, true});
|
||||
}
|
||||
|
||||
SECTION("KeyPrefixFilter_matches_some_tags") {
|
||||
osmium::tags::KeyPrefixFilter filter(false);
|
||||
filter.add(true, "name:");
|
||||
SECTION("KeyPrefixFilter_matches_some_tags") {
|
||||
osmium::tags::KeyPrefixFilter filter(false);
|
||||
filter.add(true, "name:");
|
||||
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name:de", "Hauptstraße" }
|
||||
});
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
const osmium::TagList& tag_list = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name:de", "Hauptstraße" }
|
||||
});
|
||||
|
||||
check_filter(tag_list, filter, {false, true});
|
||||
}
|
||||
check_filter(tag_list, filter, {false, true});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+46
-46
@@ -8,54 +8,54 @@
|
||||
|
||||
TEST_CASE("Operators") {
|
||||
|
||||
SECTION("Equal") {
|
||||
osmium::memory::Buffer buffer1(10240);
|
||||
{
|
||||
osmium::builder::TagListBuilder tl_builder(buffer1);
|
||||
tl_builder.add_tag("highway", "primary");
|
||||
tl_builder.add_tag("name", "Main Street");
|
||||
tl_builder.add_tag("source", "GPS");
|
||||
SECTION("Equal") {
|
||||
osmium::memory::Buffer buffer1(10240);
|
||||
{
|
||||
osmium::builder::TagListBuilder tl_builder(buffer1);
|
||||
tl_builder.add_tag("highway", "primary");
|
||||
tl_builder.add_tag("name", "Main Street");
|
||||
tl_builder.add_tag("source", "GPS");
|
||||
}
|
||||
buffer1.commit();
|
||||
|
||||
osmium::memory::Buffer buffer2(10240);
|
||||
{
|
||||
osmium::builder::TagListBuilder tl_builder(buffer2);
|
||||
tl_builder.add_tag("highway", "primary");
|
||||
}
|
||||
buffer2.commit();
|
||||
|
||||
const osmium::TagList& tl1 = buffer1.get<const osmium::TagList>(0);
|
||||
const osmium::TagList& tl2 = buffer2.get<const osmium::TagList>(0);
|
||||
|
||||
auto tagit1 = tl1.begin();
|
||||
auto tagit2 = tl2.begin();
|
||||
REQUIRE(*tagit1 == *tagit2);
|
||||
++tagit1;
|
||||
REQUIRE(!(*tagit1 == *tagit2));
|
||||
}
|
||||
buffer1.commit();
|
||||
|
||||
osmium::memory::Buffer buffer2(10240);
|
||||
{
|
||||
osmium::builder::TagListBuilder tl_builder(buffer2);
|
||||
tl_builder.add_tag("highway", "primary");
|
||||
SECTION("Order") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
{
|
||||
osmium::builder::TagListBuilder tl_builder(buffer);
|
||||
tl_builder.add_tag("highway", "residential");
|
||||
tl_builder.add_tag("highway", "primary");
|
||||
tl_builder.add_tag("name", "Main Street");
|
||||
tl_builder.add_tag("amenity", "post_box");
|
||||
}
|
||||
buffer.commit();
|
||||
|
||||
const osmium::TagList& tl = buffer.get<const osmium::TagList>(0);
|
||||
const osmium::Tag& t1 = *(tl.begin());
|
||||
const osmium::Tag& t2 = *(std::next(tl.begin(), 1));
|
||||
const osmium::Tag& t3 = *(std::next(tl.begin(), 2));
|
||||
const osmium::Tag& t4 = *(std::next(tl.begin(), 3));
|
||||
|
||||
REQUIRE(t2 < t1);
|
||||
REQUIRE(t1 < t3);
|
||||
REQUIRE(t2 < t3);
|
||||
REQUIRE(t4 < t1);
|
||||
}
|
||||
buffer2.commit();
|
||||
|
||||
const osmium::TagList& tl1 = buffer1.get<const osmium::TagList>(0);
|
||||
const osmium::TagList& tl2 = buffer2.get<const osmium::TagList>(0);
|
||||
|
||||
auto tagit1 = tl1.begin();
|
||||
auto tagit2 = tl2.begin();
|
||||
REQUIRE(*tagit1 == *tagit2);
|
||||
++tagit1;
|
||||
REQUIRE(!(*tagit1 == *tagit2));
|
||||
}
|
||||
|
||||
SECTION("Order") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
{
|
||||
osmium::builder::TagListBuilder tl_builder(buffer);
|
||||
tl_builder.add_tag("highway", "residential");
|
||||
tl_builder.add_tag("highway", "primary");
|
||||
tl_builder.add_tag("name", "Main Street");
|
||||
tl_builder.add_tag("amenity", "post_box");
|
||||
}
|
||||
buffer.commit();
|
||||
|
||||
const osmium::TagList& tl = buffer.get<const osmium::TagList>(0);
|
||||
const osmium::Tag& t1 = *(tl.begin());
|
||||
const osmium::Tag& t2 = *(std::next(tl.begin(), 1));
|
||||
const osmium::Tag& t3 = *(std::next(tl.begin(), 2));
|
||||
const osmium::Tag& t4 = *(std::next(tl.begin(), 3));
|
||||
|
||||
REQUIRE(t2 < t1);
|
||||
REQUIRE(t1 < t3);
|
||||
REQUIRE(t2 < t3);
|
||||
REQUIRE(t4 < t1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+55
-55
@@ -6,71 +6,71 @@
|
||||
|
||||
TEST_CASE("tag_list") {
|
||||
|
||||
SECTION("can_be_created_from_initializer_list") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
SECTION("can_be_created_from_initializer_list") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list(buffer, {
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" },
|
||||
{ "source", "GPS" }
|
||||
});
|
||||
|
||||
REQUIRE(osmium::item_type::tag_list == tl.type());
|
||||
REQUIRE(3 == tl.size());
|
||||
REQUIRE(std::string("highway") == tl.begin()->key());
|
||||
REQUIRE(std::string("primary") == tl.begin()->value());
|
||||
}
|
||||
|
||||
SECTION("can_be_created_from_map") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list_from_map(buffer, std::map<const char*, const char*>({
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" }
|
||||
}));
|
||||
|
||||
REQUIRE(osmium::item_type::tag_list == tl.type());
|
||||
REQUIRE(2 == tl.size());
|
||||
|
||||
if (std::string("highway") == tl.begin()->key()) {
|
||||
REQUIRE(osmium::item_type::tag_list == tl.type());
|
||||
REQUIRE(3 == tl.size());
|
||||
REQUIRE(std::string("highway") == tl.begin()->key());
|
||||
REQUIRE(std::string("primary") == tl.begin()->value());
|
||||
REQUIRE(std::string("name") == std::next(tl.begin(), 1)->key());
|
||||
REQUIRE(std::string("Main Street") == std::next(tl.begin(), 1)->value());
|
||||
} else {
|
||||
REQUIRE(std::string("highway") == std::next(tl.begin(), 1)->key());
|
||||
REQUIRE(std::string("primary") == std::next(tl.begin(), 1)->value());
|
||||
REQUIRE(std::string("name") == tl.begin()->key());
|
||||
REQUIRE(std::string("Main Street") == tl.begin()->value());
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("can_be_created_with_callback") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
SECTION("can_be_created_from_map") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list_from_func(buffer, [](osmium::builder::TagListBuilder& tlb) {
|
||||
tlb.add_tag("highway", "primary");
|
||||
tlb.add_tag("bridge", "true");
|
||||
});
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list_from_map(buffer, std::map<const char*, const char*>({
|
||||
{ "highway", "primary" },
|
||||
{ "name", "Main Street" }
|
||||
}));
|
||||
|
||||
REQUIRE(osmium::item_type::tag_list == tl.type());
|
||||
REQUIRE(2 == tl.size());
|
||||
REQUIRE(std::string("bridge") == std::next(tl.begin(), 1)->key());
|
||||
REQUIRE(std::string("true") == std::next(tl.begin(), 1)->value());
|
||||
}
|
||||
REQUIRE(osmium::item_type::tag_list == tl.type());
|
||||
REQUIRE(2 == tl.size());
|
||||
|
||||
SECTION("returns_value_by_key") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
if (std::string("highway") == tl.begin()->key()) {
|
||||
REQUIRE(std::string("primary") == tl.begin()->value());
|
||||
REQUIRE(std::string("name") == std::next(tl.begin(), 1)->key());
|
||||
REQUIRE(std::string("Main Street") == std::next(tl.begin(), 1)->value());
|
||||
} else {
|
||||
REQUIRE(std::string("highway") == std::next(tl.begin(), 1)->key());
|
||||
REQUIRE(std::string("primary") == std::next(tl.begin(), 1)->value());
|
||||
REQUIRE(std::string("name") == tl.begin()->key());
|
||||
REQUIRE(std::string("Main Street") == tl.begin()->value());
|
||||
}
|
||||
}
|
||||
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list_from_func(buffer, [](osmium::builder::TagListBuilder& tlb) {
|
||||
tlb.add_tag("highway", "primary");
|
||||
tlb.add_tag("bridge", "true");
|
||||
});
|
||||
SECTION("can_be_created_with_callback") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
|
||||
REQUIRE(std::string("primary") == tl.get_value_by_key("highway"));
|
||||
REQUIRE(nullptr == tl.get_value_by_key("name"));
|
||||
REQUIRE(std::string("foo") == tl.get_value_by_key("name", "foo"));
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list_from_func(buffer, [](osmium::builder::TagListBuilder& tlb) {
|
||||
tlb.add_tag("highway", "primary");
|
||||
tlb.add_tag("bridge", "true");
|
||||
});
|
||||
|
||||
REQUIRE(std::string("true") == tl["bridge"]);
|
||||
}
|
||||
REQUIRE(osmium::item_type::tag_list == tl.type());
|
||||
REQUIRE(2 == tl.size());
|
||||
REQUIRE(std::string("bridge") == std::next(tl.begin(), 1)->key());
|
||||
REQUIRE(std::string("true") == std::next(tl.begin(), 1)->value());
|
||||
}
|
||||
|
||||
SECTION("returns_value_by_key") {
|
||||
osmium::memory::Buffer buffer(10240);
|
||||
|
||||
const osmium::TagList& tl = osmium::builder::build_tag_list_from_func(buffer, [](osmium::builder::TagListBuilder& tlb) {
|
||||
tlb.add_tag("highway", "primary");
|
||||
tlb.add_tag("bridge", "true");
|
||||
});
|
||||
|
||||
REQUIRE(std::string("primary") == tl.get_value_by_key("highway"));
|
||||
REQUIRE(nullptr == tl.get_value_by_key("name"));
|
||||
REQUIRE(std::string("foo") == tl.get_value_by_key("name", "foo"));
|
||||
|
||||
REQUIRE(std::string("true") == tl["bridge"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ TEST_CASE("thread") {
|
||||
SECTION("can send job to thread pool") {
|
||||
auto& pool = osmium::thread::Pool::instance();
|
||||
result = 0;
|
||||
auto future = pool.submit(test_job_ok{});
|
||||
auto future = pool.submit(test_job_ok {});
|
||||
|
||||
// wait a bit for the other thread to get a chance to run
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
@@ -50,7 +50,7 @@ TEST_CASE("thread") {
|
||||
|
||||
SECTION("can send job to thread pool") {
|
||||
auto& pool = osmium::thread::Pool::instance();
|
||||
auto future = pool.submit(test_job_with_result{});
|
||||
auto future = pool.submit(test_job_with_result {});
|
||||
|
||||
REQUIRE(future.get() == 42);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ TEST_CASE("thread") {
|
||||
result = 0;
|
||||
|
||||
bool got_exception = false;
|
||||
auto future = pool.submit(test_job_throw{});
|
||||
auto future = pool.submit(test_job_throw {});
|
||||
|
||||
REQUIRE_THROWS_AS(future.get(), std::runtime_error);
|
||||
}
|
||||
|
||||
+20
-20
@@ -4,30 +4,30 @@
|
||||
|
||||
TEST_CASE("Double") {
|
||||
|
||||
SECTION("double2string") {
|
||||
std::string s1;
|
||||
osmium::util::double2string(s1, 1.123, 7);
|
||||
REQUIRE(s1 == "1.123");
|
||||
SECTION("double2string") {
|
||||
std::string s1;
|
||||
osmium::util::double2string(s1, 1.123, 7);
|
||||
REQUIRE(s1 == "1.123");
|
||||
|
||||
std::string s2;
|
||||
osmium::util::double2string(s2, 1.000, 7);
|
||||
REQUIRE(s2 == "1");
|
||||
std::string s2;
|
||||
osmium::util::double2string(s2, 1.000, 7);
|
||||
REQUIRE(s2 == "1");
|
||||
|
||||
std::string s3;
|
||||
osmium::util::double2string(s3, 0.0, 7);
|
||||
REQUIRE(s3 == "0");
|
||||
std::string s3;
|
||||
osmium::util::double2string(s3, 0.0, 7);
|
||||
REQUIRE(s3 == "0");
|
||||
|
||||
std::string s4;
|
||||
osmium::util::double2string(s4, 0.020, 7);
|
||||
REQUIRE(s4 == "0.02");
|
||||
std::string s4;
|
||||
osmium::util::double2string(s4, 0.020, 7);
|
||||
REQUIRE(s4 == "0.02");
|
||||
|
||||
std::string s5;
|
||||
osmium::util::double2string(s5, -0.020, 7);
|
||||
REQUIRE(s5 == "-0.02");
|
||||
std::string s5;
|
||||
osmium::util::double2string(s5, -0.020, 7);
|
||||
REQUIRE(s5 == "-0.02");
|
||||
|
||||
std::string s6;
|
||||
osmium::util::double2string(s6, -0.0, 7);
|
||||
REQUIRE(s6 == "-0");
|
||||
}
|
||||
std::string s6;
|
||||
osmium::util::double2string(s6, -0.0, 7);
|
||||
REQUIRE(s6 == "-0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+34
-34
@@ -6,43 +6,43 @@
|
||||
|
||||
TEST_CASE("Options") {
|
||||
|
||||
SECTION("set_simple") {
|
||||
osmium::util::Options o;
|
||||
o.set("foo", "bar");
|
||||
REQUIRE("bar" == o.get("foo"));
|
||||
REQUIRE("" == o.get("empty"));
|
||||
REQUIRE("default" == o.get("empty", "default"));
|
||||
REQUIRE(!o.is_true("foo"));
|
||||
REQUIRE(!o.is_true("empty"));
|
||||
REQUIRE(1 == o.size());
|
||||
}
|
||||
SECTION("set_simple") {
|
||||
osmium::util::Options o;
|
||||
o.set("foo", "bar");
|
||||
REQUIRE("bar" == o.get("foo"));
|
||||
REQUIRE("" == o.get("empty"));
|
||||
REQUIRE("default" == o.get("empty", "default"));
|
||||
REQUIRE(!o.is_true("foo"));
|
||||
REQUIRE(!o.is_true("empty"));
|
||||
REQUIRE(1 == o.size());
|
||||
}
|
||||
|
||||
SECTION("set_from_bool") {
|
||||
osmium::util::Options o;
|
||||
o.set("t", true);
|
||||
o.set("f", false);
|
||||
REQUIRE("true" == o.get("t"));
|
||||
REQUIRE("false" == o.get("f"));
|
||||
REQUIRE("" == o.get("empty"));
|
||||
REQUIRE(o.is_true("t"));
|
||||
REQUIRE(!o.is_true("f"));
|
||||
REQUIRE(2 == o.size());
|
||||
}
|
||||
SECTION("set_from_bool") {
|
||||
osmium::util::Options o;
|
||||
o.set("t", true);
|
||||
o.set("f", false);
|
||||
REQUIRE("true" == o.get("t"));
|
||||
REQUIRE("false" == o.get("f"));
|
||||
REQUIRE("" == o.get("empty"));
|
||||
REQUIRE(o.is_true("t"));
|
||||
REQUIRE(!o.is_true("f"));
|
||||
REQUIRE(2 == o.size());
|
||||
}
|
||||
|
||||
SECTION("set_from_single_string_with_equals") {
|
||||
osmium::util::Options o;
|
||||
o.set("foo=bar");
|
||||
REQUIRE("bar" == o.get("foo"));
|
||||
REQUIRE(1 == o.size());
|
||||
}
|
||||
SECTION("set_from_single_string_with_equals") {
|
||||
osmium::util::Options o;
|
||||
o.set("foo=bar");
|
||||
REQUIRE("bar" == o.get("foo"));
|
||||
REQUIRE(1 == o.size());
|
||||
}
|
||||
|
||||
SECTION("set_from_single_string_without_equals") {
|
||||
osmium::util::Options o;
|
||||
o.set("foo");
|
||||
REQUIRE("true" == o.get("foo"));
|
||||
REQUIRE(o.is_true("foo"));
|
||||
REQUIRE(1 == o.size());
|
||||
}
|
||||
SECTION("set_from_single_string_without_equals") {
|
||||
osmium::util::Options o;
|
||||
o.set("foo");
|
||||
REQUIRE("true" == o.get("foo"));
|
||||
REQUIRE(o.is_true("foo"));
|
||||
REQUIRE(1 == o.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+35
-35
@@ -4,54 +4,54 @@
|
||||
|
||||
TEST_CASE("split_string") {
|
||||
|
||||
SECTION("split_string string") {
|
||||
std::string str { "foo,baramba,baz" };
|
||||
std::vector<std::string> result = {"foo", "baramba", "baz"};
|
||||
SECTION("split_string string") {
|
||||
std::string str { "foo,baramba,baz" };
|
||||
std::vector<std::string> result = {"foo", "baramba", "baz"};
|
||||
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
|
||||
SECTION("split_string string without sep") {
|
||||
std::string str { "foo" };
|
||||
std::vector<std::string> result = {"foo"};
|
||||
SECTION("split_string string without sep") {
|
||||
std::string str { "foo" };
|
||||
std::vector<std::string> result = {"foo"};
|
||||
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
|
||||
SECTION("split_string string with empty at end") {
|
||||
std::string str { "foo,bar," };
|
||||
std::vector<std::string> result = {"foo", "bar", ""};
|
||||
SECTION("split_string string with empty at end") {
|
||||
std::string str { "foo,bar," };
|
||||
std::vector<std::string> result = {"foo", "bar", ""};
|
||||
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
|
||||
SECTION("split_string string with empty in middle") {
|
||||
std::string str { "foo,,bar" };
|
||||
std::vector<std::string> result = {"foo", "", "bar"};
|
||||
SECTION("split_string string with empty in middle") {
|
||||
std::string str { "foo,,bar" };
|
||||
std::vector<std::string> result = {"foo", "", "bar"};
|
||||
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
|
||||
SECTION("split_string string with empty at start") {
|
||||
std::string str { ",bar,baz" };
|
||||
std::vector<std::string> result = {"", "bar", "baz"};
|
||||
SECTION("split_string string with empty at start") {
|
||||
std::string str { ",bar,baz" };
|
||||
std::vector<std::string> result = {"", "bar", "baz"};
|
||||
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
|
||||
SECTION("split_string sep") {
|
||||
std::string str { "," };
|
||||
std::vector<std::string> result = {"", ""};
|
||||
SECTION("split_string sep") {
|
||||
std::string str { "," };
|
||||
std::vector<std::string> result = {"", ""};
|
||||
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
|
||||
SECTION("split_string empty string") {
|
||||
std::string str { "" };
|
||||
std::vector<std::string> result;
|
||||
SECTION("split_string empty string") {
|
||||
std::string str { "" };
|
||||
std::vector<std::string> result;
|
||||
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
REQUIRE(result == osmium::split_string(str, ','));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user