summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-15 14:55:45 -0700
committerGitHub <noreply@github.com>2016-06-15 14:55:45 -0700
commita0b298211908036da269e7dcc2c78025476e2bf2 (patch)
tree3ef9df845e52290f8d6df918728c8eae92abd340 /test
parent199ea2a82a74cf2f7b63078e2dd4b8274c061851 (diff)
downloadqtlocation-mapboxgl-a0b298211908036da269e7dcc2c78025476e2bf2.tar.gz
[core] Prepare Filter and FilterEvaluator for extraction (#5366)
Diffstat (limited to 'test')
-rw-r--r--test/style/filter.cpp37
1 files changed, 6 insertions, 31 deletions
diff --git a/test/style/filter.cpp b/test/style/filter.cpp
index d28ee4a357..4a1010445e 100644
--- a/test/style/filter.cpp
+++ b/test/style/filter.cpp
@@ -3,7 +3,6 @@
#include <mbgl/style/filter.hpp>
#include <mbgl/style/filter_evaluator.hpp>
#include <mbgl/style/parser.hpp>
-#include <mbgl/tile/geometry_tile_data.hpp>
#include <rapidjson/document.h>
@@ -14,33 +13,6 @@ using namespace mbgl::style;
typedef std::multimap<std::string, mbgl::Value> Properties;
-class StubFeature : public GeometryTileFeature {
-public:
- inline StubFeature(Properties properties_, FeatureType type_)
- : properties(std::move(properties_))
- , type(type_)
- {}
-
- optional<Value> getValue(const std::string &key) const override {
- auto it = properties.find(key);
- if (it == properties.end())
- return optional<Value>();
- return it->second;
- }
-
- FeatureType getType() const override {
- return type;
- }
-
- GeometryCollection getGeometries() const override {
- return GeometryCollection();
- }
-
-private:
- const Properties properties;
- FeatureType type;
-};
-
Filter parse(const char * expression) {
rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> doc;
doc.Parse<0>(expression);
@@ -48,9 +20,12 @@ Filter parse(const char * expression) {
}
bool evaluate(const Filter& filter, const Properties& properties, FeatureType type = FeatureType::Unknown) {
- StubFeature feature(properties, type);
- FilterEvaluator evaluator(feature);
- return Filter::visit(filter, evaluator);
+ return filter(type, [&] (const std::string& key) -> optional<Value> {
+ auto it = properties.find(key);
+ if (it == properties.end())
+ return {};
+ return it->second;
+ });
}
TEST(Filter, EqualsString) {