[msvc] Fix compilation errors and warnings (#141)

This commit is contained in:
Tadej Novak
2021-08-29 22:53:42 +02:00
committed by GitHub
parent c0d76c69cc
commit fe041b80ca
51 changed files with 206 additions and 195 deletions

View File

@@ -1300,7 +1300,7 @@ TEST(Map, PrefetchDeltaOverrideCustomSource) {
};
auto layer = test.map.getStyle().removeLayer("custom");
std::move(test.map.getStyle().removeSource("custom"));
test.map.getStyle().removeSource("custom");
test.map.getStyle().addLayer(std::move(layer));
test.map.getStyle().addSource(makeCustomSource());
test.runLoop.run();

View File

@@ -119,7 +119,7 @@ TEST(MapSnapshotter, TEST_REQUIRES_SERVER(runtimeStyling)) {
observer.didFinishLoadingStyleCallback = [&snapshotter, &runLoop] {
auto fillLayer = std::make_unique<style::FillLayer>("green_fill", "mapbox");
fillLayer->setSourceLayer("water");
fillLayer->setFillColor(Color(0.25, 0.88, 0.82, 1.0));
fillLayer->setFillColor(Color(0.25f, 0.88f, 0.82f, 1.0f));
snapshotter.getStyle().addLayer(std::move(fillLayer));
snapshotter.snapshot([&runLoop](std::exception_ptr ptr,
mbgl::PremultipliedImage image,

View File

@@ -45,15 +45,15 @@ auto createOverride(expression::type::Type exprType,
}
TEST(PropertyExpression, Constant) {
EXPECT_EQ(2.0f, evaluate(PropertyValue<float>(2.0), 0));
EXPECT_EQ(3.8f, evaluate(PropertyValue<float>(3.8), 0));
EXPECT_EQ(22.0f, evaluate(PropertyValue<float>(22.0), 0));
EXPECT_EQ(2.0f, evaluate(PropertyValue<float>(2.0), 4));
EXPECT_EQ(3.8f, evaluate(PropertyValue<float>(3.8), 4));
EXPECT_EQ(22.0f, evaluate(PropertyValue<float>(22.0), 4));
EXPECT_EQ(2.0f, evaluate(PropertyValue<float>(2.0), 22));
EXPECT_EQ(3.8f, evaluate(PropertyValue<float>(3.8), 22));
EXPECT_EQ(22.0f, evaluate(PropertyValue<float>(22.0), 22));
EXPECT_EQ(2.0f, evaluate(PropertyValue<float>(2.0f), 0));
EXPECT_EQ(3.8f, evaluate(PropertyValue<float>(3.8f), 0));
EXPECT_EQ(22.0f, evaluate(PropertyValue<float>(22.0f), 0));
EXPECT_EQ(2.0f, evaluate(PropertyValue<float>(2.0f), 4));
EXPECT_EQ(3.8f, evaluate(PropertyValue<float>(3.8f), 4));
EXPECT_EQ(22.0f, evaluate(PropertyValue<float>(22.0f), 4));
EXPECT_EQ(2.0f, evaluate(PropertyValue<float>(2.0f), 22));
EXPECT_EQ(3.8f, evaluate(PropertyValue<float>(3.8f), 22));
EXPECT_EQ(22.0f, evaluate(PropertyValue<float>(22.0f), 22));
}
TEST(PropertyExpression, Expression) {

View File

@@ -35,7 +35,7 @@ const float overscaling = 1.0f;
TEST(getAnchors, NonContinuedLineShortLabels) {
const Anchors anchors = getAnchors(
nonContinuedLine, bigSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
nonContinuedLine, bigSpacing, static_cast<float>(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
const Anchors expected_anchors = {Anchor(1.0f, 2.0f, 1.570796371f, 1u),
Anchor(1.0f, 5.0f, 1.570796371f, 4u),
Anchor(1.0f, 8.0f, 1.570796371f, 7u)};
@@ -46,7 +46,7 @@ TEST(getAnchors, NonContinuedLineShortLabels) {
TEST(getAnchors, NonContinuedLineLongLabels) {
const Anchors anchors = getAnchors(nonContinuedLine,
smallSpacing,
M_PI,
static_cast<float>(M_PI),
textLeft,
textRight,
iconLeft,
@@ -63,7 +63,7 @@ TEST(getAnchors, NonContinuedLineLongLabels) {
TEST(getAnchors, ContinuedLineShortLabels) {
const Anchors anchors = getAnchors(
continuedLine, bigSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
continuedLine, bigSpacing, static_cast<float>(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
const Anchors expected_anchors = {Anchor(1.0f, 2.0f, 1.570796371f, 1u),
Anchor(1.0f, 5.0f, 1.570796371f, 4u),
Anchor(1.0f, 8.0f, 1.570796371f, 7u)};
@@ -73,7 +73,7 @@ TEST(getAnchors, ContinuedLineShortLabels) {
TEST(getAnchors, ContinuedLineLongLabels) {
const Anchors anchors = getAnchors(
continuedLine, smallSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
continuedLine, smallSpacing, static_cast<float>(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
const Anchors expected_anchors = {Anchor(1.0f, 1.0f, 1.570796371f, 1u),
Anchor(1.0f, 4.0f, 1.570796371f, 3u),
Anchor(1.0f, 6.0f, 1.570796371f, 6u)};
@@ -83,10 +83,10 @@ TEST(getAnchors, ContinuedLineLongLabels) {
TEST(getAnchors, OverscaledAnchorsInParent) {
const Anchors anchors = getAnchors(
nonContinuedLine, bigSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
nonContinuedLine, bigSpacing, static_cast<float>(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
const Anchors childAnchors = getAnchors(nonContinuedLine,
bigSpacing / 2,
M_PI,
static_cast<float>(M_PI),
textLeft,
textRight,
iconLeft,
@@ -102,7 +102,7 @@ TEST(getAnchors, OverscaledAnchorsInParent) {
TEST(getAnchors, UseMidpointForShortLine) {
const GeometryCoordinates shortLine = {Point<int16_t>{1, 1}, Point<int16_t>{1, 3}};
const Anchors anchors = getAnchors(
shortLine, smallSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
shortLine, smallSpacing, static_cast<float>(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling);
const Anchors expected_anchors = {Anchor(1.0f, 2.0f, 1.570796371f, 0u)};
EXPECT_EQ(anchors, expected_anchors);
@@ -111,20 +111,20 @@ TEST(getAnchors, UseMidpointForShortLine) {
TEST(getAnchors, GetCenterAnchor) {
const GeometryCoordinates line = {
Point<int16_t>{1, 1}, Point<int16_t>{1, 3}, Point<int16_t>{3, 6}, Point<int16_t>{4, 7}};
const auto anchor = getCenterAnchor(line, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale);
const auto anchor = getCenterAnchor(line, static_cast<float>(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale);
EXPECT_TRUE(anchor);
EXPECT_EQ(*anchor, Anchor(2.0f, 4.0f, .982793748f, 1u));
}
TEST(getAnchors, GetCenterAnchorOutsideTileBounds) {
const GeometryCoordinates line = {Point<int16_t>{-10, -10}, Point<int16_t>{5, 5}};
const auto anchor = getCenterAnchor(line, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale);
const auto anchor = getCenterAnchor(line, static_cast<float>(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale);
EXPECT_TRUE(anchor);
EXPECT_EQ(*anchor, Anchor(-3.0f, -3.0f, .785398185f, 0u));
}
TEST(getAnchors, GetCenterAnchorFailMaxAngle) {
const GeometryCoordinates line = {Point<int16_t>{1, 1}, Point<int16_t>{1, 3}, Point<int16_t>{3, 3}};
const auto anchor = getCenterAnchor(line, M_PI / 4, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale);
const auto anchor = getCenterAnchor(line, static_cast<float>(M_PI) / 4, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale);
EXPECT_FALSE(anchor);
}

View File

@@ -255,7 +255,7 @@ TEST(GlyphManager, LoadLocalCJKGlyph) {
TEST(GlyphManager, LoadLocalCJKGlyphAfterLoadingRangeFromURL) {
GlyphManagerTest test;
int firstGlyphResponse = false;
bool firstGlyphResponse = false;
test.fileSource.glyphsResponse = [&] (const Resource&) {
firstGlyphResponse = true;

View File

@@ -86,13 +86,13 @@ TEST(getIconQuads, style) {
ASSERT_EQ(quads.size(), 1);
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -64.4444427);
EXPECT_FLOAT_EQ(quad.tl.x, -64.4444427f);
EXPECT_FLOAT_EQ(quad.tl.y, 0);
EXPECT_FLOAT_EQ(quad.tr.x, 24.4444427);
EXPECT_FLOAT_EQ(quad.tr.x, 24.4444427f);
EXPECT_FLOAT_EQ(quad.tr.y, 0);
EXPECT_FLOAT_EQ(quad.bl.x, -64.4444427);
EXPECT_FLOAT_EQ(quad.bl.x, -64.4444427f);
EXPECT_FLOAT_EQ(quad.bl.y, 20);
EXPECT_FLOAT_EQ(quad.br.x, 24.4444427);
EXPECT_FLOAT_EQ(quad.br.x, 24.4444427f);
EXPECT_FLOAT_EQ(quad.br.y, 20);
}
@@ -105,13 +105,13 @@ TEST(getIconQuads, style) {
ASSERT_EQ(quads.size(), 1);
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -32.2222214);
EXPECT_FLOAT_EQ(quad.tl.x, -32.2222214f);
EXPECT_FLOAT_EQ(quad.tl.y, -5);
EXPECT_FLOAT_EQ(quad.tr.x, 12.2222214);
EXPECT_FLOAT_EQ(quad.tr.x, 12.2222214f);
EXPECT_FLOAT_EQ(quad.tr.y, -5);
EXPECT_FLOAT_EQ(quad.bl.x, -32.2222214);
EXPECT_FLOAT_EQ(quad.bl.x, -32.2222214f);
EXPECT_FLOAT_EQ(quad.bl.y, 15);
EXPECT_FLOAT_EQ(quad.br.x, 12.2222214);
EXPECT_FLOAT_EQ(quad.br.x, 12.2222214f);
EXPECT_FLOAT_EQ(quad.br.y, 15);
}
@@ -124,13 +124,13 @@ TEST(getIconQuads, style) {
ASSERT_EQ(quads.size(), 1);
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -43.3333321);
EXPECT_FLOAT_EQ(quad.tl.x, -43.3333321f);
EXPECT_FLOAT_EQ(quad.tl.y, -5);
EXPECT_FLOAT_EQ(quad.tr.x, 23.3333321);
EXPECT_FLOAT_EQ(quad.tr.x, 23.3333321f);
EXPECT_FLOAT_EQ(quad.tr.y, -5);
EXPECT_FLOAT_EQ(quad.bl.x, -43.3333321);
EXPECT_FLOAT_EQ(quad.bl.x, -43.3333321f);
EXPECT_FLOAT_EQ(quad.bl.y, 15);
EXPECT_FLOAT_EQ(quad.br.x, 23.3333321);
EXPECT_FLOAT_EQ(quad.br.x, 23.3333321f);
EXPECT_FLOAT_EQ(quad.br.y, 15);
}
@@ -144,13 +144,13 @@ TEST(getIconQuads, style) {
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -30);
EXPECT_FLOAT_EQ(quad.tl.y, -12.2222214);
EXPECT_FLOAT_EQ(quad.tl.y, -12.2222214f);
EXPECT_FLOAT_EQ(quad.tr.x, -10);
EXPECT_FLOAT_EQ(quad.tr.y, -12.2222214);
EXPECT_FLOAT_EQ(quad.tr.y, -12.2222214f);
EXPECT_FLOAT_EQ(quad.bl.x, -30);
EXPECT_FLOAT_EQ(quad.bl.y, 32.2222214);
EXPECT_FLOAT_EQ(quad.bl.y, 32.2222214f);
EXPECT_FLOAT_EQ(quad.br.x, -10);
EXPECT_FLOAT_EQ(quad.br.y, 32.2222214);
EXPECT_FLOAT_EQ(quad.br.y, 32.2222214f);
}
// height x textSize
@@ -164,13 +164,13 @@ TEST(getIconQuads, style) {
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -20);
EXPECT_FLOAT_EQ(quad.tl.y, -6.11111069);
EXPECT_FLOAT_EQ(quad.tl.y, -6.11111069f);
EXPECT_FLOAT_EQ(quad.tr.x, 0);
EXPECT_FLOAT_EQ(quad.tr.y, -6.11111069);
EXPECT_FLOAT_EQ(quad.tr.y, -6.11111069f);
EXPECT_FLOAT_EQ(quad.bl.x, -20);
EXPECT_FLOAT_EQ(quad.bl.y, 16.1111107);
EXPECT_FLOAT_EQ(quad.bl.y, 16.1111107f);
EXPECT_FLOAT_EQ(quad.br.x, 0);
EXPECT_FLOAT_EQ(quad.br.y, 16.1111107);
EXPECT_FLOAT_EQ(quad.br.y, 16.1111107f);
}
// height x textSize + padding
@@ -183,13 +183,13 @@ TEST(getIconQuads, style) {
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -20);
EXPECT_FLOAT_EQ(quad.tl.y, -11.666666);
EXPECT_FLOAT_EQ(quad.tl.y, -11.666666f);
EXPECT_FLOAT_EQ(quad.tr.x, 0);
EXPECT_FLOAT_EQ(quad.tr.y, -11.666666);
EXPECT_FLOAT_EQ(quad.tr.y, -11.666666f);
EXPECT_FLOAT_EQ(quad.bl.x, -20);
EXPECT_FLOAT_EQ(quad.bl.y, 21.666666);
EXPECT_FLOAT_EQ(quad.bl.y, 21.666666f);
EXPECT_FLOAT_EQ(quad.br.x, 0);
EXPECT_FLOAT_EQ(quad.br.y, 21.666666);
EXPECT_FLOAT_EQ(quad.br.y, 21.666666f);
}
// both
@@ -201,14 +201,14 @@ TEST(getIconQuads, style) {
ASSERT_EQ(quads.size(), 1);
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -64.4444427);
EXPECT_FLOAT_EQ(quad.tl.y, -12.2222214);
EXPECT_FLOAT_EQ(quad.tr.x, 24.4444427);
EXPECT_FLOAT_EQ(quad.tr.y, -12.2222214);
EXPECT_FLOAT_EQ(quad.bl.x, -64.4444427);
EXPECT_FLOAT_EQ(quad.bl.y, 32.2222214);
EXPECT_FLOAT_EQ(quad.br.x, 24.4444427);
EXPECT_FLOAT_EQ(quad.br.y, 32.2222214);
EXPECT_FLOAT_EQ(quad.tl.x, -64.4444427f);
EXPECT_FLOAT_EQ(quad.tl.y, -12.2222214f);
EXPECT_FLOAT_EQ(quad.tr.x, 24.4444427f);
EXPECT_FLOAT_EQ(quad.tr.y, -12.2222214f);
EXPECT_FLOAT_EQ(quad.bl.x, -64.4444427f);
EXPECT_FLOAT_EQ(quad.bl.y, 32.2222214f);
EXPECT_FLOAT_EQ(quad.br.x, 24.4444427f);
EXPECT_FLOAT_EQ(quad.br.y, 32.2222214f);
}
// both x textSize
@@ -220,14 +220,14 @@ TEST(getIconQuads, style) {
ASSERT_EQ(quads.size(), 1);
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -32.2222214);
EXPECT_FLOAT_EQ(quad.tl.y, -6.11111069);
EXPECT_FLOAT_EQ(quad.tr.x, 12.2222214);
EXPECT_FLOAT_EQ(quad.tr.y, -6.11111069);
EXPECT_FLOAT_EQ(quad.bl.x, -32.2222214);
EXPECT_FLOAT_EQ(quad.bl.y, 16.1111107);
EXPECT_FLOAT_EQ(quad.br.x, 12.2222214);
EXPECT_FLOAT_EQ(quad.br.y, 16.1111107);
EXPECT_FLOAT_EQ(quad.tl.x, -32.2222214f);
EXPECT_FLOAT_EQ(quad.tl.y, -6.11111069f);
EXPECT_FLOAT_EQ(quad.tr.x, 12.2222214f);
EXPECT_FLOAT_EQ(quad.tr.y, -6.11111069f);
EXPECT_FLOAT_EQ(quad.bl.x, -32.2222214f);
EXPECT_FLOAT_EQ(quad.bl.y, 16.1111107f);
EXPECT_FLOAT_EQ(quad.br.x, 12.2222214f);
EXPECT_FLOAT_EQ(quad.br.y, 16.1111107f);
}
// both x textSize + padding
@@ -239,14 +239,14 @@ TEST(getIconQuads, style) {
ASSERT_EQ(quads.size(), 1);
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -43.3333321);
EXPECT_FLOAT_EQ(quad.tl.y, -11.666666);
EXPECT_FLOAT_EQ(quad.tr.x, 23.3333321);
EXPECT_FLOAT_EQ(quad.tr.y, -11.666666);
EXPECT_FLOAT_EQ(quad.bl.x, -43.3333321);
EXPECT_FLOAT_EQ(quad.bl.y, 21.666666);
EXPECT_FLOAT_EQ(quad.br.x, 23.3333321);
EXPECT_FLOAT_EQ(quad.br.y, 21.666666);
EXPECT_FLOAT_EQ(quad.tl.x, -43.3333321f);
EXPECT_FLOAT_EQ(quad.tl.y, -11.666666f);
EXPECT_FLOAT_EQ(quad.tr.x, 23.3333321f);
EXPECT_FLOAT_EQ(quad.tr.y, -11.666666f);
EXPECT_FLOAT_EQ(quad.bl.x, -43.3333321f);
EXPECT_FLOAT_EQ(quad.bl.y, 21.666666f);
EXPECT_FLOAT_EQ(quad.br.x, 23.3333321f);
EXPECT_FLOAT_EQ(quad.br.y, 21.666666f);
}
// both x textSize + padding t/r/b/l
@@ -260,13 +260,13 @@ TEST(getIconQuads, style) {
ASSERT_EQ(quads.size(), 1);
const auto& quad = quads[0];
EXPECT_FLOAT_EQ(quad.tl.x, -48.3333321);
EXPECT_FLOAT_EQ(quad.tl.y, -6.66666603);
EXPECT_FLOAT_EQ(quad.tr.x, 18.3333321);
EXPECT_FLOAT_EQ(quad.tr.y, -6.66666603);
EXPECT_FLOAT_EQ(quad.bl.x, -48.3333321);
EXPECT_FLOAT_EQ(quad.bl.y, 26.666666);
EXPECT_FLOAT_EQ(quad.br.x, 18.3333321);
EXPECT_FLOAT_EQ(quad.br.y, 26.666666);
EXPECT_FLOAT_EQ(quad.tl.x, -48.3333321f);
EXPECT_FLOAT_EQ(quad.tl.y, -6.66666603f);
EXPECT_FLOAT_EQ(quad.tr.x, 18.3333321f);
EXPECT_FLOAT_EQ(quad.tr.y, -6.66666603f);
EXPECT_FLOAT_EQ(quad.bl.x, -48.3333321f);
EXPECT_FLOAT_EQ(quad.bl.y, 26.666666f);
EXPECT_FLOAT_EQ(quad.br.x, 18.3333321f);
EXPECT_FLOAT_EQ(quad.br.y, 26.666666f);
}
}

View File

@@ -161,14 +161,14 @@ TEST(Memory, Footprint) {
std::vector<std::unique_ptr<FrontendAndMap>> maps;
unsigned runs = 15;
long vectorInitialRSS = mbgl::test::getCurrentRSS();
size_t vectorInitialRSS = mbgl::test::getCurrentRSS();
for (unsigned i = 0; i < runs; ++i) {
maps.emplace_back(std::make_unique<FrontendAndMap>(test, "maptiler://maps/streets"));
}
double vectorFootprint = (mbgl::test::getCurrentRSS() - vectorInitialRSS) / double(runs);
long rasterInitialRSS = mbgl::test::getCurrentRSS();
size_t rasterInitialRSS = mbgl::test::getCurrentRSS();
for (unsigned i = 0; i < runs; ++i) {
maps.emplace_back(std::make_unique<FrontendAndMap>(test, "maptiler://maps/hybrid"));
}