Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add moveto-lineto command fixtures, more tests #31

Open
wants to merge 1 commit into
base: limit_reserve
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added test/fixtures/lineto-huge-linestring.mvt
Binary file not shown.
Binary file added test/fixtures/lineto-huge-polygon.mvt
Binary file not shown.
Binary file added test/fixtures/moveto-huge-linestring.mvt
Binary file not shown.
Binary file added test/fixtures/moveto-huge-point.mvt
Binary file not shown.
Binary file added test/fixtures/moveto-huge-polygon.mvt
Binary file not shown.
3 changes: 3 additions & 0 deletions test/fixtures/moveto-original.mvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
;x0

000000000000000"0000000(�000000"�����000000000
38 changes: 33 additions & 5 deletions test/unit/vector_tile.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,43 @@ TEST_CASE( "Read Feature-single-polygon.mvt" ) {
REQUIRE(stringify_geom(geom) == "25, 17");
}*/

TEST_CASE( "Prevent massive over allocation" ) {
std::string buffer = open_tile("test/test046.mvt");
TEST_CASE( "Prevent massive over allocation - moveto point" ) {
std::string buffer = open_tile("test/fixtures/moveto-huge-point.mvt");
mapbox::vector_tile::buffer tile(buffer);
auto const layer_names = tile.layerNames();
REQUIRE(layer_names.size() == 1);
REQUIRE(layer_names[0] == "0000000000");
auto const layer = tile.getLayer("0000000000");
REQUIRE(layer_names[0] == "hello");
auto const layer = tile.getLayer("hello");
REQUIRE(layer.featureCount() == 1);
REQUIRE(layer.getName() == "0000000000");
REQUIRE(layer.getName() == "hello");
auto const feature = mapbox::vector_tile::feature(layer.getFeature(0),layer);
mapbox::vector_tile::points_arrays_type geom = feature.getGeometries<mapbox::vector_tile::points_arrays_type>(1.0);
REQUIRE(geom.capacity() <= 655360);
}

TEST_CASE( "Prevent massive over allocation - moveto linestring" ) {
std::string buffer = open_tile("test/fixtures/moveto-huge-linestring.mvt");
mapbox::vector_tile::buffer tile(buffer);
auto const layer_names = tile.layerNames();
REQUIRE(layer_names.size() == 1);
REQUIRE(layer_names[0] == "hello");
auto const layer = tile.getLayer("hello");
REQUIRE(layer.featureCount() == 1);
REQUIRE(layer.getName() == "hello");
auto const feature = mapbox::vector_tile::feature(layer.getFeature(0),layer);
mapbox::vector_tile::points_arrays_type geom = feature.getGeometries<mapbox::vector_tile::points_arrays_type>(1.0);
REQUIRE(geom.capacity() <= 655360);
}

TEST_CASE( "Prevent massive over allocation - moveto polygon" ) {
std::string buffer = open_tile("test/fixtures/moveto-huge-linestring.mvt");
mapbox::vector_tile::buffer tile(buffer);
auto const layer_names = tile.layerNames();
REQUIRE(layer_names.size() == 1);
REQUIRE(layer_names[0] == "hello");
auto const layer = tile.getLayer("hello");
REQUIRE(layer.featureCount() == 1);
REQUIRE(layer.getName() == "hello");
auto const feature = mapbox::vector_tile::feature(layer.getFeature(0),layer);
mapbox::vector_tile::points_arrays_type geom = feature.getGeometries<mapbox::vector_tile::points_arrays_type>(1.0);
REQUIRE(geom.capacity() <= 655360);
Expand Down