Update vendored vtzero dependency to v1.1.0 (#6871)
This commit is contained in:
+15233
-9213
File diff suppressed because it is too large
Load Diff
+49
-37
@@ -13,7 +13,7 @@
|
||||
#include <string>
|
||||
|
||||
static std::string open_tile(const std::string& path) {
|
||||
const auto fixtures_dir = std::getenv("FIXTURES_DIR");
|
||||
const auto* fixtures_dir = std::getenv("FIXTURES_DIR");
|
||||
if (fixtures_dir == nullptr) {
|
||||
std::cerr << "Set FIXTURES_DIR environment variable to the directory where the mvt fixtures are!\n";
|
||||
std::exit(2);
|
||||
@@ -25,8 +25,8 @@ static std::string open_tile(const std::string& path) {
|
||||
throw std::runtime_error{"could not open: '" + path + "'"};
|
||||
}
|
||||
|
||||
const std::string message{std::istreambuf_iterator<char>(stream.rdbuf()),
|
||||
std::istreambuf_iterator<char>()};
|
||||
std::string message{std::istreambuf_iterator<char>(stream.rdbuf()),
|
||||
std::istreambuf_iterator<char>()};
|
||||
|
||||
stream.close();
|
||||
return message;
|
||||
@@ -187,7 +187,7 @@ TEST_CASE("MVT test 004: Tile with single point with missing geometry") {
|
||||
std::string buffer{open_tile("004/tile.mvt")};
|
||||
vtzero::vector_tile tile{buffer};
|
||||
|
||||
REQUIRE_THROWS_AS(check_layer(tile), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(check_layer(tile), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 005: Tile with single point with broken tags array") {
|
||||
@@ -199,7 +199,7 @@ TEST_CASE("MVT test 005: Tile with single point with broken tags array") {
|
||||
auto layer = tile.next_layer();
|
||||
REQUIRE_FALSE(layer.empty());
|
||||
|
||||
REQUIRE_THROWS_AS(layer.next_feature(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(layer.next_feature(), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 006: Tile with single point with invalid GeomType") {
|
||||
@@ -210,7 +210,7 @@ TEST_CASE("MVT test 006: Tile with single point with invalid GeomType") {
|
||||
auto layer = tile.next_layer();
|
||||
REQUIRE_FALSE(layer.empty());
|
||||
|
||||
REQUIRE_THROWS_AS(layer.next_feature(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(layer.next_feature(), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 007: Layer version as string instead of as an int") {
|
||||
@@ -218,7 +218,7 @@ TEST_CASE("MVT test 007: Layer version as string instead of as an int") {
|
||||
vtzero::vector_tile tile{buffer};
|
||||
|
||||
REQUIRE(tile.count_layers() == 1);
|
||||
REQUIRE_THROWS_AS(tile.get_layer(0), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(tile.get_layer(0), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 008: Tile layer extent encoded as string") {
|
||||
@@ -226,7 +226,7 @@ TEST_CASE("MVT test 008: Tile layer extent encoded as string") {
|
||||
vtzero::vector_tile tile{buffer};
|
||||
|
||||
REQUIRE(tile.count_layers() == 1);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 009: Tile layer extent missing") {
|
||||
@@ -254,7 +254,7 @@ TEST_CASE("MVT test 010: Tile layer value is encoded as int, but pretends to be
|
||||
REQUIRE_FALSE(layer.empty());
|
||||
|
||||
const auto pv = layer.value(0);
|
||||
REQUIRE_THROWS_AS(pv.type(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(pv.type(), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 011: Tile layer value is encoded as unknown type") {
|
||||
@@ -266,7 +266,7 @@ TEST_CASE("MVT test 011: Tile layer value is encoded as unknown type") {
|
||||
REQUIRE_FALSE(layer.empty());
|
||||
|
||||
const auto pv = layer.value(0);
|
||||
REQUIRE_THROWS_AS(pv.type(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(pv.type(), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 012: Unknown layer version") {
|
||||
@@ -274,7 +274,7 @@ TEST_CASE("MVT test 012: Unknown layer version") {
|
||||
vtzero::vector_tile tile{buffer};
|
||||
|
||||
REQUIRE(tile.count_layers() == 1);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), const vtzero::version_exception&);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), vtzero::version_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 013: Tile with key in table encoded as int") {
|
||||
@@ -282,7 +282,7 @@ TEST_CASE("MVT test 013: Tile with key in table encoded as int") {
|
||||
vtzero::vector_tile tile{buffer};
|
||||
|
||||
REQUIRE(tile.count_layers() == 1);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 014: Tile layer without a name") {
|
||||
@@ -290,7 +290,7 @@ TEST_CASE("MVT test 014: Tile layer without a name") {
|
||||
vtzero::vector_tile tile{buffer};
|
||||
|
||||
REQUIRE(tile.count_layers() == 1);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 015: Two layers with the same name") {
|
||||
@@ -444,8 +444,8 @@ TEST_CASE("MVT test 023: Invalid layer: missing layer name") {
|
||||
vtzero::vector_tile tile{buffer};
|
||||
|
||||
REQUIRE(tile.count_layers() == 1);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(tile.get_layer_by_name("foo"), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(tile.next_layer(), vtzero::format_exception);
|
||||
REQUIRE_THROWS_AS(tile.get_layer_by_name("foo"), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 024: Missing layer version") {
|
||||
@@ -483,7 +483,7 @@ TEST_CASE("MVT test 026: Extra value type") {
|
||||
|
||||
const auto pvv = table[0];
|
||||
REQUIRE(pvv.valid());
|
||||
REQUIRE_THROWS_AS(pvv.type(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(pvv.type(), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 027: Layer with unused bool property value") {
|
||||
@@ -509,7 +509,7 @@ TEST_CASE("MVT test 030: Two geometry fields") {
|
||||
auto layer = tile.next_layer();
|
||||
REQUIRE_FALSE(layer.empty());
|
||||
|
||||
REQUIRE_THROWS_AS(layer.next_feature(), const vtzero::format_exception&);
|
||||
REQUIRE_THROWS_AS(layer.next_feature(), vtzero::format_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 032: Layer with single feature with string property value") {
|
||||
@@ -535,6 +535,18 @@ TEST_CASE("MVT test 032: Layer with single feature with string property value")
|
||||
REQUIRE(ii.key().value() == 0);
|
||||
REQUIRE(ii.value().value() == 0);
|
||||
REQUIRE_FALSE(feature.next_property_indexes());
|
||||
|
||||
int32_t sum = 0;
|
||||
int32_t count = 0;
|
||||
feature.for_each_property_indexes([&](vtzero::index_value_pair&& ivp) {
|
||||
sum += ivp.key().value();
|
||||
sum += ivp.value().value();
|
||||
++count;
|
||||
return true;
|
||||
});
|
||||
|
||||
REQUIRE(sum == 0);
|
||||
REQUIRE(count == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 033: Layer with single feature with float property value") {
|
||||
@@ -634,13 +646,13 @@ TEST_CASE("MVT test 038: Layer with all types of property value") {
|
||||
REQUIRE(vtab[5].sint_value() == -87948);
|
||||
REQUIRE(vtab[6].uint_value() == 87948);
|
||||
|
||||
REQUIRE_THROWS_AS(vtab[0].bool_value(), const vtzero::type_exception&);
|
||||
REQUIRE_THROWS_AS(vtab[0].int_value(), const vtzero::type_exception&);
|
||||
REQUIRE_THROWS_AS(vtab[0].double_value(), const vtzero::type_exception&);
|
||||
REQUIRE_THROWS_AS(vtab[0].float_value(), const vtzero::type_exception&);
|
||||
REQUIRE_THROWS_AS(vtab[0].sint_value(), const vtzero::type_exception&);
|
||||
REQUIRE_THROWS_AS(vtab[0].uint_value(), const vtzero::type_exception&);
|
||||
REQUIRE_THROWS_AS(vtab[1].string_value(), const vtzero::type_exception&);
|
||||
REQUIRE_THROWS_AS(vtab[0].bool_value(), vtzero::type_exception);
|
||||
REQUIRE_THROWS_AS(vtab[0].int_value(), vtzero::type_exception);
|
||||
REQUIRE_THROWS_AS(vtab[0].double_value(), vtzero::type_exception);
|
||||
REQUIRE_THROWS_AS(vtab[0].float_value(), vtzero::type_exception);
|
||||
REQUIRE_THROWS_AS(vtab[0].sint_value(), vtzero::type_exception);
|
||||
REQUIRE_THROWS_AS(vtab[0].uint_value(), vtzero::type_exception);
|
||||
REQUIRE_THROWS_AS(vtab[1].string_value(), vtzero::type_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 039: Default values are actually encoded in the tile") {
|
||||
@@ -659,7 +671,7 @@ TEST_CASE("MVT test 039: Default values are actually encoded in the tile") {
|
||||
REQUIRE(feature.geometry_type() == vtzero::GeomType::UNKNOWN);
|
||||
REQUIRE(feature.empty());
|
||||
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(feature.geometry(), geom_handler{}), const vtzero::geometry_exception&);
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(feature.geometry(), geom_handler{}), vtzero::geometry_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 040: Feature has tags that point to non-existent Key in the layer.") {
|
||||
@@ -671,7 +683,7 @@ TEST_CASE("MVT test 040: Feature has tags that point to non-existent Key in the
|
||||
REQUIRE(layer.num_features() == 1);
|
||||
auto feature = layer.next_feature();
|
||||
REQUIRE(feature.num_properties() == 1);
|
||||
REQUIRE_THROWS_AS(feature.next_property(), const vtzero::out_of_range_exception&);
|
||||
REQUIRE_THROWS_AS(feature.next_property(), vtzero::out_of_range_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 040: Feature has tags that point to non-existent Key in the layer decoded using next_property_indexes().") {
|
||||
@@ -683,7 +695,7 @@ TEST_CASE("MVT test 040: Feature has tags that point to non-existent Key in the
|
||||
REQUIRE(layer.num_features() == 1);
|
||||
auto feature = layer.next_feature();
|
||||
REQUIRE(feature.num_properties() == 1);
|
||||
REQUIRE_THROWS_AS(feature.next_property_indexes(), const vtzero::out_of_range_exception&);
|
||||
REQUIRE_THROWS_AS(feature.next_property_indexes(), vtzero::out_of_range_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 041: Tags encoded as floats instead of as ints") {
|
||||
@@ -694,7 +706,7 @@ TEST_CASE("MVT test 041: Tags encoded as floats instead of as ints") {
|
||||
auto layer = tile.next_layer();
|
||||
REQUIRE(layer.num_features() == 1);
|
||||
auto feature = layer.next_feature();
|
||||
REQUIRE_THROWS_AS(feature.next_property(), const vtzero::out_of_range_exception&);
|
||||
REQUIRE_THROWS_AS(feature.next_property(), vtzero::out_of_range_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 042: Feature has tags that point to non-existent Value in the layer.") {
|
||||
@@ -706,7 +718,7 @@ TEST_CASE("MVT test 042: Feature has tags that point to non-existent Value in th
|
||||
REQUIRE(layer.num_features() == 1);
|
||||
auto feature = layer.next_feature();
|
||||
REQUIRE(feature.num_properties() == 1);
|
||||
REQUIRE_THROWS_AS(feature.next_property(), const vtzero::out_of_range_exception&);
|
||||
REQUIRE_THROWS_AS(feature.next_property(), vtzero::out_of_range_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 043: A layer with six points that all share the same key but each has a unique value.") {
|
||||
@@ -747,7 +759,7 @@ TEST_CASE("MVT test 044: Geometry field begins with a ClosePath command, which i
|
||||
REQUIRE(feature);
|
||||
|
||||
const auto geometry = feature.geometry();
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), const vtzero::geometry_exception&);
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), vtzero::geometry_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 045: Invalid point geometry that includes a MoveTo command and only half of the xy coordinates") {
|
||||
@@ -762,7 +774,7 @@ TEST_CASE("MVT test 045: Invalid point geometry that includes a MoveTo command a
|
||||
REQUIRE(feature);
|
||||
|
||||
const auto geometry = feature.geometry();
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), const vtzero::geometry_exception&);
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), vtzero::geometry_exception);
|
||||
REQUIRE_THROWS_WITH(vtzero::decode_geometry(geometry, geom_handler{}), "too few points in geometry");
|
||||
}
|
||||
|
||||
@@ -798,7 +810,7 @@ TEST_CASE("MVT test 047: Invalid polygon with wrong ClosePath count 2 (must be c
|
||||
REQUIRE(feature);
|
||||
|
||||
const auto geometry = feature.geometry();
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), const vtzero::geometry_exception&);
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), vtzero::geometry_exception);
|
||||
REQUIRE_THROWS_WITH(vtzero::decode_geometry(geometry, geom_handler{}), "ClosePath command count is not 1");
|
||||
}
|
||||
|
||||
@@ -814,7 +826,7 @@ TEST_CASE("MVT test 048: Invalid polygon with wrong ClosePath count 0 (must be c
|
||||
REQUIRE(feature);
|
||||
|
||||
const auto geometry = feature.geometry();
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), const vtzero::geometry_exception&);
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), vtzero::geometry_exception);
|
||||
REQUIRE_THROWS_WITH(vtzero::decode_geometry(geometry, geom_handler{}), "ClosePath command count is not 1");
|
||||
}
|
||||
|
||||
@@ -870,7 +882,7 @@ TEST_CASE("MVT test 051: multipoint with a huge count value, useful for ensuring
|
||||
REQUIRE(feature);
|
||||
|
||||
const auto geometry = feature.geometry();
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), const vtzero::geometry_exception&);
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), vtzero::geometry_exception);
|
||||
REQUIRE_THROWS_WITH(vtzero::decode_geometry(geometry, geom_handler{}), "count too large");
|
||||
}
|
||||
|
||||
@@ -886,7 +898,7 @@ TEST_CASE("MVT test 052: multipoint with not enough points") {
|
||||
REQUIRE(feature);
|
||||
|
||||
const auto geometry = feature.geometry();
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), const vtzero::geometry_exception&);
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), vtzero::geometry_exception);
|
||||
}
|
||||
|
||||
TEST_CASE("MVT test 053: clipped square (exact extent): a polygon that covers the entire tile to the exact boundary") {
|
||||
@@ -981,7 +993,7 @@ TEST_CASE("MVT test 057: A point fixture with a gigantic MoveTo command. Can be
|
||||
REQUIRE(feature);
|
||||
|
||||
const auto geometry = feature.geometry();
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), const vtzero::geometry_exception&);
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), vtzero::geometry_exception);
|
||||
REQUIRE_THROWS_WITH(vtzero::decode_geometry(geometry, geom_handler{}), "count too large");
|
||||
}
|
||||
|
||||
@@ -997,7 +1009,7 @@ TEST_CASE("MVT test 058: A linestring fixture with a gigantic LineTo command") {
|
||||
REQUIRE(feature);
|
||||
|
||||
const auto geometry = feature.geometry();
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), const vtzero::geometry_exception&);
|
||||
REQUIRE_THROWS_AS(vtzero::decode_geometry(geometry, geom_handler{}), vtzero::geometry_exception);
|
||||
REQUIRE_THROWS_WITH(vtzero::decode_geometry(geometry, geom_handler{}), "count too large");
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -12,12 +12,15 @@ struct assert_error : public std::runtime_error {
|
||||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define vtzero_assert(x) if (!(x)) { throw assert_error{#x}; }
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define vtzero_assert_in_noexcept_function(x) if (!(x)) { got_an_assert = true; }
|
||||
|
||||
extern bool got_an_assert;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define REQUIRE_ASSERT(x) x; REQUIRE(got_an_assert); got_an_assert = false;
|
||||
|
||||
#include <vtzero/output.hpp>
|
||||
|
||||
+1
Submodule third_party/vtzero/test/mvt-fixtures added at a351144a7a
+199
-36
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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));
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ std::string load_test_tile() {
|
||||
throw std::runtime_error{"could not open: '" + path + "'"};
|
||||
}
|
||||
|
||||
const std::string message{std::istreambuf_iterator<char>(stream.rdbuf()),
|
||||
std::istreambuf_iterator<char>()};
|
||||
std::string message{std::istreambuf_iterator<char>(stream.rdbuf()),
|
||||
std::istreambuf_iterator<char>()};
|
||||
|
||||
stream.close();
|
||||
return message;
|
||||
|
||||
Reference in New Issue
Block a user