This commit is contained in:
Bart Louwers
2024-08-11 15:04:14 +02:00
committed by GitHub
parent 60c1d351cf
commit 544f918c17
34 changed files with 97 additions and 89 deletions

View File

@@ -13,7 +13,7 @@ PackConstructorInitializers: Never
PenaltyBreakAssignment: 80 PenaltyBreakAssignment: 80
SortIncludes: false SortIncludes: false
SpacesBeforeTrailingComments: 1 SpacesBeforeTrailingComments: 1
Standard: c++17 Standard: c++20
--- ---
Language: Cpp Language: Cpp
--- ---

View File

@@ -1,5 +1,5 @@
--- ---
Checks: > Checks: [
android-*, android-*,
boost-*, boost-*,
bugprone-*, bugprone-*,
@@ -108,7 +108,9 @@ Checks: >
-readability-static-definition-in-anonymous-namespace, -readability-static-definition-in-anonymous-namespace,
-readability-suspicious-call-argument, -readability-suspicious-call-argument,
-readability-uppercase-literal-suffix, -readability-uppercase-literal-suffix,
-readability-use-anyofallof -readability-use-anyofallof,
-modernize-loop-convert # since C++20 this complains about reverse loops with iterators, but good ranges support only landed in clang 15
]
WarningsAsErrors: '*' WarningsAsErrors: '*'
HeaderFilterRegex: '.*' HeaderFilterRegex: '.*'
CheckOptions: CheckOptions:

View File

@@ -120,7 +120,7 @@ target_link_libraries(
cmake_policy(SET CMP0063 NEW) cmake_policy(SET CMP0063 NEW)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_C_EXTENSIONS OFF)
@@ -1382,6 +1382,16 @@ set_source_files_properties(
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-Wno-deprecated-declarations> $<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-Wno-deprecated-declarations>
) )
# gcc 12 compiler bug, remove when fixed
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651
set_source_files_properties(
${PROJECT_SOURCE_DIR}/src/mbgl/style/expression/compound_expression.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/font_stack.cpp
PROPERTIES
COMPILE_FLAGS
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,12.0.0>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,13.0.0>>:-Wno-restrict>
)
source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${INCLUDE_FILES}) source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${INCLUDE_FILES})
source_group(TREE ${PROJECT_SOURCE_DIR}/src FILES ${SRC_FILES}) source_group(TREE ${PROJECT_SOURCE_DIR}/src FILES ${SRC_FILES})

View File

@@ -53,7 +53,7 @@ MSVC_FLAGS = [
"/wd4435", # (boost) Object layout under /vd2 will change due to virtual base "/wd4435", # (boost) Object layout under /vd2 will change due to virtual base
"/wd4702", # Unreachable code "/wd4702", # Unreachable code
"/wd4710", # Function not inlined "/wd4710", # Function not inlined
"/wd5041", # out-of-line definition for constexpr static data member is not needed and is deprecated in C++17 "/wd5041", # out-of-line definition for constexpr static data member is not needed and is deprecated since C++17
"/wd4946", # reinterpret_cast used between related classes "/wd4946", # reinterpret_cast used between related classes
"/wd4459", # declaration of 'x' hides global declaration "/wd4459", # declaration of 'x' hides global declaration
"/wd4373", # virtual function overrides 'x', previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers "/wd4373", # virtual function overrides 'x', previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers
@@ -86,12 +86,12 @@ GCC_CLANG_CPP_FLAGS = [
"-fexceptions", "-fexceptions",
"-fno-rtti", "-fno-rtti",
"-ftemplate-depth=1024", "-ftemplate-depth=1024",
"-std=c++17", "-std=c++20",
] ]
MSVC_CPP_FLAGS = [ MSVC_CPP_FLAGS = [
"/EHsc", "/EHsc",
"/std:c++17", "/std:c++20",
"/GR-", "/GR-",
"/permissive-", "/permissive-",
"/utf-8", "/utf-8",

View File

@@ -23,6 +23,7 @@ RUN apt-get update \
ccache \ ccache \
ninja-build \ ninja-build \
pkg-config \ pkg-config \
clang-tidy \
&& : # end of the RUN cmd - easier to keep a colon at the end of the list, than to keep the backslashes in check && : # end of the RUN cmd - easier to keep a colon at the end of the list, than to keep the backslashes in check
# This could also be `.../releases/latest/download/bazelisk-linux-amd64` for the latest version, but for predictability better hardcode it # This could also be `.../releases/latest/download/bazelisk-linux-amd64` for the latest version, but for predictability better hardcode it

View File

@@ -224,7 +224,7 @@ public:
virtual void eachChild(const std::function<void(const Expression&)>&) const = 0; virtual void eachChild(const std::function<void(const Expression&)>&) const = 0;
virtual bool operator==(const Expression&) const = 0; virtual bool operator==(const Expression&) const = 0;
bool operator!=(const Expression& rhs) const noexcept { return !operator==(rhs); } bool operator!=(const Expression&) const = default;
Kind getKind() const noexcept { return kind; }; Kind getKind() const noexcept { return kind; };
const type::Type& getType() const noexcept { return type; }; const type::Type& getType() const noexcept { return type; };

View File

@@ -35,7 +35,7 @@ public:
defaultValue.match([&fn](const style::PropertyExpression<T>& e) { fn(e.getExpression()); }, [](const T&) {}); defaultValue.match([&fn](const style::PropertyExpression<T>& e) { fn(e.getExpression()); }, [](const T&) {});
} }
bool operator==(const Expression& e) const final { bool operator==(const Expression& e) const final override {
if (e.getKind() == Kind::FormatSectionOverride) { if (e.getKind() == Kind::FormatSectionOverride) {
const auto* other = static_cast<const FormatSectionOverride*>(&e); const auto* other = static_cast<const FormatSectionOverride*>(&e);
@@ -60,6 +60,8 @@ public:
return false; return false;
} }
bool operator==(const FormatSectionOverride& other) const { return *this == static_cast<const Expression&>(other); }
std::vector<std::optional<Value>> possibleOutputs() const final { return {std::nullopt}; } std::vector<std::optional<Value>> possibleOutputs() const final { return {std::nullopt}; }
std::string getOperator() const final { return "format-section-override"; } std::string getOperator() const final { return "format-section-override"; }

View File

@@ -5,7 +5,7 @@ project(MapLibreAndroid)
add_subdirectory(../../../../../ add_subdirectory(../../../../../
../../../../../${ANDROID_ABI}) ../../../../../${ANDROID_ABI})
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
target_compile_options(mbgl-compiler-options INTERFACE -frtti) target_compile_options(mbgl-compiler-options INTERFACE -frtti)

View File

@@ -34,11 +34,11 @@ CGImageRef CGImageCreateWithMLNPremultipliedImage(mbgl::PremultipliedImage&& src
constexpr const size_t bytesPerPixel = 4; constexpr const size_t bytesPerPixel = 4;
constexpr const size_t bitsPerPixel = bitsPerComponent * bytesPerPixel; constexpr const size_t bitsPerPixel = bitsPerComponent * bytesPerPixel;
const size_t bytesPerRow = bytesPerPixel * src.size.width; const size_t bytesPerRow = bytesPerPixel * src.size.width;
const auto bitmapInfo = static_cast<uint32_t>(kCGBitmapByteOrderDefault) | static_cast<uint32_t>(kCGImageAlphaPremultipliedLast);
return CGImageCreate(src.size.width, src.size.height, bitsPerComponent, bitsPerPixel, return CGImageCreate(src.size.width, src.size.height, bitsPerComponent, bitsPerPixel,
bytesPerRow, *colorSpace, bytesPerRow, *colorSpace,
// NOLINTNEXTLINE(bugprone-suspicious-enum-usage) bitmapInfo, *provider,
kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast, *provider,
NULL, false, kCGRenderingIntentDefault); NULL, false, kCGRenderingIntentDefault);
} }
@@ -56,11 +56,10 @@ mbgl::PremultipliedImage MLNPremultipliedImageFromCGImage(CGImageRef src) {
constexpr const size_t bitsPerComponent = 8; constexpr const size_t bitsPerComponent = 8;
constexpr const size_t bytesPerPixel = 4; constexpr const size_t bytesPerPixel = 4;
const size_t bytesPerRow = bytesPerPixel * width; const size_t bytesPerRow = bytesPerPixel * width;
const auto bitmapInfo = static_cast<uint32_t>(kCGBitmapByteOrderDefault) | static_cast<uint32_t>(kCGImageAlphaPremultipliedLast);
CGContextHandle context(CGBitmapContextCreate( CGContextHandle context(CGBitmapContextCreate(
image.data.get(), width, height, bitsPerComponent, bytesPerRow, *colorSpace, image.data.get(), width, height, bitsPerComponent, bytesPerRow, *colorSpace, bitmapInfo));
// NOLINTNEXTLINE(bugprone-suspicious-enum-usage)
kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast));
if (!context) { if (!context) {
throw std::runtime_error("CGBitmapContextCreate failed"); throw std::runtime_error("CGBitmapContextCreate failed");
} }

View File

@@ -234,6 +234,7 @@ PremultipliedImage drawGlyphBitmap(GlyphID glyphID, CTFontRef font, GlyphMetrics
constexpr const size_t bitsPerComponent = 8; constexpr const size_t bitsPerComponent = 8;
constexpr const size_t bytesPerPixel = 4; constexpr const size_t bytesPerPixel = 4;
const size_t bytesPerRow = bytesPerPixel * size.width; const size_t bytesPerRow = bytesPerPixel * size.width;
const auto bitmapInfo = static_cast<uint32_t>(kCGBitmapByteOrderDefault) | static_cast<uint32_t>(kCGImageAlphaPremultipliedLast);
CGContextHandle context(CGBitmapContextCreate( CGContextHandle context(CGBitmapContextCreate(
rgbaBitmap.data.get(), rgbaBitmap.data.get(),
@@ -242,8 +243,7 @@ PremultipliedImage drawGlyphBitmap(GlyphID glyphID, CTFontRef font, GlyphMetrics
bitsPerComponent, bitsPerComponent,
bytesPerRow, bytesPerRow,
*colorSpace, *colorSpace,
// NOLINTNEXTLINE(bugprone-suspicious-enum-usage) bitmapInfo));
kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast));
if (!context) { if (!context) {
throw std::runtime_error("CGBitmapContextCreate failed"); throw std::runtime_error("CGBitmapContextCreate failed");
} }

View File

@@ -33,8 +33,8 @@ public:
ref.invoke(&FileSourceRequest::setResponse, res); ref.invoke(&FileSourceRequest::setResponse, res);
}; };
auto requestFromNetwork = [=](const Resource& res, auto requestFromNetwork = [=, this](const Resource& res,
std::unique_ptr<AsyncRequest> parent) -> std::unique_ptr<AsyncRequest> { std::unique_ptr<AsyncRequest> parent) -> std::unique_ptr<AsyncRequest> {
if (!onlineFileSource || !onlineFileSource->canRequest(resource)) { if (!onlineFileSource || !onlineFileSource->canRequest(resource)) {
return parent; return parent;
} }
@@ -43,7 +43,7 @@ public:
std::shared_ptr<AsyncRequest> parentKeepAlive = std::move(parent); std::shared_ptr<AsyncRequest> parentKeepAlive = std::move(parent);
MBGL_TIMING_START(watch); MBGL_TIMING_START(watch);
return onlineFileSource->request(res, [=, ptr = parentKeepAlive](const Response& response) { return onlineFileSource->request(res, [=, ptr = parentKeepAlive, this](const Response& response) {
if (databaseFileSource) { if (databaseFileSource) {
databaseFileSource->forward(res, response, nullptr); databaseFileSource->forward(res, response, nullptr);
} }
@@ -79,7 +79,7 @@ public:
tasks[req] = databaseFileSource->request(resource, callback); tasks[req] = databaseFileSource->request(resource, callback);
} else { } else {
// Cache request with fallback to network with cache control // Cache request with fallback to network with cache control
tasks[req] = databaseFileSource->request(resource, [=](const Response& response) { tasks[req] = databaseFileSource->request(resource, [=, this](const Response& response) {
Resource res = resource; Resource res = resource;
// Resource is in the cache // Resource is in the cache

View File

@@ -273,7 +273,7 @@ void OfflineDownload::activateDownload() {
sourceResource.setPriority(Resource::Priority::Low); sourceResource.setPriority(Resource::Priority::Low);
sourceResource.setUsage(Resource::Usage::Offline); sourceResource.setUsage(Resource::Usage::Offline);
ensureResource(std::move(sourceResource), [=](const Response& sourceResponse) { ensureResource(std::move(sourceResource), [=, this](const Response& sourceResponse) {
style::conversion::Error error; style::conversion::Error error;
std::optional<Tileset> tileset = style::conversion::convertJSON<Tileset>(*sourceResponse.data, std::optional<Tileset> tileset = style::conversion::convertJSON<Tileset>(*sourceResponse.data,
error); error);
@@ -467,7 +467,7 @@ void OfflineDownload::ensureResource(Resource&& resource, std::function<void(Res
assert(resource.usage == Resource::Usage::Offline); assert(resource.usage == Resource::Usage::Offline);
auto workRequestsIt = requests.insert(requests.begin(), nullptr); auto workRequestsIt = requests.insert(requests.begin(), nullptr);
*workRequestsIt = util::RunLoop::Get()->invokeCancellable([=]() { *workRequestsIt = util::RunLoop::Get()->invokeCancellable([=, this]() {
requests.erase(workRequestsIt); requests.erase(workRequestsIt);
const auto resourceKind = resource.kind; const auto resourceKind = resource.kind;
auto getResourceSizeInDatabase = [&]() -> std::optional<int64_t> { auto getResourceSizeInDatabase = [&]() -> std::optional<int64_t> {
@@ -507,7 +507,7 @@ void OfflineDownload::ensureResource(Resource&& resource, std::function<void(Res
} }
auto fileRequestsIt = requests.insert(requests.begin(), nullptr); auto fileRequestsIt = requests.insert(requests.begin(), nullptr);
*fileRequestsIt = onlineFileSource.request(resource, [=](const Response& onlineResponse) { *fileRequestsIt = onlineFileSource.request(resource, [=, this](const Response& onlineResponse) {
if (onlineResponse.error) { if (onlineResponse.error) {
observer->responseError(*onlineResponse.error); observer->responseError(*onlineResponse.error);
if (onlineResponse.error->reason == Response::Error::Reason::NotFound) { if (onlineResponse.error->reason == Response::Error::Reason::NotFound) {

View File

@@ -138,7 +138,7 @@ public:
void queueRequest(OnlineFileRequest* req) { pendingRequests.insert(req); } void queueRequest(OnlineFileRequest* req) { pendingRequests.insert(req); }
void activateRequest(OnlineFileRequest* req) { void activateRequest(OnlineFileRequest* req) {
auto callback = [=](const Response& response) { auto callback = [=, this](const Response& response) {
activeRequests.erase(req); activeRequests.erase(req);
req->request.reset(); req->request.reset();
req->completed(response); req->completed(response);

View File

@@ -153,9 +153,6 @@ std::size_t VertexAttributeGL::getStride() const {
return getStride(getGLType()); return getStride(getGLType());
} }
namespace {
const std::vector<std::uint8_t> noData;
}
const std::vector<std::uint8_t>& VertexAttributeGL::getRaw(gfx::VertexAttribute& attr, platform::GLenum type) { const std::vector<std::uint8_t>& VertexAttributeGL::getRaw(gfx::VertexAttribute& attr, platform::GLenum type) {
const auto count = attr.getCount(); const auto count = attr.getCount();
const auto stride_ = getStride(type); const auto stride_ = getStride(type);

View File

@@ -142,7 +142,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
startTransition( startTransition(
camera, camera,
animation, animation,
[=](double t) { [=, this](double t) {
Point<double> framePoint = util::interpolate(startPoint, endPoint, t); Point<double> framePoint = util::interpolate(startPoint, endPoint, t);
LatLng frameLatLng = Projection::unproject(framePoint, state.zoomScale(startZoom)); LatLng frameLatLng = Projection::unproject(framePoint, state.zoomScale(startZoom));
double frameZoom = util::interpolate(startZoom, zoom, t); double frameZoom = util::interpolate(startZoom, zoom, t);
@@ -299,7 +299,7 @@ void Transform::flyTo(const CameraOptions& camera, const AnimationOptions& anima
startTransition( startTransition(
camera, camera,
animation, animation,
[=](double k) { [=, this](double k) {
/// s: The distance traveled along the flight path, measured in /// s: The distance traveled along the flight path, measured in
/// ρ-screenfuls. /// ρ-screenfuls.
double s = k * S; double s = k * S;

View File

@@ -7,9 +7,9 @@
namespace mbgl { namespace mbgl {
struct ZoomHistory { struct ZoomHistory {
float lastZoom; float lastZoom = 0;
float lastFloorZoom; float lastFloorZoom = 0;
float lastIntegerZoom; float lastIntegerZoom = 0;
TimePoint lastIntegerZoomTime; TimePoint lastIntegerZoomTime;
bool first = true; bool first = true;

View File

@@ -85,7 +85,7 @@ public:
uint64_t imageCorrelationID) = 0; uint64_t imageCorrelationID) = 0;
void addPendingRequest(const std::string& imageId) { pendingRequests.insert(imageId); } void addPendingRequest(const std::string& imageId) { pendingRequests.insert(imageId); }
bool hasPendingRequest(const std::string& imageId) const { return pendingRequests.count(imageId); } bool hasPendingRequest(const std::string& imageId) const { return pendingRequests.contains(imageId); }
bool hasPendingRequests() const { return !pendingRequests.empty(); } bool hasPendingRequests() const { return !pendingRequests.empty(); }
void removePendingRequest(const std::string& imageId) { pendingRequests.erase(imageId); } void removePendingRequest(const std::string& imageId) { pendingRequests.erase(imageId); }

View File

@@ -137,10 +137,6 @@ struct SegmentGroup {
bool operator<(const SegmentGroup& other) const { return renderable < other.renderable; } bool operator<(const SegmentGroup& other) const { return renderable < other.renderable; }
}; };
namespace {
const SegmentVector<SymbolTextAttributes> emptySegmentVector;
}
#if MLN_LEGACY_RENDERER #if MLN_LEGACY_RENDERER
template <typename DrawFn> template <typename DrawFn>
@@ -726,6 +722,8 @@ void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
namespace { namespace {
const SegmentVector<SymbolTextAttributes> emptySegmentVector;
template <typename TText, typename TIcon> template <typename TText, typename TIcon>
const auto& getProperty(const SymbolBucket::PaintProperties& paintProps, bool isText) { const auto& getProperty(const SymbolBucket::PaintProperties& paintProps, bool isText) {
return isText ? paintProps.textBinders.get<TText>() : paintProps.iconBinders.get<TIcon>(); return isText ? paintProps.textBinders.get<TText>() : paintProps.iconBinders.get<TIcon>();

View File

@@ -306,7 +306,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
std::unordered_set<std::string> constantsMaskChanged; std::unordered_set<std::string> constantsMaskChanged;
for (RenderLayer& layer : orderedLayers) { for (RenderLayer& layer : orderedLayers) {
const std::string& id = layer.getID(); const std::string& id = layer.getID();
const bool layerAddedOrChanged = layerDiff.added.count(id) || layerDiff.changed.count(id); const bool layerAddedOrChanged = layerDiff.added.contains(id) || layerDiff.changed.contains(id);
evaluationParameters.layerChanged = layerAddedOrChanged; evaluationParameters.layerChanged = layerAddedOrChanged;
evaluationParameters.hasCrossfade = layer.hasCrossfade(); evaluationParameters.hasCrossfade = layer.hasCrossfade();
@@ -383,7 +383,8 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
if (layerInfo->source != LayerTypeInfo::Source::NotRequired) { if (layerInfo->source != LayerTypeInfo::Source::NotRequired) {
if (layer.baseImpl->source == sourceImpl->id) { if (layer.baseImpl->source == sourceImpl->id) {
const std::string& layerId = layer.getID(); const std::string& layerId = layer.getID();
sourceNeedsRelayout = (sourceNeedsRelayout || hasImageDiff || constantsMaskChanged.count(layerId) || sourceNeedsRelayout = (sourceNeedsRelayout || hasImageDiff ||
constantsMaskChanged.contains(layerId) ||
hasLayoutDifference(layerDiff, layerId)); hasLayoutDifference(layerDiff, layerId));
if (layerIsVisible) { if (layerIsVisible) {
filteredLayersForSource.push_back(layer.evaluatedProperties); filteredLayersForSource.push_back(layer.evaluatedProperties);

View File

@@ -110,18 +110,17 @@ void SourceFeatureState::removeState(const std::optional<std::string>& sourceLay
const std::optional<std::string>& stateKey) { const std::optional<std::string>& stateKey) {
std::string sourceLayer = sourceLayerID.value_or(std::string()); std::string sourceLayer = sourceLayerID.value_or(std::string());
bool sourceLayerDeleted = (deletedStates.count(sourceLayer) > 0) && deletedStates[sourceLayer].empty(); bool sourceLayerDeleted = deletedStates.contains(sourceLayer) && deletedStates[sourceLayer].empty();
if (sourceLayerDeleted) { if (sourceLayerDeleted) {
return; return;
} }
if (stateKey && featureID) { if (stateKey && featureID) {
if ((deletedStates.count(sourceLayer) == 0) && (deletedStates[sourceLayer].count(*featureID)) == 0) { if (!deletedStates.contains(sourceLayer) && !deletedStates[sourceLayer].contains(*featureID)) {
deletedStates[sourceLayer][*featureID][*stateKey] = {}; deletedStates[sourceLayer][*featureID][*stateKey] = {};
} }
} else if (featureID) { } else if (featureID) {
bool updateInQueue = (stateChanges.count(sourceLayer) != 0U) && bool updateInQueue = stateChanges.contains(sourceLayer) && stateChanges[sourceLayer].contains(*featureID);
(stateChanges[sourceLayer].count(*featureID) != 0U);
if (updateInQueue) { if (updateInQueue) {
for (const auto& changeEntry : stateChanges[sourceLayer][*featureID]) { for (const auto& changeEntry : stateChanges[sourceLayer][*featureID]) {
deletedStates[sourceLayer][*featureID][changeEntry.first] = {}; deletedStates[sourceLayer][*featureID][changeEntry.first] = {};

View File

@@ -62,7 +62,7 @@ LayerDifference diffLayers(const Immutable<std::vector<ImmutableLayer>>& a,
} }
bool hasLayoutDifference(const LayerDifference& layerDiff, const std::string& layerID) { bool hasLayoutDifference(const LayerDifference& layerDiff, const std::string& layerID) {
if (layerDiff.added.count(layerID)) return true; if (layerDiff.added.contains(layerID)) return true;
const auto it = layerDiff.changed.find(layerID); const auto it = layerDiff.changed.find(layerID);
if (it == layerDiff.changed.end()) return false; if (it == layerDiff.changed.end()) return false;
return it->second.before->hasLayoutDifference(*it->second.after); return it->second.before->hasLayoutDifference(*it->second.after);

View File

@@ -1098,6 +1098,7 @@ std::string expectedTypesError(const Definitions& definitions, const std::vector
} }
}); });
} }
std::string signatures = overloads.empty() ? boost::algorithm::join(availableOverloads, " | ") std::string signatures = overloads.empty() ? boost::algorithm::join(availableOverloads, " | ")
: boost::algorithm::join(overloads, " | "); : boost::algorithm::join(overloads, " | ");

View File

@@ -111,7 +111,7 @@ std::shared_ptr<GeoJSONData> GeoJSONData::create(const GeoJSON& geoJSON,
}; };
clusterOptions.reduce = [feature, options](PropertyMap& toReturn, const PropertyMap& toFill) { clusterOptions.reduce = [feature, options](PropertyMap& toReturn, const PropertyMap& toFill) {
for (const auto& p : options->clusterProperties) { for (const auto& p : options->clusterProperties) {
if (toFill.count(p.first) == 0) { if (!toFill.contains(p.first)) {
continue; continue;
} }
feature->properties = toFill; feature->properties = toFill;

View File

@@ -28,8 +28,6 @@
namespace mbgl { namespace mbgl {
namespace style { namespace style {
static Observer nullObserver;
Style::Impl::Impl(std::shared_ptr<FileSource> fileSource_, float pixelRatio, const TaggedScheduler& threadPool_) Style::Impl::Impl(std::shared_ptr<FileSource> fileSource_, float pixelRatio, const TaggedScheduler& threadPool_)
: fileSource(std::move(fileSource_)), : fileSource(std::move(fileSource_)),
spriteLoader(std::make_unique<SpriteLoader>(pixelRatio, threadPool_)), spriteLoader(std::make_unique<SpriteLoader>(pixelRatio, threadPool_)),

View File

@@ -203,7 +203,7 @@ bool CrossTileSymbolLayerIndex::removeStaleBuckets(const std::unordered_set<uint
bool tilesChanged = false; bool tilesChanged = false;
for (auto& zoomIndexes : indexes) { for (auto& zoomIndexes : indexes) {
for (auto it = zoomIndexes.second.begin(); it != zoomIndexes.second.end();) { for (auto it = zoomIndexes.second.begin(); it != zoomIndexes.second.end();) {
if (!currentIDs.count(it->second.bucketInstanceId)) { if (!currentIDs.contains(it->second.bucketInstanceId)) {
removeBucketCrossTileIDs(zoomIndexes.first, it->second); removeBucketCrossTileIDs(zoomIndexes.first, it->second);
it = zoomIndexes.second.erase(it); it = zoomIndexes.second.erase(it);
tilesChanged = true; tilesChanged = true;

View File

@@ -249,7 +249,7 @@ void Placement::placeSymbolBucket(const BucketPlacementData& params, std::set<ui
collisionGroups.get(params.sourceId), collisionGroups.get(params.sourceId),
getAvoidEdges(symbolBucket, renderTile.matrix)}; getAvoidEdges(symbolBucket, renderTile.matrix)};
for (const SymbolInstance& symbol : getSortedSymbols(params, ctx.pixelRatio)) { for (const SymbolInstance& symbol : getSortedSymbols(params, ctx.pixelRatio)) {
if (seenCrossTileIDs.count(symbol.crossTileID) != 0u) continue; if (seenCrossTileIDs.contains(symbol.crossTileID)) continue;
placeSymbol(symbol, ctx); placeSymbol(symbol, ctx);
// Prevent a flickering issue while zooming out. // Prevent a flickering issue while zooming out.
@@ -983,7 +983,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket,
true); true);
for (SymbolInstance& symbolInstance : bucket.symbolInstances) { for (SymbolInstance& symbolInstance : bucket.symbolInstances) {
bool isDuplicate = seenCrossTileIDs.count(symbolInstance.crossTileID) > 0; bool isDuplicate = seenCrossTileIDs.contains(symbolInstance.crossTileID);
auto it = opacities.find(symbolInstance.crossTileID); auto it = opacities.find(symbolInstance.crossTileID);
auto opacityState = defaultOpacityState; auto opacityState = defaultOpacityState;
@@ -1414,7 +1414,7 @@ void TilePlacement::placeLayers(const RenderLayerReferences& layers) {
const SymbolInstance& symbol = intersection.symbol; const SymbolInstance& symbol = intersection.symbol;
const PlacementContext& ctx = intersection.ctx; const PlacementContext& ctx = intersection.ctx;
currentIntersectionPriority = intersection.priority; currentIntersectionPriority = intersection.priority;
if (seenCrossTileIDs.count(symbol.crossTileID) != 0u) continue; if (seenCrossTileIDs.contains(symbol.crossTileID)) continue;
JointPlacement placement = placeSymbol(symbol, ctx); JointPlacement placement = placeSymbol(symbol, ctx);
if (shouldRetryPlacement(placement, ctx)) continue; if (shouldRetryPlacement(placement, ctx)) continue;
seenCrossTileIDs.insert(symbol.crossTileID); seenCrossTileIDs.insert(symbol.crossTileID);

View File

@@ -265,7 +265,7 @@ void GridIndex<T>::query(const BBox& queryBBox, std::function<bool(const T&, con
cellIndex = xCellCount * y + x; cellIndex = xCellCount * y + x;
// Look up other boxes // Look up other boxes
for (auto uid : boxCells[cellIndex]) { for (auto uid : boxCells[cellIndex]) {
if (seenBoxes.count(uid) == 0) { if (!seenBoxes.contains(uid)) {
seenBoxes.insert(uid); seenBoxes.insert(uid);
auto& pair = boxElements.at(uid); auto& pair = boxElements.at(uid);
@@ -280,7 +280,7 @@ void GridIndex<T>::query(const BBox& queryBBox, std::function<bool(const T&, con
// Look up circles // Look up circles
for (auto uid : circleCells[cellIndex]) { for (auto uid : circleCells[cellIndex]) {
if (seenCircles.count(uid) == 0) { if (!seenCircles.contains(uid)) {
seenCircles.insert(uid); seenCircles.insert(uid);
auto& pair = circleElements.at(uid); auto& pair = circleElements.at(uid);
@@ -330,7 +330,7 @@ void GridIndex<T>::query(const BCircle& queryBCircle, std::function<bool(const T
cellIndex = xCellCount * y + x; cellIndex = xCellCount * y + x;
// Look up boxes // Look up boxes
for (auto uid : boxCells[cellIndex]) { for (auto uid : boxCells[cellIndex]) {
if (seenBoxes.count(uid) == 0) { if (!seenBoxes.contains(uid)) {
seenBoxes.insert(uid); seenBoxes.insert(uid);
auto& pair = boxElements.at(uid); auto& pair = boxElements.at(uid);
@@ -345,7 +345,7 @@ void GridIndex<T>::query(const BCircle& queryBCircle, std::function<bool(const T
// Look up other circles // Look up other circles
for (auto uid : circleCells[cellIndex]) { for (auto uid : circleCells[cellIndex]) {
if (seenCircles.count(uid) == 0) { if (!seenCircles.contains(uid)) {
seenCircles.insert(uid); seenCircles.insert(uid);
auto& pair = circleElements.at(uid); auto& pair = circleElements.at(uid);

View File

@@ -371,12 +371,12 @@ TEST(Annotations, QueryRenderedFeatures) {
ASSERT_NEAR(points[1].y, point1.y, 1e-8); ASSERT_NEAR(points[1].y, point1.y, 1e-8);
auto features = test.frontend.getRenderer()->queryRenderedFeatures(point0); auto features = test.frontend.getRenderer()->queryRenderedFeatures(point0);
EXPECT_EQ(features.size(), 1u); ASSERT_EQ(features.size(), 1u);
EXPECT_EQ(features[0].id.is<NullValue>(), false); EXPECT_EQ(features[0].id.is<NullValue>(), false);
EXPECT_EQ(features[0].id, uint64_t(0)); EXPECT_EQ(features[0].id, uint64_t(0));
auto features2 = test.frontend.getRenderer()->queryRenderedFeatures(point1); auto features2 = test.frontend.getRenderer()->queryRenderedFeatures(point1);
EXPECT_EQ(features2.size(), 1u); ASSERT_EQ(features2.size(), 1u);
EXPECT_EQ(features[0].id.is<NullValue>(), false); EXPECT_EQ(features[0].id.is<NullValue>(), false);
EXPECT_EQ(features2[0].id, uint64_t(1)); EXPECT_EQ(features2[0].id, uint64_t(1));
} }

View File

@@ -201,7 +201,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterChildren) {
QueryTest test; QueryTest test;
auto topClusterFeature = getTopClusterFeature(test); auto topClusterFeature = getTopClusterFeature(test);
EXPECT_EQ(topClusterFeature.size(), 1u); ASSERT_EQ(topClusterFeature.size(), 1u);
const auto featureProps = topClusterFeature[0].properties; const auto featureProps = topClusterFeature[0].properties;
auto clusterId = featureProps.find("cluster_id"s); auto clusterId = featureProps.find("cluster_id"s);
auto cluster = featureProps.find("cluster"s); auto cluster = featureProps.find("cluster"s);
@@ -213,7 +213,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterChildren) {
EXPECT_TRUE(queryChildren.is<FeatureCollection>()); EXPECT_TRUE(queryChildren.is<FeatureCollection>());
auto children = queryChildren.get<FeatureCollection>(); auto children = queryChildren.get<FeatureCollection>();
EXPECT_EQ(children.size(), 4u); ASSERT_EQ(children.size(), 4u);
// Compare results produced by supercluster with default clustering options. // Compare results produced by supercluster with default clustering options.
EXPECT_EQ(children[0].properties["cluster_id"].get<uint64_t>(), 2u); EXPECT_EQ(children[0].properties["cluster_id"].get<uint64_t>(), 2u);
@@ -229,7 +229,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterChildren) {
TEST(Query, QueryFeatureExtensionsSuperclusterExpansionZoom) { TEST(Query, QueryFeatureExtensionsSuperclusterExpansionZoom) {
QueryTest test; QueryTest test;
auto topClusterFeature = getTopClusterFeature(test); auto topClusterFeature = getTopClusterFeature(test);
EXPECT_EQ(topClusterFeature.size(), 1u); ASSERT_EQ(topClusterFeature.size(), 1u);
auto queryChildren = test.frontend.getRenderer()->queryFeatureExtensions( auto queryChildren = test.frontend.getRenderer()->queryFeatureExtensions(
"cluster_source"s, topClusterFeature[0], "supercluster"s, "children"s); "cluster_source"s, topClusterFeature[0], "supercluster"s, "children"s);
@@ -251,7 +251,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterExpansionZoom) {
TEST(Query, QueryFeatureExtensionsSuperclusterLeaves) { TEST(Query, QueryFeatureExtensionsSuperclusterLeaves) {
QueryTest test; QueryTest test;
auto topClusterFeature = getTopClusterFeature(test); auto topClusterFeature = getTopClusterFeature(test);
EXPECT_EQ(topClusterFeature.size(), 1u); ASSERT_EQ(topClusterFeature.size(), 1u);
// Get leaves for cluster 1, with default limit 10, offset 0. // Get leaves for cluster 1, with default limit 10, offset 0.
auto queryClusterLeaves = test.frontend.getRenderer()->queryFeatureExtensions( auto queryClusterLeaves = test.frontend.getRenderer()->queryFeatureExtensions(
@@ -265,7 +265,7 @@ TEST(Query, QueryFeatureExtensionsSuperclusterLeaves) {
auto queryClusterLeavesLimit3 = test.frontend.getRenderer()->queryFeatureExtensions( auto queryClusterLeavesLimit3 = test.frontend.getRenderer()->queryFeatureExtensions(
"cluster_source"s, topClusterFeature[0], "supercluster"s, "leaves"s, limitOpts); "cluster_source"s, topClusterFeature[0], "supercluster"s, "leaves"s, limitOpts);
auto limitLeaves3 = queryClusterLeavesLimit3.get<FeatureCollection>(); auto limitLeaves3 = queryClusterLeavesLimit3.get<FeatureCollection>();
EXPECT_EQ(limitLeaves3.size(), 3u); ASSERT_EQ(limitLeaves3.size(), 3u);
EXPECT_EQ(limitLeaves3[0].properties["name"].get<std::string>(), "Niagara Falls"s); EXPECT_EQ(limitLeaves3[0].properties["name"].get<std::string>(), "Niagara Falls"s);
EXPECT_EQ(limitLeaves3[1].properties["name"].get<std::string>(), "Cape May"s); EXPECT_EQ(limitLeaves3[1].properties["name"].get<std::string>(), "Cape May"s);

View File

@@ -140,9 +140,9 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(ExpiresParsing)) {
EXPECT_EQ(nullptr, res.error); EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get()); ASSERT_TRUE(res.data.get());
EXPECT_EQ("Hello World!", *res.data); EXPECT_EQ("Hello World!", *res.data);
EXPECT_EQ(Timestamp{Seconds(1420797926)}, res.expires); EXPECT_TRUE(Timestamp{Seconds(1420797926)} == res.expires);
EXPECT_FALSE(res.mustRevalidate); EXPECT_FALSE(res.mustRevalidate);
EXPECT_EQ(Timestamp{Seconds(1420794326)}, res.modified); EXPECT_TRUE(Timestamp{Seconds(1420794326)} == res.modified);
EXPECT_EQ("foo", *res.etag); EXPECT_EQ("foo", *res.etag);
loop.stop(); loop.stop();
}); });

View File

@@ -42,9 +42,9 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheResponse)) {
EXPECT_EQ(response.error, res2.error); EXPECT_EQ(response.error, res2.error);
ASSERT_TRUE(res2.data.get()); ASSERT_TRUE(res2.data.get());
EXPECT_EQ(*response.data, *res2.data); EXPECT_EQ(*response.data, *res2.data);
EXPECT_EQ(response.expires, res2.expires); EXPECT_TRUE(response.expires == res2.expires);
EXPECT_EQ(response.mustRevalidate, res2.mustRevalidate); EXPECT_EQ(response.mustRevalidate, res2.mustRevalidate);
EXPECT_EQ(response.modified, res2.modified); EXPECT_TRUE(response.modified == res2.modified);
EXPECT_EQ(response.etag, res2.etag); EXPECT_EQ(response.etag, res2.etag);
loop.stop(); loop.stop();
@@ -166,7 +166,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheRevalidateModified)) {
EXPECT_EQ("Response", *res.data); EXPECT_EQ("Response", *res.data);
EXPECT_FALSE(bool(res.expires)); EXPECT_FALSE(bool(res.expires));
EXPECT_TRUE(res.mustRevalidate); EXPECT_TRUE(res.mustRevalidate);
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res.modified); EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res.modified);
EXPECT_FALSE(res.etag); EXPECT_FALSE(res.etag);
// The first response is stored in the cache, but it has // The first response is stored in the cache, but it has
@@ -188,7 +188,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheRevalidateModified)) {
EXPECT_EQ("Response", *res2.data); EXPECT_EQ("Response", *res2.data);
EXPECT_TRUE(bool(res2.expires)); EXPECT_TRUE(bool(res2.expires));
EXPECT_TRUE(res2.mustRevalidate); EXPECT_TRUE(res2.mustRevalidate);
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res2.modified); EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res2.modified);
EXPECT_FALSE(res2.etag); EXPECT_FALSE(res2.etag);
} else { } else {
// The test server sends a Cache-Control header with a max-age // The test server sends a Cache-Control header with a max-age
@@ -203,7 +203,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheRevalidateModified)) {
EXPECT_FALSE(res2.data.get()); EXPECT_FALSE(res2.data.get());
EXPECT_TRUE(bool(res2.expires)); EXPECT_TRUE(bool(res2.expires));
EXPECT_TRUE(res2.mustRevalidate); EXPECT_TRUE(res2.mustRevalidate);
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res2.modified); EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res2.modified);
EXPECT_FALSE(res2.etag); EXPECT_FALSE(res2.etag);
loop.stop(); loop.stop();
} }
@@ -311,7 +311,7 @@ TEST(MainResourceLoader, OptionalNonExpired) {
ASSERT_TRUE(res.data.get()); ASSERT_TRUE(res.data.get());
EXPECT_EQ("Cached value", *res.data); EXPECT_EQ("Cached value", *res.data);
ASSERT_TRUE(bool(res.expires)); ASSERT_TRUE(bool(res.expires));
EXPECT_EQ(*response.expires, *res.expires); EXPECT_TRUE(*response.expires == *res.expires);
EXPECT_FALSE(res.mustRevalidate); EXPECT_FALSE(res.mustRevalidate);
EXPECT_FALSE(bool(res.modified)); EXPECT_FALSE(bool(res.modified));
EXPECT_FALSE(bool(res.etag)); EXPECT_FALSE(bool(res.etag));
@@ -344,7 +344,7 @@ TEST(MainResourceLoader, OptionalExpired) {
ASSERT_TRUE(res.data.get()); ASSERT_TRUE(res.data.get());
EXPECT_EQ("Cached value", *res.data); EXPECT_EQ("Cached value", *res.data);
ASSERT_TRUE(bool(res.expires)); ASSERT_TRUE(bool(res.expires));
EXPECT_EQ(*response.expires, *res.expires); EXPECT_TRUE(*response.expires == *res.expires);
EXPECT_FALSE(res.mustRevalidate); EXPECT_FALSE(res.mustRevalidate);
EXPECT_FALSE(bool(res.modified)); EXPECT_FALSE(bool(res.modified));
EXPECT_FALSE(bool(res.etag)); EXPECT_FALSE(bool(res.etag));
@@ -406,7 +406,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(NoCacheRefreshEtagNotModified)) {
EXPECT_TRUE(res.notModified); EXPECT_TRUE(res.notModified);
EXPECT_FALSE(res.data.get()); EXPECT_FALSE(res.data.get());
ASSERT_TRUE(bool(res.expires)); ASSERT_TRUE(bool(res.expires));
EXPECT_LT(util::now(), *res.expires); EXPECT_TRUE(util::now() < *res.expires);
EXPECT_TRUE(res.mustRevalidate); EXPECT_TRUE(res.mustRevalidate);
EXPECT_FALSE(bool(res.modified)); EXPECT_FALSE(bool(res.modified));
ASSERT_TRUE(bool(res.etag)); ASSERT_TRUE(bool(res.etag));
@@ -517,10 +517,10 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(NoCacheRefreshModifiedNotModified)
EXPECT_TRUE(res.notModified); EXPECT_TRUE(res.notModified);
EXPECT_FALSE(res.data.get()); EXPECT_FALSE(res.data.get());
ASSERT_TRUE(bool(res.expires)); ASSERT_TRUE(bool(res.expires));
EXPECT_LT(util::now(), *res.expires); EXPECT_TRUE(util::now() < *res.expires);
EXPECT_TRUE(res.mustRevalidate); EXPECT_TRUE(res.mustRevalidate);
ASSERT_TRUE(bool(res.modified)); ASSERT_TRUE(bool(res.modified));
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res.modified); EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res.modified);
EXPECT_FALSE(bool(res.etag)); EXPECT_FALSE(bool(res.etag));
loop.stop(); loop.stop();
}); });
@@ -557,7 +557,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(NoCacheRefreshModifiedModified)) {
EXPECT_EQ("Response", *res.data); EXPECT_EQ("Response", *res.data);
EXPECT_FALSE(bool(res.expires)); EXPECT_FALSE(bool(res.expires));
EXPECT_TRUE(res.mustRevalidate); EXPECT_TRUE(res.mustRevalidate);
EXPECT_EQ(Timestamp{Seconds(1420070400)}, *res.modified); EXPECT_TRUE(Timestamp{Seconds(1420070400)} == *res.modified);
EXPECT_FALSE(res.etag); EXPECT_FALSE(res.etag);
loop.stop(); loop.stop();
}); });
@@ -662,10 +662,10 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(RespondToStaleMustRevalidate)) {
ASSERT_TRUE(res.data.get()); ASSERT_TRUE(res.data.get());
EXPECT_EQ("Cached value", *res.data); EXPECT_EQ("Cached value", *res.data);
ASSERT_TRUE(res.expires); ASSERT_TRUE(res.expires);
EXPECT_EQ(Timestamp{Seconds(1417392000)}, *res.expires); EXPECT_TRUE(Timestamp{Seconds(1417392000)} == *res.expires);
EXPECT_TRUE(res.mustRevalidate); EXPECT_TRUE(res.mustRevalidate);
ASSERT_TRUE(res.modified); ASSERT_TRUE(res.modified);
EXPECT_EQ(Timestamp{Seconds(1417392000)}, *res.modified); EXPECT_TRUE(Timestamp{Seconds(1417392000)} == *res.modified);
ASSERT_TRUE(res.etag); ASSERT_TRUE(res.etag);
EXPECT_EQ("snowfall", *res.etag); EXPECT_EQ("snowfall", *res.etag);
@@ -702,10 +702,10 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(RespondToStaleMustRevalidate)) {
// a 304 Not Modified response. // a 304 Not Modified response.
EXPECT_EQ("Prior value", *res.data); EXPECT_EQ("Prior value", *res.data);
ASSERT_TRUE(res.expires); ASSERT_TRUE(res.expires);
EXPECT_LE(util::now(), *res.expires); EXPECT_TRUE(util::now() <= *res.expires);
EXPECT_TRUE(res.mustRevalidate); EXPECT_TRUE(res.mustRevalidate);
ASSERT_TRUE(res.modified); ASSERT_TRUE(res.modified);
EXPECT_EQ(Timestamp{Seconds(1417392000)}, *res.modified); EXPECT_TRUE(Timestamp{Seconds(1417392000)} == *res.modified);
ASSERT_TRUE(res.etag); ASSERT_TRUE(res.etag);
EXPECT_EQ("snowfall", *res.etag); EXPECT_EQ("snowfall", *res.etag);
loop.stop(); loop.stop();

View File

@@ -1790,7 +1790,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(MergeDatabaseWithSingleRegion_Update))
auto updatedTile = db.getRegionResource(Resource::tile(tileURL, 1, 0, 0, 1, Tileset::Scheme::XYZ)); auto updatedTile = db.getRegionResource(Resource::tile(tileURL, 1, 0, 0, 1, Tileset::Scheme::XYZ));
auto updatedStamp = updatedTile->first.modified; auto updatedStamp = updatedTile->first.modified;
EXPECT_EQ(*originalStamp, *updatedStamp); EXPECT_TRUE(*originalStamp == *updatedStamp);
} }
} }
@@ -1815,7 +1815,7 @@ TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_NoUpdate) {
auto updatedTile = db.getRegionResource(Resource::tile(tileURL, 1, 0, 0, 1, Tileset::Scheme::XYZ)); auto updatedTile = db.getRegionResource(Resource::tile(tileURL, 1, 0, 0, 1, Tileset::Scheme::XYZ));
// Verify the modified timestamp matches the tile in the main db. // Verify the modified timestamp matches the tile in the main db.
EXPECT_EQ(originalStamp, updatedTile->first.modified); EXPECT_TRUE(originalStamp == updatedTile->first.modified);
} }
TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_AmbientTiles) { TEST(OfflineDatabase, MergeDatabaseWithSingleRegion_AmbientTiles) {

View File

@@ -155,7 +155,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryDelayOnExpiredTile)) {
std::unique_ptr<AsyncRequest> req = fs->request(resource, [&](Response res) { std::unique_ptr<AsyncRequest> req = fs->request(resource, [&](Response res) {
counter++; counter++;
EXPECT_EQ(nullptr, res.error); EXPECT_EQ(nullptr, res.error);
EXPECT_GT(util::now(), *res.expires); EXPECT_TRUE(util::now() > *res.expires);
EXPECT_FALSE(res.mustRevalidate); EXPECT_FALSE(res.mustRevalidate);
loop.stop(); loop.stop();
}); });
@@ -177,14 +177,14 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryOnClockSkew)) {
switch (counter++) { switch (counter++) {
case 0: { case 0: {
EXPECT_EQ(nullptr, res.error); EXPECT_EQ(nullptr, res.error);
EXPECT_GT(util::now(), *res.expires); EXPECT_TRUE(util::now() > *res.expires);
} break; } break;
case 1: { case 1: {
EXPECT_EQ(nullptr, res.error); EXPECT_EQ(nullptr, res.error);
auto now = util::now(); auto now = util::now();
EXPECT_LT(now + Seconds(40), *res.expires) << "Expiration not interpolated to 60s"; EXPECT_TRUE(now + Seconds(40) < *res.expires) << "Expiration not interpolated to 60s";
EXPECT_GT(now + Seconds(80), *res.expires) << "Expiration not interpolated to 60s"; EXPECT_TRUE(now + Seconds(80) > *res.expires) << "Expiration not interpolated to 60s";
loop.stop(); loop.stop();
} break; } break;
@@ -385,7 +385,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitStandard)) {
ASSERT_NE(nullptr, res.error); ASSERT_NE(nullptr, res.error);
EXPECT_EQ(Response::Error::Reason::RateLimit, res.error->reason); EXPECT_EQ(Response::Error::Reason::RateLimit, res.error->reason);
ASSERT_EQ(true, bool(res.error->retryAfter)); ASSERT_EQ(true, bool(res.error->retryAfter));
ASSERT_LT(util::now(), res.error->retryAfter); ASSERT_TRUE(util::now() < res.error->retryAfter);
loop.stop(); loop.stop();
}); });
@@ -400,7 +400,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RateLimitMBX)) {
ASSERT_NE(nullptr, res.error); ASSERT_NE(nullptr, res.error);
EXPECT_EQ(Response::Error::Reason::RateLimit, res.error->reason); EXPECT_EQ(Response::Error::Reason::RateLimit, res.error->reason);
ASSERT_EQ(true, bool(res.error->retryAfter)); ASSERT_EQ(true, bool(res.error->retryAfter));
ASSERT_LT(util::now(), res.error->retryAfter); ASSERT_TRUE(util::now() < res.error->retryAfter);
loop.stop(); loop.stop();
}); });

View File

@@ -336,7 +336,7 @@ void benchmark(const std::string_view label,
for (std::size_t j = 0; j < lookups; ++j) { for (std::size_t j = 0; j < lookups; ++j) {
for (const auto& k : testKeys) { for (const auto& k : testKeys) {
if (map.count(k)) { if (map.count(k)) {
do_not_optimize_away++; do_not_optimize_away = do_not_optimize_away + 1;
} }
} }
} }