From 0395271b9d900cacf543d9bca6314e50b7cfc7af Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 5 Jul 2017 14:57:34 +0300 Subject: [test] Reuse StubGeometryTileFeature in MergeLines --- test/src/mbgl/test/stub_geometry_tile_feature.hpp | 7 ++++ test/util/merge_lines.test.cpp | 41 ++++------------------- 2 files changed, 14 insertions(+), 34 deletions(-) (limited to 'test') diff --git a/test/src/mbgl/test/stub_geometry_tile_feature.hpp b/test/src/mbgl/test/stub_geometry_tile_feature.hpp index 21d198a96b..775d783ead 100644 --- a/test/src/mbgl/test/stub_geometry_tile_feature.hpp +++ b/test/src/mbgl/test/stub_geometry_tile_feature.hpp @@ -9,6 +9,13 @@ public: : properties(std::move(properties_)) { } + StubGeometryTileFeature(optional id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_) + : properties(std::move(properties_)), + id(std::move(id_)), + type(type_), + geometry(std::move(geometry_)) { + } + PropertyMap properties; optional id = {}; FeatureType type = FeatureType::Point; diff --git a/test/util/merge_lines.test.cpp b/test/util/merge_lines.test.cpp index 6c8387c451..ff80157354 100644 --- a/test/util/merge_lines.test.cpp +++ b/test/util/merge_lines.test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -9,40 +10,12 @@ const std::u16string bbb = u"b"; using namespace mbgl; -class GeometryTileFeatureStub : public GeometryTileFeature { -public: - GeometryTileFeatureStub(optional id_, FeatureType type_, GeometryCollection geometry_, - std::unordered_map properties_) : - id(std::move(id_)), - type(type_), - geometry(std::move(geometry_)), - properties(std::move(properties_)) - {} - - FeatureType getType() const override { return type; } - optional getValue(const std::string& key) const override { - auto it = properties.find(key); - if (it != properties.end()) { - return it->second; - } - return {}; - }; - std::unordered_map getProperties() const override { return properties; }; - optional getID() const override { return id; }; - GeometryCollection getGeometries() const override { return geometry; }; - - optional id; - FeatureType type; - GeometryCollection geometry; - std::unordered_map properties; -}; - class SymbolFeatureStub : public SymbolFeature { public: SymbolFeatureStub(optional id_, FeatureType type_, GeometryCollection geometry_, std::unordered_map properties_, optional text_, optional icon_, std::size_t index_) : - SymbolFeature(std::make_unique(id_, type_, geometry_, properties_)) + SymbolFeature(std::make_unique(id_, type_, geometry_, properties_)) { text = text_; icon = icon_; @@ -60,7 +33,7 @@ TEST(MergeLines, SameText) { input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{6, 0}, {7, 0}, {8, 0}}}, {}, aaa, {}, 0)); input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{5, 0}, {6, 0}}}, {}, aaa, {}, 0)); - const std::vector expected1 = { + const std::vector expected1 = { { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, {} }, { {}, FeatureType::LineString, {{{4, 0}, {5, 0}, {6, 0}}}, {} }, { {}, FeatureType::LineString, {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, {} }, @@ -83,7 +56,7 @@ TEST(MergeLines, BothEnds) { input2.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{4, 0}, {5, 0}, {6, 0}}}, {}, aaa, {}, 0 }); input2.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{2, 0}, {3, 0}, {4, 0}}}, {}, aaa, {}, 0 }); - const std::vector expected2 = { + const std::vector expected2 = { { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, {} }, { {}, FeatureType::LineString, {{}}, {} }, { {}, FeatureType::LineString, {{}}, {} } @@ -103,7 +76,7 @@ TEST(MergeLines, CircularLines) { input3.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{2, 0}, {3, 0}, {4, 0}}}, {}, aaa, {}, 0 }); input3.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{4, 0}, {0, 0}}}, {}, aaa, {}, 0 }); - const std::vector expected3 = { + const std::vector expected3 = { { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, {} }, { {}, FeatureType::LineString, {{}}, {} }, { {}, FeatureType::LineString, {{}}, {} } @@ -120,7 +93,7 @@ TEST(MergeLines, EmptyOuterGeometry) { std::vector input; input.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {}, {}, aaa, {}, 0 }); - const std::vector expected = { { {}, FeatureType::LineString, {}, {} } }; + const std::vector expected = { { {}, FeatureType::LineString, {}, {} } }; mbgl::util::mergeLines(input); @@ -131,7 +104,7 @@ TEST(MergeLines, EmptyInnerGeometry) { std::vector input; input.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{}}, {}, aaa, {}, 0 }); - const std::vector expected = { { {}, FeatureType::LineString, {{}}, {} } }; + const std::vector expected = { { {}, FeatureType::LineString, {{}}, {} } }; mbgl::util::mergeLines(input); -- cgit v1.2.1