pull in latest osmcode/libosmium changes
This commit is contained in:
+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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user