From 8eddf4c9984a3f9cd4f745eb120096083bd18916 Mon Sep 17 00:00:00 2001 From: mapsam Date: Tue, 12 Dec 2017 15:26:31 -0800 Subject: [PATCH] add moveto-lineto command fixtures, more tests --- test/fixtures/lineto-huge-linestring.mvt | Bin 0 -> 100 bytes test/fixtures/lineto-huge-polygon.mvt | Bin 0 -> 98 bytes test/fixtures/moveto-huge-linestring.mvt | Bin 0 -> 100 bytes test/fixtures/moveto-huge-point.mvt | Bin 0 -> 90 bytes test/fixtures/moveto-huge-polygon.mvt | Bin 0 -> 98 bytes test/fixtures/moveto-original.mvt | 3 ++ test/unit/vector_tile.test.cpp | 38 ++++++++++++++++++++--- 7 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 test/fixtures/lineto-huge-linestring.mvt create mode 100644 test/fixtures/lineto-huge-polygon.mvt create mode 100644 test/fixtures/moveto-huge-linestring.mvt create mode 100644 test/fixtures/moveto-huge-point.mvt create mode 100644 test/fixtures/moveto-huge-polygon.mvt create mode 100644 test/fixtures/moveto-original.mvt diff --git a/test/fixtures/lineto-huge-linestring.mvt b/test/fixtures/lineto-huge-linestring.mvt new file mode 100644 index 0000000000000000000000000000000000000000..841e1548ad07c57be4243492da28aef6db7e8363 GIT binary patch literal 100 zcmb12s$k+`%}CA3$rqC5s1{;kV31%^669oI`Sl+P7#Rcv7^GP85_40P47v1^GSd}u uGV@a7OY#+x^K)|(^HLNt^GZ_FQ;QVR@{1HoGBS(73W`gLGV{_k8WaFqG$Kg= literal 0 HcmV?d00001 diff --git a/test/fixtures/lineto-huge-polygon.mvt b/test/fixtures/lineto-huge-polygon.mvt new file mode 100644 index 0000000000000000000000000000000000000000..e953be1859304d89ddfa75f689041831d2f44035 GIT binary patch literal 98 zcmb12s9@q^%}CA3$rqC0s1{;kV31%@65?dz`Sl+P7`b>PboixM@)C1XmGroDk}}g3 vax(K$<4f`tlJj$O6Z29OGV@AO(^HES((;QGN-{Ew6$OY#+x^K)|(^HLNt^GZ_FQ;QVR@{1HoGBS%5ax(K$i%W_!^U^gM6aabgB47Xj literal 0 HcmV?d00001 diff --git a/test/fixtures/moveto-huge-point.mvt b/test/fixtures/moveto-huge-point.mvt new file mode 100644 index 0000000000000000000000000000000000000000..b5ddc476b2ca4aab77de5ae6e64cb77ea80c6bee GIT binary patch literal 90 zcmb1&s9@q^%}CA3$rlpis1{;kV31%`;`#X>3K)%)q*(G2b5oUcxU`Zo(-m^_%TnV@ m@)eTvb8{2(QWP@tN>bBPixkrGixf&SGK&=o@_|Ac4GI8@LLf!} literal 0 HcmV?d00001 diff --git a/test/fixtures/moveto-huge-polygon.mvt b/test/fixtures/moveto-huge-polygon.mvt new file mode 100644 index 0000000000000000000000000000000000000000..fb9fa8a955940027fbda154541ad66559920901e GIT binary patch literal 98 zcmb12s9@q^%}CA3$rqC0s1{;kV31%@68iZc3K-dVgt&MlboixM@)C1XmGroDk}}g3 va`Vel<4f`tlJj$O6Z29OGV@AO(^HES((;QGN-{Ew6$(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(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(1.0); REQUIRE(geom.capacity() <= 655360);