summaryrefslogtreecommitdiff
path: root/expression-test
diff options
context:
space:
mode:
Diffstat (limited to 'expression-test')
-rw-r--r--expression-test/expression_test_parser.cpp18
-rw-r--r--expression-test/expression_test_parser.hpp10
-rw-r--r--expression-test/expression_test_runner.cpp3
3 files changed, 25 insertions, 6 deletions
diff --git a/expression-test/expression_test_parser.cpp b/expression-test/expression_test_parser.cpp
index 3b40eeb3b0..15136f0231 100644
--- a/expression-test/expression_test_parser.cpp
+++ b/expression-test/expression_test_parser.cpp
@@ -104,8 +104,7 @@ optional<Value> toValue(const JSValue& jsvalue) {
style::expression::type::Type stringToType(const std::string& type) {
using namespace style::expression;
- if (type == "string"s || type == "number-format"s ||
- type == "image"s) { // TODO: replace once we implement image expressions
+ if (type == "string"s || type == "number-format"s) {
return type::String;
} else if (type == "number"s) {
return type::Number;
@@ -119,6 +118,8 @@ style::expression::type::Type stringToType(const std::string& type) {
return type::Value;
} else if (type == "formatted"s) {
return type::Formatted;
+ } else if (type == "resolvedImage"s) {
+ return type::Image;
}
// Should not reach.
@@ -253,6 +254,16 @@ bool parseInputs(const JSValue& inputsValue, TestData& data) {
heatmapDensity = evaluationContext["heatmapDensity"].GetDouble();
}
+ // Parse availableImages
+ std::set<std::string> availableImages;
+ if (evaluationContext.HasMember("availableImages")) {
+ assert(evaluationContext["availableImages"].IsArray());
+ for (const auto& image : evaluationContext["availableImages"].GetArray()) {
+ assert(image.IsString());
+ availableImages.emplace(toString(image));
+ }
+ }
+
// Parse feature properties
Feature feature(mapbox::geometry::point<double>(0.0, 0.0));
const auto& featureObject = input[1].GetObject();
@@ -271,7 +282,8 @@ bool parseInputs(const JSValue& inputsValue, TestData& data) {
feature.id = mapbox::geojson::convert<mapbox::feature::identifier>(featureObject["id"]);
}
- data.inputs.emplace_back(std::move(zoom), std::move(heatmapDensity), std::move(feature));
+ data.inputs.emplace_back(
+ std::move(zoom), std::move(heatmapDensity), std::move(availableImages), std::move(feature));
}
return true;
}
diff --git a/expression-test/expression_test_parser.hpp b/expression-test/expression_test_parser.hpp
index 561ccd9647..842d8a1563 100644
--- a/expression-test/expression_test_parser.hpp
+++ b/expression-test/expression_test_parser.hpp
@@ -7,18 +7,24 @@
#include <mbgl/util/optional.hpp>
#include <mbgl/util/rapidjson.hpp>
-#include <vector>
+#include <set>
#include <string>
+#include <vector>
using namespace mbgl;
struct Input {
- Input(optional<float> zoom_, optional<double> heatmapDensity_, Feature feature_)
+ Input(optional<float> zoom_,
+ optional<double> heatmapDensity_,
+ std::set<std::string> availableImages_,
+ Feature feature_)
: zoom(std::move(zoom_)),
heatmapDensity(std::move(heatmapDensity_)),
+ availableImages(std::move(availableImages_)),
feature(std::move(feature_)) {}
optional<float> zoom;
optional<double> heatmapDensity;
+ std::set<std::string> availableImages;
Feature feature;
};
diff --git a/expression-test/expression_test_runner.cpp b/expression-test/expression_test_runner.cpp
index c8a39f07ce..436e449921 100644
--- a/expression-test/expression_test_runner.cpp
+++ b/expression-test/expression_test_runner.cpp
@@ -104,7 +104,8 @@ TestRunOutput runExpressionTest(TestData& data, const std::string& rootPath, con
std::vector<Value> outputs;
if (!data.inputs.empty()) {
for (const auto& input : data.inputs) {
- auto evaluationResult = expression->evaluate(input.zoom, input.feature, input.heatmapDensity);
+ auto evaluationResult =
+ expression->evaluate(input.zoom, input.feature, input.heatmapDensity, input.availableImages);
if (!evaluationResult) {
std::unordered_map<std::string, Value> error{{"error", Value{evaluationResult.error().message}}};
outputs.emplace_back(Value{std::move(error)});