From 4014aa6721e53318e4ac92814776b3e01b4589cb Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 11 Jul 2017 19:19:04 +0300 Subject: [core] GCC 4.9 bracket initialization issues --- test/gl/bucket.test.cpp | 16 +++-- test/src/mbgl/test/stub_geometry_tile_feature.hpp | 4 +- test/style/function/source_function.test.cpp | 9 ++- test/tile/annotation_tile.test.cpp | 6 +- test/tile/vector_tile.test.cpp | 2 +- test/util/merge_lines.test.cpp | 73 +++++++++++++---------- 6 files changed, 63 insertions(+), 47 deletions(-) (limited to 'test') diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp index fdff0e990a..24bec0bd22 100644 --- a/test/gl/bucket.test.cpp +++ b/test/gl/bucket.test.cpp @@ -14,6 +14,12 @@ using namespace mbgl; +namespace { + +PropertyMap properties; + +} // namespace + TEST(Buckets, CircleBucket) { gl::Context context; CircleBucket bucket { { {0, 0, 0}, MapMode::Still, 1.0 }, {} }; @@ -21,7 +27,7 @@ TEST(Buckets, CircleBucket) { ASSERT_FALSE(bucket.needsUpload()); GeometryCollection point { { { 0, 0 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, {} }, point); + bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point); ASSERT_TRUE(bucket.hasData()); ASSERT_TRUE(bucket.needsUpload()); @@ -37,7 +43,7 @@ TEST(Buckets, FillBucket) { ASSERT_FALSE(bucket.needsUpload()); GeometryCollection polygon { { { 0, 0 }, { 0, 1 }, { 1, 1 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Polygon, polygon, {} }, polygon); + bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Polygon, polygon, properties }, polygon); ASSERT_TRUE(bucket.hasData()); ASSERT_TRUE(bucket.needsUpload()); @@ -53,11 +59,11 @@ TEST(Buckets, LineBucket) { // Ignore invalid feature type. GeometryCollection point { { { 0, 0 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, {} }, point); + bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point); ASSERT_FALSE(bucket.hasData()); GeometryCollection line { { { 0, 0 }, { 1, 1 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::LineString, line, {} }, line); + bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::LineString, line, properties }, line); ASSERT_TRUE(bucket.hasData()); ASSERT_TRUE(bucket.needsUpload()); @@ -80,7 +86,7 @@ TEST(Buckets, SymbolBucket) { // SymbolBucket::addFeature() is a no-op. GeometryCollection point { { { 0, 0 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, {} }, point); + bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point); ASSERT_FALSE(bucket.hasData()); ASSERT_FALSE(bucket.needsUpload()); diff --git a/test/src/mbgl/test/stub_geometry_tile_feature.hpp b/test/src/mbgl/test/stub_geometry_tile_feature.hpp index 775d783ead..0164ab133c 100644 --- a/test/src/mbgl/test/stub_geometry_tile_feature.hpp +++ b/test/src/mbgl/test/stub_geometry_tile_feature.hpp @@ -17,9 +17,9 @@ public: } PropertyMap properties; - optional id = {}; + optional id; FeatureType type = FeatureType::Point; - GeometryCollection geometry = {}; + GeometryCollection geometry; FeatureType getType() const override { return type; diff --git a/test/style/function/source_function.test.cpp b/test/style/function/source_function.test.cpp index 260620c8d0..46ad961002 100644 --- a/test/style/function/source_function.test.cpp +++ b/test/style/function/source_function.test.cpp @@ -76,11 +76,14 @@ TEST(SourceFunction, Categorical) { EXPECT_EQ(0.0f, SourceFunction("property", CategoricalStops({{ int64_t(1), 1.0f }})) .evaluate(oneString, 0.0f)); - EXPECT_EQ(0.0f, SourceFunction("property", CategoricalStops({{ "1"s, 1.0f }})) + CategoricalStops::Stops stops; + stops["1"s] = 1.0f; + + EXPECT_EQ(0.0f, SourceFunction("property", CategoricalStops(stops)) .evaluate(oneInteger, 0.0f)); - EXPECT_EQ(0.0f, SourceFunction("property", CategoricalStops({{ "1"s, 1.0f }})) + EXPECT_EQ(0.0f, SourceFunction("property", CategoricalStops(stops)) .evaluate(oneDouble, 0.0f)); - EXPECT_EQ(1.0f, SourceFunction("property", CategoricalStops({{ "1"s, 1.0f }})) + EXPECT_EQ(1.0f, SourceFunction("property", CategoricalStops(stops)) .evaluate(oneString, 0.0f)); EXPECT_EQ(1.0f, SourceFunction("property", CategoricalStops({{ true, 1.0f }})) diff --git a/test/tile/annotation_tile.test.cpp b/test/tile/annotation_tile.test.cpp index a1bfc23492..813b813220 100644 --- a/test/tile/annotation_tile.test.cpp +++ b/test/tile/annotation_tile.test.cpp @@ -58,7 +58,7 @@ TEST(AnnotationTile, Issue8289) { // Simulate layout and placement of a symbol layer. tile.onLayout(GeometryTile::LayoutResult { - {}, + std::unordered_map>(), std::make_unique(), std::move(data), 0 @@ -72,7 +72,7 @@ TEST(AnnotationTile, Issue8289) { collisionTile->placeFeature(feature, false, false); tile.onPlacement(GeometryTile::PlacementResult { - {}, + std::unordered_map>(), std::move(collisionTile), {}, {}, @@ -81,7 +81,7 @@ TEST(AnnotationTile, Issue8289) { // Simulate a second layout with empty data. tile.onLayout(GeometryTile::LayoutResult { - {}, + std::unordered_map>(), std::make_unique(), std::make_unique(), 0 diff --git a/test/tile/vector_tile.test.cpp b/test/tile/vector_tile.test.cpp index 18152cd2c1..d7ad3c999d 100644 --- a/test/tile/vector_tile.test.cpp +++ b/test/tile/vector_tile.test.cpp @@ -89,7 +89,7 @@ TEST(VectorTile, Issue7615) { // Subsequent onLayout should not cause the existing symbol bucket to be discarded. tile.onLayout(GeometryTile::LayoutResult { - {}, + std::unordered_map>(), nullptr, nullptr, 0 diff --git a/test/util/merge_lines.test.cpp b/test/util/merge_lines.test.cpp index ff80157354..d3a2ebae03 100644 --- a/test/util/merge_lines.test.cpp +++ b/test/util/merge_lines.test.cpp @@ -10,15 +10,22 @@ const std::u16string bbb = u"b"; using namespace mbgl; +namespace { + +PropertyMap properties; +LineString emptyLine; + +} + 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_)) + PropertyMap properties_, optional text_, + optional icon_, std::size_t index_) : + SymbolFeature(std::make_unique(std::move(id_), type_, std::move(geometry_), std::move(properties_))) { - text = text_; - icon = icon_; + text = std::move(text_); + icon = std::move(icon_); index = index_; } }; @@ -26,20 +33,20 @@ public: TEST(MergeLines, SameText) { // merges lines with the same text std::vector input1; - input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}}}, {}, aaa, {}, 0)); - input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{4, 0}, {5, 0}, {6, 0}}}, {}, bbb, {}, 0)); - input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{8, 0}, {9, 0}}}, {}, aaa, {}, 0)); - input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{2, 0}, {3, 0}, {4, 0}}}, {}, aaa, {}, 0)); - 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)); + input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}}}, properties, aaa, {}, 0)); + input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{4, 0}, {5, 0}, {6, 0}}}, properties, bbb, {}, 0)); + input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{8, 0}, {9, 0}}}, properties, aaa, {}, 0)); + input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{2, 0}, {3, 0}, {4, 0}}}, properties, aaa, {}, 0)); + input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{6, 0}, {7, 0}, {8, 0}}}, properties, aaa, {}, 0)); + input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{5, 0}, {6, 0}}}, properties, aaa, {}, 0)); 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}}}, {} }, - { {}, FeatureType::LineString, {{}}, {} }, - { {}, FeatureType::LineString, {{}}, {} }, - { {}, FeatureType::LineString, {{}}, {} } + { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, properties }, + { {}, FeatureType::LineString, {{{4, 0}, {5, 0}, {6, 0}}}, properties }, + { {}, FeatureType::LineString, {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, properties }, + { {}, FeatureType::LineString, { emptyLine }, properties }, + { {}, FeatureType::LineString, { emptyLine }, properties }, + { {}, FeatureType::LineString, { emptyLine }, properties } }; mbgl::util::mergeLines(input1); @@ -52,14 +59,14 @@ TEST(MergeLines, SameText) { TEST(MergeLines, BothEnds) { // mergeLines handles merge from both ends std::vector input2; - input2.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}}}, {}, aaa, {}, 0 }); - 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 }); + input2.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}}}, properties, aaa, {}, 0 }); + input2.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{4, 0}, {5, 0}, {6, 0}}}, properties, aaa, {}, 0 }); + input2.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{2, 0}, {3, 0}, {4, 0}}}, properties, aaa, {}, 0 }); const std::vector expected2 = { - { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, {} }, - { {}, FeatureType::LineString, {{}}, {} }, - { {}, FeatureType::LineString, {{}}, {} } + { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, properties }, + { {}, FeatureType::LineString, { emptyLine }, properties }, + { {}, FeatureType::LineString, { emptyLine }, properties } }; mbgl::util::mergeLines(input2); @@ -72,14 +79,14 @@ TEST(MergeLines, BothEnds) { TEST(MergeLines, CircularLines) { // mergeLines handles circular lines std::vector input3; - input3.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}}}, {}, aaa, {}, 0 }); - 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 }); + input3.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}}}, properties, aaa, {}, 0 }); + input3.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{2, 0}, {3, 0}, {4, 0}}}, properties, aaa, {}, 0 }); + input3.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{4, 0}, {0, 0}}}, properties, aaa, {}, 0 }); const std::vector expected3 = { - { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, {} }, - { {}, FeatureType::LineString, {{}}, {} }, - { {}, FeatureType::LineString, {{}}, {} } + { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, properties }, + { {}, FeatureType::LineString, { emptyLine }, properties }, + { {}, FeatureType::LineString, { emptyLine }, properties } }; mbgl::util::mergeLines(input3); @@ -91,9 +98,9 @@ TEST(MergeLines, CircularLines) { TEST(MergeLines, EmptyOuterGeometry) { std::vector input; - input.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {}, {}, aaa, {}, 0 }); + input.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {}, properties, aaa, {}, 0 }); - const std::vector expected = { { {}, FeatureType::LineString, {}, {} } }; + const std::vector expected = { { {}, FeatureType::LineString, {}, properties } }; mbgl::util::mergeLines(input); @@ -102,9 +109,9 @@ TEST(MergeLines, EmptyOuterGeometry) { TEST(MergeLines, EmptyInnerGeometry) { std::vector input; - input.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{}}, {}, aaa, {}, 0 }); + input.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {}, properties, aaa, {}, 0 }); - const std::vector expected = { { {}, FeatureType::LineString, {{}}, {} } }; + const std::vector expected = { { {}, FeatureType::LineString, {}, properties } }; mbgl::util::mergeLines(input); -- cgit v1.2.1