Update vendored vtzero dependency to v1.1.0 (#6871)

This commit is contained in:
Dennis Luxen
2024-05-07 22:19:48 +02:00
committed by GitHub
parent 79de092bb2
commit 10237b8761
43 changed files with 16229 additions and 9674 deletions
+199 -36
View File
@@ -4,6 +4,10 @@
#include <vtzero/builder.hpp>
#include <vtzero/index.hpp>
#include <vtzero/output.hpp>
#include <vtzero/property_mapper.hpp>
#include <protozero/buffer_fixed.hpp>
#include <protozero/buffer_vector.hpp>
#include <cstdint>
#include <string>
@@ -47,8 +51,8 @@ TEST_CASE("Create tile from existing layers") {
}
TEST_CASE("Create layer based on existing layer") {
const auto buffer = load_test_tile();
vtzero::vector_tile tile{buffer};
const auto orig_tile_buffer = load_test_tile();
vtzero::vector_tile tile{orig_tile_buffer};
const auto layer = tile.get_layer_by_name("place_label");
vtzero::tile_builder tbuilder;
@@ -58,7 +62,36 @@ TEST_CASE("Create layer based on existing layer") {
fbuilder.add_point(10, 20);
fbuilder.commit();
const std::string data = tbuilder.serialize();
std::string data;
SECTION("use std::string buffer") {
data = tbuilder.serialize();
}
SECTION("use std::string buffer as parameter") {
tbuilder.serialize(data);
}
SECTION("use std::vector<char> buffer as parameter") {
std::vector<char> buffer;
tbuilder.serialize(buffer);
std::copy(buffer.cbegin(), buffer.cend(), std::back_inserter(data));
}
SECTION("use fixed size buffer on stack") {
std::array<char, 1000> buffer = {{0}};
protozero::fixed_size_buffer_adaptor adaptor{buffer};
tbuilder.serialize(adaptor);
std::copy_n(adaptor.data(), adaptor.size(), std::back_inserter(data));
}
SECTION("use fixed size buffer on heap") {
std::vector<char> buffer(1000);
protozero::fixed_size_buffer_adaptor adaptor{buffer};
tbuilder.serialize(adaptor);
std::copy_n(adaptor.data(), adaptor.size(), std::back_inserter(data));
}
vtzero::vector_tile new_tile{data};
const auto new_layer = new_tile.next_layer();
REQUIRE(std::string(new_layer.name()) == "place_label");
@@ -131,9 +164,9 @@ TEST_CASE("Committing a feature succeeds after a geometry was added") {
fbuilder.rollback();
}
REQUIRE_THROWS_AS(fbuilder.set_id(10), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_point(20, 20), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_property("x", "y"), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.set_id(10), assert_error);
REQUIRE_THROWS_AS(fbuilder.add_point(20, 20), assert_error);
REQUIRE_THROWS_AS(fbuilder.add_property("x", "y"), assert_error);
}
const std::string data = tbuilder.serialize();
@@ -155,13 +188,13 @@ TEST_CASE("Committing a feature fails with assert if no geometry was added") {
SECTION("explicit immediate commit") {
vtzero::point_feature_builder fbuilder{lbuilder};
REQUIRE_THROWS_AS(fbuilder.commit(), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.commit(), assert_error);
}
SECTION("explicit commit after setting id") {
vtzero::point_feature_builder fbuilder{lbuilder};
fbuilder.set_id(2);
REQUIRE_THROWS_AS(fbuilder.commit(), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.commit(), assert_error);
}
}
@@ -238,25 +271,22 @@ TEST_CASE("Rollback feature") {
REQUIRE_FALSE(feature);
}
static vtzero::layer next_nonempty_layer(vtzero::vector_tile& tile) {
while (auto layer = tile.next_layer()) {
if (layer && !layer.empty()) {
return layer;
}
}
return vtzero::layer{};
}
static bool vector_tile_equal(const std::string& t1, const std::string& t2) {
vtzero::vector_tile vt1{t1};
vtzero::vector_tile vt2{t2};
for (auto l1 = vt1.next_layer(), l2 = vt2.next_layer();
l1 && l2;
l1 = vt1.next_layer(), l2 = vt2.next_layer()) {
if (l1.empty()) {
l1 = vt1.next_layer();
if (!l1) {
return true;
}
}
if (l2.empty()) {
l2 = vt2.next_layer();
if (!l2) {
return true;
}
}
for (auto l1 = next_nonempty_layer(vt1), l2 = next_nonempty_layer(vt2);
l1 || l2;
l1 = next_nonempty_layer(vt1), l2 = next_nonempty_layer(vt2)) {
if (!l1 ||
!l2 ||
@@ -268,18 +298,23 @@ static bool vector_tile_equal(const std::string& t1, const std::string& t2) {
}
for (auto f1 = l1.next_feature(), f2 = l2.next_feature();
f1 && f2;
f1 || f2;
f1 = l1.next_feature(), f2 = l2.next_feature()) {
if (f1.id() != f2.id() ||
if (!f1 ||
!f2 ||
f1.id() != f2.id() ||
f1.geometry_type() != f2.geometry_type() ||
f1.num_properties() != f2.num_properties() ||
f1.geometry().data() != f2.geometry().data()) {
return false;
}
for (auto p1 = f1.next_property(), p2 = f2.next_property();
p1 && p2;
p1 || p2;
p1 = f1.next_property(), p2 = f2.next_property()) {
if (p1.key() != p2.key() || p1.value() != p2.value()) {
if (!p1 ||
!p2 ||
p1.key() != p2.key() ||
p1.value() != p2.value()) {
return false;
}
}
@@ -289,6 +324,16 @@ static bool vector_tile_equal(const std::string& t1, const std::string& t2) {
return true;
}
TEST_CASE("vector_tile_equal") {
REQUIRE(vector_tile_equal("", ""));
const auto buffer = load_test_tile();
REQUIRE(buffer.size() == 269388);
REQUIRE(vector_tile_equal(buffer, buffer));
REQUIRE_FALSE(vector_tile_equal(buffer, ""));
}
TEST_CASE("Copy tile") {
const auto buffer = load_test_tile();
vtzero::vector_tile tile{buffer};
@@ -316,11 +361,31 @@ TEST_CASE("Copy tile using geometry_feature_builder") {
vtzero::layer_builder lbuilder{tbuilder, layer};
while (auto feature = layer.next_feature()) {
vtzero::geometry_feature_builder fbuilder{lbuilder};
fbuilder.set_id(feature.id());
fbuilder.copy_id(feature);
fbuilder.set_geometry(feature.geometry());
while (auto property = feature.next_property()) {
fbuilder.add_property(property.key(), property.value());
}
fbuilder.copy_properties(feature);
fbuilder.commit();
}
}
const std::string data = tbuilder.serialize();
REQUIRE(vector_tile_equal(buffer, data));
}
TEST_CASE("Copy tile using geometry_feature_builder and property_mapper") {
const auto buffer = load_test_tile();
vtzero::vector_tile tile{buffer};
vtzero::tile_builder tbuilder;
while (auto layer = tile.next_layer()) {
vtzero::layer_builder lbuilder{tbuilder, layer};
vtzero::property_mapper mapper{layer, lbuilder};
while (auto feature = layer.next_feature()) {
vtzero::geometry_feature_builder fbuilder{lbuilder};
fbuilder.copy_id(feature);
fbuilder.set_geometry(feature.geometry());
fbuilder.copy_properties(feature, mapper);
fbuilder.commit();
}
}
@@ -360,7 +425,105 @@ TEST_CASE("Copy only point geometries using geometry_feature_builder") {
n = 0;
vtzero::vector_tile result_tile{data};
while (auto layer = result_tile.next_layer()) {
while (layer.next_feature()) {
++n;
}
}
REQUIRE(n == 17);
}
struct points_to_vector {
std::vector<vtzero::point> m_points{};
void points_begin(const uint32_t count) {
m_points.reserve(count);
}
void points_point(const vtzero::point point) {
m_points.push_back(point);
}
void points_end() const {
}
const std::vector<vtzero::point>& result() const {
return m_points;
}
}; // struct points_to_vector
TEST_CASE("Copy only point geometries using point_feature_builder") {
const auto buffer = load_test_tile();
vtzero::vector_tile tile{buffer};
vtzero::tile_builder tbuilder;
int n = 0;
while (auto layer = tile.next_layer()) {
vtzero::layer_builder lbuilder{tbuilder, layer};
while (auto feature = layer.next_feature()) {
vtzero::point_feature_builder fbuilder{lbuilder};
fbuilder.copy_id(feature);
if (feature.geometry().type() == vtzero::GeomType::POINT) {
const auto points = decode_point_geometry(feature.geometry(), points_to_vector{});
fbuilder.add_points_from_container(points);
fbuilder.copy_properties(feature);
fbuilder.commit();
++n;
} else {
fbuilder.rollback();
}
}
}
REQUIRE(n == 17);
const std::string data = tbuilder.serialize();
n = 0;
vtzero::vector_tile result_tile{data};
while (auto layer = result_tile.next_layer()) {
while (layer.next_feature()) {
++n;
}
}
REQUIRE(n == 17);
}
TEST_CASE("Copy only point geometries using point_feature_builder using property_mapper") {
const auto buffer = load_test_tile();
vtzero::vector_tile tile{buffer};
vtzero::tile_builder tbuilder;
int n = 0;
while (auto layer = tile.next_layer()) {
vtzero::layer_builder lbuilder{tbuilder, layer};
vtzero::property_mapper mapper{layer, lbuilder};
while (auto feature = layer.next_feature()) {
vtzero::point_feature_builder fbuilder{lbuilder};
fbuilder.copy_id(feature);
if (feature.geometry().type() == vtzero::GeomType::POINT) {
const auto points = decode_point_geometry(feature.geometry(), points_to_vector{});
fbuilder.add_points_from_container(points);
fbuilder.copy_properties(feature, mapper);
fbuilder.commit();
++n;
} else {
fbuilder.rollback();
}
}
}
REQUIRE(n == 17);
const std::string data = tbuilder.serialize();
n = 0;
vtzero::vector_tile result_tile{data};
while (auto layer = result_tile.next_layer()) {
while (layer.next_feature()) {
++n;
}
}
@@ -373,15 +536,15 @@ TEST_CASE("Build point feature from container with too many points") {
// fake container pretending to contain too many points
struct test_container {
std::size_t size() const noexcept {
return 1ul << 29u;
static std::size_t size() noexcept {
return 1UL << 29U;
}
vtzero::point* begin() const noexcept {
static vtzero::point* begin() noexcept {
return nullptr;
}
vtzero::point* end() const noexcept {
static vtzero::point* end() noexcept {
return nullptr;
}
@@ -394,7 +557,7 @@ TEST_CASE("Build point feature from container with too many points") {
fbuilder.set_id(1);
test_container tc;
REQUIRE_THROWS_AS(fbuilder.add_points_from_container(tc), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(fbuilder.add_points_from_container(tc), vtzero::geometry_exception);
}
TEST_CASE("Moving a feature builder is allowed") {
+6 -6
View File
@@ -95,13 +95,13 @@ TEST_CASE("Calling add_linestring() with bad values throws assert") {
vtzero::linestring_feature_builder fbuilder{lbuilder};
SECTION("0") {
REQUIRE_THROWS_AS(fbuilder.add_linestring(0), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_linestring(0), assert_error);
}
SECTION("1") {
REQUIRE_THROWS_AS(fbuilder.add_linestring(1), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_linestring(1), assert_error);
}
SECTION("2^29") {
REQUIRE_THROWS_AS(fbuilder.add_linestring(1ul << 29u), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_linestring(1UL << 29U), assert_error);
}
}
@@ -180,7 +180,7 @@ TEST_CASE("Calling linestring_feature_builder::set_point() throws assert") {
vtzero::layer_builder lbuilder{tbuilder, "test"};
vtzero::linestring_feature_builder fbuilder{lbuilder};
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), assert_error);
}
TEST_CASE("Calling linestring_feature_builder::set_point() with same point throws") {
@@ -190,7 +190,7 @@ TEST_CASE("Calling linestring_feature_builder::set_point() with same point throw
fbuilder.add_linestring(2);
fbuilder.set_point(10, 10);
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), vtzero::geometry_exception);
}
TEST_CASE("Calling linestring_feature_builder::set_point() too often throws assert") {
@@ -201,7 +201,7 @@ TEST_CASE("Calling linestring_feature_builder::set_point() too often throws asse
fbuilder.add_linestring(2);
fbuilder.set_point(10, 20);
fbuilder.set_point(20, 20);
REQUIRE_THROWS_AS(fbuilder.set_point(30, 20), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.set_point(30, 20), assert_error);
}
TEST_CASE("Add linestring from container") {
+9 -9
View File
@@ -106,10 +106,10 @@ TEST_CASE("Calling add_points() with bad values throws assert") {
vtzero::point_feature_builder fbuilder{lbuilder};
SECTION("0") {
REQUIRE_THROWS_AS(fbuilder.add_points(0), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_points(0), assert_error);
}
SECTION("2^29") {
REQUIRE_THROWS_AS(fbuilder.add_points(1ul << 29u), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_points(1UL << 29U), assert_error);
}
}
@@ -178,13 +178,13 @@ TEST_CASE("Calling add_point() and then other geometry functions throws assert")
fbuilder.add_point(10, 20);
SECTION("add_point()") {
REQUIRE_THROWS_AS(fbuilder.add_point(10, 20), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_point(10, 20), assert_error);
}
SECTION("add_points()") {
REQUIRE_THROWS_AS(fbuilder.add_points(2), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_points(2), assert_error);
}
SECTION("set_point()") {
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), assert_error);
}
}
@@ -193,7 +193,7 @@ TEST_CASE("Calling point_feature_builder::set_point() throws assert") {
vtzero::layer_builder lbuilder{tbuilder, "test"};
vtzero::point_feature_builder fbuilder{lbuilder};
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), assert_error);
}
TEST_CASE("Calling add_points() and then other geometry functions throws assert") {
@@ -204,10 +204,10 @@ TEST_CASE("Calling add_points() and then other geometry functions throws assert"
fbuilder.add_points(2);
SECTION("add_point()") {
REQUIRE_THROWS_AS(fbuilder.add_point(10, 20), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_point(10, 20), assert_error);
}
SECTION("add_points()") {
REQUIRE_THROWS_AS(fbuilder.add_points(2), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_points(2), assert_error);
}
}
@@ -219,7 +219,7 @@ TEST_CASE("Calling point_feature_builder::set_point() too often throws assert")
fbuilder.add_points(2);
fbuilder.set_point(10, 20);
fbuilder.set_point(20, 20);
REQUIRE_THROWS_AS(fbuilder.set_point(30, 20), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.set_point(30, 20), assert_error);
}
TEST_CASE("Add points from container") {
+11 -11
View File
@@ -96,19 +96,19 @@ TEST_CASE("Calling add_ring() with bad values throws assert") {
vtzero::polygon_feature_builder fbuilder{lbuilder};
SECTION("0") {
REQUIRE_THROWS_AS(fbuilder.add_ring(0), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_ring(0), assert_error);
}
SECTION("1") {
REQUIRE_THROWS_AS(fbuilder.add_ring(1), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_ring(1), assert_error);
}
SECTION("2") {
REQUIRE_THROWS_AS(fbuilder.add_ring(2), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_ring(2), assert_error);
}
SECTION("3") {
REQUIRE_THROWS_AS(fbuilder.add_ring(3), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_ring(3), assert_error);
}
SECTION("2^29") {
REQUIRE_THROWS_AS(fbuilder.add_ring(1ul << 29u), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.add_ring(1UL << 29U), assert_error);
}
}
@@ -198,10 +198,10 @@ TEST_CASE("Calling polygon_feature_builder::set_point()/close_ring() throws asse
vtzero::polygon_feature_builder fbuilder{lbuilder};
SECTION("set_point") {
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), assert_error);
}
SECTION("close_ring") {
REQUIRE_THROWS_AS(fbuilder.close_ring(), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.close_ring(), assert_error);
}
}
@@ -217,10 +217,10 @@ TEST_CASE("Calling polygon_feature_builder::set_point()/close_ring() too often t
fbuilder.set_point(10, 20);
SECTION("set_point") {
REQUIRE_THROWS_AS(fbuilder.set_point(50, 20), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.set_point(50, 20), assert_error);
}
SECTION("close_ring") {
REQUIRE_THROWS_AS(fbuilder.close_ring(), const assert_error&);
REQUIRE_THROWS_AS(fbuilder.close_ring(), assert_error);
}
}
@@ -231,7 +231,7 @@ TEST_CASE("Calling polygon_feature_builder::set_point() with same point throws")
fbuilder.add_ring(4);
fbuilder.set_point(10, 10);
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(fbuilder.set_point(10, 10), vtzero::geometry_exception);
}
TEST_CASE("Calling polygon_feature_builder::set_point() creating unclosed ring throws") {
@@ -243,7 +243,7 @@ TEST_CASE("Calling polygon_feature_builder::set_point() creating unclosed ring t
fbuilder.set_point(10, 10);
fbuilder.set_point(10, 20);
fbuilder.set_point(20, 20);
REQUIRE_THROWS_AS(fbuilder.set_point(20, 30), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(fbuilder.set_point(20, 30), vtzero::geometry_exception);
}
TEST_CASE("Add polygon from container") {
+10 -10
View File
@@ -18,7 +18,7 @@ TEST_CASE("geometry_decoder") {
REQUIRE(decoder.count() == 0);
REQUIRE(decoder.done());
REQUIRE_FALSE(decoder.next_command(vtzero::detail::CommandId::MOVE_TO));
REQUIRE_THROWS_AS(decoder.next_point(), const assert_error&);
REQUIRE_THROWS_AS(decoder.next_point(), assert_error);
}
TEST_CASE("geometry_decoder with point") {
@@ -28,10 +28,10 @@ TEST_CASE("geometry_decoder with point") {
REQUIRE(decoder.count() == 0);
REQUIRE_FALSE(decoder.done());
REQUIRE_THROWS_AS(decoder.next_point(), const assert_error&);
REQUIRE_THROWS_AS(decoder.next_point(), assert_error);
SECTION("trying to get LineTo command") {
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::LINE_TO), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::LINE_TO), vtzero::geometry_exception);
}
SECTION("trying to get ClosePath command") {
@@ -40,7 +40,7 @@ TEST_CASE("geometry_decoder with point") {
SECTION("trying to get MoveTo command") {
REQUIRE(decoder.next_command(vtzero::detail::CommandId::MOVE_TO));
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::MOVE_TO), const assert_error&);
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::MOVE_TO), assert_error);
REQUIRE(decoder.count() == 1);
REQUIRE(decoder.next_point() == vtzero::point(25, 17));
@@ -67,7 +67,7 @@ TEST_CASE("geometry_decoder with incomplete point") {
REQUIRE(decoder.next_command(vtzero::detail::CommandId::MOVE_TO));
REQUIRE(decoder.count() == 1);
REQUIRE_THROWS_AS(decoder.next_point(), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(decoder.next_point(), vtzero::geometry_exception);
}
TEST_CASE("geometry_decoder with multipoint") {
@@ -195,7 +195,7 @@ TEST_CASE("geometry_decoder with polygon with wrong ClosePath count 2") {
REQUIRE(decoder.next_command(vtzero::detail::CommandId::LINE_TO));
REQUIRE(decoder.next_point() == vtzero::point(8, 12));
REQUIRE(decoder.next_point() == vtzero::point(20, 34));
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::CLOSE_PATH), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::CLOSE_PATH), vtzero::geometry_exception);
REQUIRE_THROWS_WITH(decoder.next_command(vtzero::detail::CommandId::CLOSE_PATH), "ClosePath command count is not 1");
}
@@ -211,7 +211,7 @@ TEST_CASE("geometry_decoder with polygon with wrong ClosePath count 0") {
REQUIRE(decoder.next_command(vtzero::detail::CommandId::LINE_TO));
REQUIRE(decoder.next_point() == vtzero::point(8, 12));
REQUIRE(decoder.next_point() == vtzero::point(20, 34));
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::CLOSE_PATH), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::CLOSE_PATH), vtzero::geometry_exception);
REQUIRE_THROWS_WITH(decoder.next_command(vtzero::detail::CommandId::CLOSE_PATH), "ClosePath command count is not 1");
}
@@ -312,14 +312,14 @@ TEST_CASE("geometry_decoder decoding linestring with int32 overflow in y coordin
}
TEST_CASE("geometry_decoder with multipoint with a huge count") {
const uint32_t huge_value = (1ul << 29u) - 1;
const uint32_t huge_value = (1UL << 29U) - 1;
const container g = {vtzero::detail::command_move_to(huge_value), 10, 10};
vtzero::detail::geometry_decoder<iterator> decoder{g.cbegin(), g.cend(), g.size() / 2};
REQUIRE(decoder.count() == 0);
REQUIRE_FALSE(decoder.done());
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::MOVE_TO), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::MOVE_TO), vtzero::geometry_exception);
}
TEST_CASE("geometry_decoder with multipoint with not enough points") {
@@ -329,6 +329,6 @@ TEST_CASE("geometry_decoder with multipoint with not enough points") {
REQUIRE(decoder.count() == 0);
REQUIRE_FALSE(decoder.done());
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::MOVE_TO), const vtzero::geometry_exception&);
REQUIRE_THROWS_AS(decoder.next_command(vtzero::detail::CommandId::MOVE_TO), vtzero::geometry_exception);
}
+7 -7
View File
@@ -64,7 +64,7 @@ TEST_CASE("Calling decode_linestring_geometry() with a point geometry fails") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_linestring(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_linestring(dummy_geom_handler{}),
@@ -78,7 +78,7 @@ TEST_CASE("Calling decode_linestring_geometry() with a polygon geometry fails")
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_linestring(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_linestring(dummy_geom_handler{}),
@@ -92,7 +92,7 @@ TEST_CASE("Calling decode_linestring_geometry() with something other than MoveTo
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_linestring(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_linestring(dummy_geom_handler{}),
@@ -106,7 +106,7 @@ TEST_CASE("Calling decode_linestring_geometry() with a count of 0") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_linestring(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_linestring(dummy_geom_handler{}),
@@ -120,7 +120,7 @@ TEST_CASE("Calling decode_linestring_geometry() with a count of 2") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_linestring(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_linestring(dummy_geom_handler{}),
@@ -135,7 +135,7 @@ TEST_CASE("Calling decode_linestring_geometry() with 2nd command not a LineTo")
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_linestring(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_linestring(dummy_geom_handler{}),
@@ -150,7 +150,7 @@ TEST_CASE("Calling decode_linestring_geometry() with LineTo and 0 count") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_linestring(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_linestring(dummy_geom_handler{}),
+6 -6
View File
@@ -39,7 +39,7 @@ TEST_CASE("Calling decode_point() with empty input") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_point(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_point(dummy_geom_handler{}),
@@ -69,7 +69,7 @@ TEST_CASE("Calling decode_point() with a linestring geometry fails") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_point(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_point(dummy_geom_handler{}),
@@ -83,7 +83,7 @@ TEST_CASE("Calling decode_point() with a polygon geometry fails") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_point(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_point(dummy_geom_handler{}),
@@ -97,7 +97,7 @@ TEST_CASE("Calling decode_point() with something other than MoveTo command") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_point(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_point(dummy_geom_handler{}),
@@ -111,7 +111,7 @@ TEST_CASE("Calling decode_point() with a count of 0") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_point(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_point(dummy_geom_handler{}),
@@ -125,7 +125,7 @@ TEST_CASE("Calling decode_point() with more data then expected") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_point(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_point(dummy_geom_handler{}),
+7 -7
View File
@@ -74,7 +74,7 @@ TEST_CASE("Calling decode_polygon_geometry() with a point geometry fails") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_polygon(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_polygon(dummy_geom_handler{}),
@@ -88,7 +88,7 @@ TEST_CASE("Calling decode_polygon_geometry() with a linestring geometry fails")
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_polygon(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_polygon(dummy_geom_handler{}),
@@ -102,7 +102,7 @@ TEST_CASE("Calling decode_polygon_geometry() with something other than MoveTo co
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_polygon(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_polygon(dummy_geom_handler{}),
@@ -116,7 +116,7 @@ TEST_CASE("Calling decode_polygon_geometry() with a count of 0") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_polygon(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_polygon(dummy_geom_handler{}),
@@ -130,7 +130,7 @@ TEST_CASE("Calling decode_polygon_geometry() with a count of 2") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_polygon(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_polygon(dummy_geom_handler{}),
@@ -145,7 +145,7 @@ TEST_CASE("Calling decode_polygon_geometry() with 2nd command not a LineTo") {
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_polygon(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_polygon(dummy_geom_handler{}),
@@ -183,7 +183,7 @@ TEST_CASE("Calling decode_polygon_geometry() with 3nd command not a ClosePath")
SECTION("check exception type") {
REQUIRE_THROWS_AS(decoder.decode_polygon(dummy_geom_handler{}),
const vtzero::geometry_exception&);
vtzero::geometry_exception);
}
SECTION("check exception message") {
REQUIRE_THROWS_WITH(decoder.decode_polygon(dummy_geom_handler{}),
+4 -4
View File
@@ -14,13 +14,13 @@ TEST_CASE("add keys to layer using key index built into layer") {
vtzero::tile_builder tbuilder;
vtzero::layer_builder lbuilder{tbuilder, "test"};
for (int n = 0; n < max_keys; ++n) {
for (uint32_t n = 0; n < max_keys; ++n) {
const auto key = std::to_string(n);
const auto idx = lbuilder.add_key(key);
REQUIRE(n == idx.value());
}
for (int n = 0; n < max_keys; n += 2) {
for (uint32_t n = 0; n < max_keys; n += 2) {
const auto key = std::to_string(n);
const auto idx = lbuilder.add_key(key);
REQUIRE(n == idx.value());
@@ -33,13 +33,13 @@ TEST_CASE("add values to layer using value index built into layer") {
vtzero::tile_builder tbuilder;
vtzero::layer_builder lbuilder{tbuilder, "test"};
for (int n = 0; n < max_values; ++n) {
for (uint32_t n = 0; n < max_values; ++n) {
const auto value = std::to_string(n);
const auto idx = lbuilder.add_value(vtzero::encoded_property_value{value});
REQUIRE(n == idx.value());
}
for (int n = 0; n < max_values; n += 2) {
for (uint32_t n = 0; n < max_values; n += 2) {
const auto value = std::to_string(n);
const auto idx = lbuilder.add_value(vtzero::encoded_property_value{value});
REQUIRE(n == idx.value());
+9 -9
View File
@@ -19,14 +19,14 @@ TEST_CASE("default constructed layer") {
REQUIRE(layer.empty());
REQUIRE(layer.num_features() == 0);
REQUIRE_THROWS_AS(layer.key_table(), const assert_error&);
REQUIRE_THROWS_AS(layer.value_table(), const assert_error&);
REQUIRE_THROWS_AS(layer.key_table(), assert_error);
REQUIRE_THROWS_AS(layer.value_table(), assert_error);
REQUIRE_THROWS_AS(layer.key(0), const assert_error&);
REQUIRE_THROWS_AS(layer.value(0), const assert_error&);
REQUIRE_THROWS_AS(layer.key(0), assert_error);
REQUIRE_THROWS_AS(layer.value(0), assert_error);
REQUIRE_THROWS_AS(layer.get_feature_by_id(0), const assert_error&);
REQUIRE_THROWS_AS(layer.next_feature(), const assert_error&);
REQUIRE_THROWS_AS(layer.get_feature_by_id(0), assert_error);
REQUIRE_THROWS_AS(layer.next_feature(), assert_error);
REQUIRE_ASSERT(layer.reset_feature());
}
@@ -60,13 +60,13 @@ TEST_CASE("read a layer") {
REQUIRE(layer.key(1) == "oneway");
REQUIRE(layer.key(2) == "osm_id");
REQUIRE(layer.key(3) == "type");
REQUIRE_THROWS_AS(layer.key(4), const vtzero::out_of_range_exception&);
REQUIRE_THROWS_AS(layer.key(4), vtzero::out_of_range_exception);
REQUIRE(layer.value(0).string_value() == "main");
REQUIRE(layer.value(1).int_value() == 0);
REQUIRE(layer.value(2).string_value() == "primary");
REQUIRE(layer.value(3).string_value() == "tertiary");
REQUIRE_THROWS_AS(layer.value(4), const vtzero::out_of_range_exception&);
REQUIRE_THROWS_AS(layer.value(4), vtzero::out_of_range_exception);
}
TEST_CASE("access features in a layer by id") {
@@ -99,7 +99,7 @@ TEST_CASE("iterate over all features in a layer") {
std::size_t count = 0;
SECTION("external iterator") {
while (auto feature = layer.next_feature()) {
while (layer.next_feature()) {
++count;
}
}
+8 -8
View File
@@ -69,7 +69,7 @@ struct string_conv {
s(std::to_string(value)) {
}
explicit operator std::string() {
explicit operator std::string() const {
return s;
}
@@ -94,11 +94,11 @@ TEST_CASE("default constructed property_value") {
}
TEST_CASE("empty property_value") {
char x[1] = {0};
vtzero::data_view dv{x, 0};
char x = 0;
vtzero::data_view dv{&x, 0};
vtzero::property_value pv{dv};
REQUIRE(pv.valid());
REQUIRE_THROWS_AS(pv.type(), const vtzero::format_exception&);
REQUIRE_THROWS_AS(pv.type(), vtzero::format_exception);
}
TEST_CASE("string value") {
@@ -128,7 +128,7 @@ TEST_CASE("string value") {
}
TEST_CASE("float value") {
vtzero::encoded_property_value epv{1.2f};
vtzero::encoded_property_value epv{1.2F};
vtzero::property_value pv{epv.data()};
REQUIRE(pv.float_value() == Approx(1.2));
@@ -318,8 +318,8 @@ TEST_CASE("create encoded property values from different string types") {
}
TEST_CASE("create encoded property values from different floating point types") {
vtzero::encoded_property_value f1{vtzero::float_value_type{3.2f}};
vtzero::encoded_property_value f2{3.2f};
vtzero::encoded_property_value f1{vtzero::float_value_type{3.2F}};
vtzero::encoded_property_value f2{3.2F};
vtzero::encoded_property_value d1{vtzero::double_value_type{3.2}};
vtzero::encoded_property_value d2{3.2};
@@ -361,7 +361,7 @@ TEST_CASE("create encoded property values from different integer types") {
vtzero::property_value pvu{u1.data()};
vtzero::property_value pvs{s1.data()};
REQUIRE(pvi.int_value() == pvu.uint_value());
REQUIRE(pvi.int_value() == static_cast<int64_t>(pvu.uint_value()));
REQUIRE(pvi.int_value() == pvs.sint_value());
}
+1 -1
View File
@@ -22,7 +22,7 @@ TEST_CASE("default constructed float_value_type") {
}
TEST_CASE("float_value_type with value") {
float x = 2.7f;
float x = 2.7F;
vtzero::float_value_type v{x};
REQUIRE(v.value == Approx(x));
}