diff options
author | clydebarrow <github@cps.sr20.org> | 2016-09-14 10:33:54 +1000 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-16 10:58:42 -0700 |
commit | 767aedc6766d1dd277f674ae54894cfcf21a437a (patch) | |
tree | 4f7bc65dd4be56b8f423aaa26f3af3c53d7d7a27 /test | |
parent | 36076a1d6de1e81623bd00e48cd1c5b16b769e43 (diff) | |
download | qtlocation-mapboxgl-767aedc6766d1dd277f674ae54894cfcf21a437a.tar.gz |
[core] Correct evaluation of interval functions
Diffstat (limited to 'test')
-rw-r--r-- | test/style/functions.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/style/functions.cpp b/test/style/functions.cpp index 5406320e4c..9577bcc633 100644 --- a/test/style/functions.cpp +++ b/test/style/functions.cpp @@ -10,6 +10,9 @@ using namespace mbgl::style; float evaluate(PropertyValue<float> value, float zoom) { return PropertyValue<float>::visit(value, PropertyEvaluator<float>(CalculationParameters(zoom), 0)); } +std::string evaluate(PropertyValue<std::string> value, float zoom) { + return PropertyValue<std::string>::visit(value, PropertyEvaluator<std::string>(CalculationParameters(zoom), "")); +} TEST(Function, Constant) { EXPECT_EQ(2.0f, evaluate(2, 0)); @@ -61,4 +64,12 @@ TEST(Function, Stops) { EXPECT_EQ(4, evaluate(slope_4, 2)); EXPECT_EQ(4.75, evaluate(slope_4, 2.75)); EXPECT_EQ(10, evaluate(slope_4, 8)); + + // discrete values + Function<std::string> discrete_0({{ 3, "string0"}, {6, "string1"}, {9, "string2"}}, 1); + EXPECT_EQ("string0", evaluate(discrete_0, 2)); + EXPECT_EQ("string0", evaluate(discrete_0, 4)); + EXPECT_EQ("string1", evaluate(discrete_0, 7)); + EXPECT_EQ("string2", evaluate(discrete_0, 9)); + EXPECT_EQ("string2", evaluate(discrete_0, 10)); } |