[test] Fix failing tests on iOS

This commit is contained in:
Juha Alanen
2020-02-12 12:34:30 +02:00
parent ddc7930b27
commit a4c4de2828
5 changed files with 11 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -621,7 +621,8 @@ TEST(Transform, LatLngBounds) {
}
transform.jumpTo(CameraOptions().withCenter(sanFrancisco));
ASSERT_EQ(transform.getLatLng(), sanFrancisco);
ASSERT_NEAR(transform.getLatLng().latitude(), sanFrancisco.latitude(), 1e-8);
ASSERT_NEAR(transform.getLatLng().longitude(), sanFrancisco.longitude(), 1e-8);
// Single location.
transform.setLatLngBounds(LatLngBounds::singleton(sanFrancisco));
@@ -655,7 +656,7 @@ TEST(Transform, LatLngBounds) {
// └───┴───┸───┴───┸───┴───┘
transform.setLatLngBounds(LatLngBounds::hull({ -90.0, 0.0 }, { 90.0, 180.0 }));
transform.jumpTo(CameraOptions().withCenter(sanFrancisco));
ASSERT_EQ(transform.getLatLng().latitude(), sanFrancisco.latitude());
ASSERT_NEAR(transform.getLatLng().latitude(), sanFrancisco.latitude(), 1e-8);
ASSERT_EQ(transform.getLatLng().longitude(), 0.0);
// -1 | 0 | +1

View File

@@ -779,7 +779,7 @@ TEST(OfflineDatabase, MapboxTileLimitExceeded) {
db.put(ambientTile, response);
};
auto insertRegionTile = [&](int64_t regionID, unsigned i) {
auto insertRegionTile = [&](int64_t regionID, uint64_t i) {
const Resource tile = Resource::tile("mapbox://region_tile_" + std::to_string(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
db.putRegionResource(regionID, tile, response);
};
@@ -801,14 +801,14 @@ TEST(OfflineDatabase, MapboxTileLimitExceeded) {
ASSERT_EQ(db.getOfflineMapboxTileCount(), 0);
// Fine because this region is under the tile limit.
for (unsigned i = 0; i < limit - 10; ++i) {
for (uint64_t i = 0; i < limit - 10; ++i) {
insertRegionTile(region1->getID(), i);
}
ASSERT_EQ(db.getOfflineMapboxTileCount(), limit - 10);
// Fine because this region + the previous is at the limit.
for (unsigned i = limit; i < limit + 10; ++i) {
for (uint64_t i = limit; i < limit + 10; ++i) {
insertRegionTile(region2->getID(), i);
}
@@ -848,7 +848,7 @@ TEST(OfflineDatabase, MapboxTileLimitExceeded) {
// 10, which would blow up the limit if it wasn't
// for the fact that tile 60 is already on the
// database and will not count.
for (unsigned i = limit; i < limit + 10; ++i) {
for (uint64_t i = limit; i < limit + 10; ++i) {
insertRegionTile(region1->getID(), i);
}

View File

@@ -91,6 +91,8 @@ TEST(VectorTileData, ParseResults) {
ASSERT_TRUE(false) << "should throw: feature index is out of range.";
} catch (const std::out_of_range&) {
ASSERT_TRUE(true);
} catch (...) { // needed for iOS when MBGL_WITH_RTTI=OFF
ASSERT_TRUE(true);
}
std::unique_ptr<GeometryTileFeature> feature = layer->getFeature(0u);

View File

@@ -365,7 +365,7 @@ TEST(TileCount, BoundsCrossingAntimeridian) {
TEST(TileCover, DISABLED_FuzzPoly) {
while(true)
{
std::srand (time(nullptr));
std::srand(static_cast<uint32_t>(time(nullptr)));
std::size_t len = std::rand() % 10000 + 3;
Polygon<double> polygon;
@@ -393,7 +393,7 @@ TEST(TileCover, DISABLED_FuzzPoly) {
TEST(TileCover, DISABLED_FuzzLine) {
while(true)
{
std::srand (time(nullptr));
std::srand(static_cast<uint32_t>(time(nullptr)));
std::size_t len = std::rand() % 10000 + 3;
MultiLineString<double> mls;