summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-12-22 12:34:38 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-12-22 18:14:00 -0800
commit083cee8956e6aa89eefe93df6e5c286a1b6728b8 (patch)
treedf3283ecadaf6c82b822f69c9c213a96b91febb2 /test
parent317b2bf42fc16b629abcd0a984d4acc14070904f (diff)
downloadqtlocation-mapboxgl-083cee8956e6aa89eefe93df6e5c286a1b6728b8.tar.gz
[core] Correct boolean function interpolation
Diffstat (limited to 'test')
-rw-r--r--test/style/functions.test.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/test/style/functions.test.cpp b/test/style/functions.test.cpp
index c50787814b..93447a8943 100644
--- a/test/style/functions.test.cpp
+++ b/test/style/functions.test.cpp
@@ -13,17 +13,20 @@ float evaluate(PropertyValue<float> value, float zoom) {
std::string evaluate(PropertyValue<std::string> value, float zoom) {
return value.evaluate(PropertyEvaluator<std::string>(PropertyEvaluationParameters(zoom), ""));
}
+bool evaluate(PropertyValue<bool> value, float zoom) {
+ return value.evaluate(PropertyEvaluator<bool>(PropertyEvaluationParameters(zoom), false));
+}
TEST(Function, Constant) {
- EXPECT_EQ(2.0f, evaluate(2, 0));
- EXPECT_EQ(3.8f, evaluate(3.8, 0));
- EXPECT_EQ(22.0f, evaluate(22, 0));
- EXPECT_EQ(2.0f, evaluate(2, 4));
- EXPECT_EQ(3.8f, evaluate(3.8, 4));
- EXPECT_EQ(22.0f, evaluate(22, 4));
- EXPECT_EQ(2.0f, evaluate(2, 22));
- EXPECT_EQ(3.8f, evaluate(3.8, 22));
- EXPECT_EQ(22.0f, evaluate(22, 22));
+ EXPECT_EQ(2.0f, evaluate(PropertyValue<float>(2.0), 0));
+ EXPECT_EQ(3.8f, evaluate(PropertyValue<float>(3.8), 0));
+ EXPECT_EQ(22.0f, evaluate(PropertyValue<float>(22.0), 0));
+ EXPECT_EQ(2.0f, evaluate(PropertyValue<float>(2.0), 4));
+ EXPECT_EQ(3.8f, evaluate(PropertyValue<float>(3.8), 4));
+ EXPECT_EQ(22.0f, evaluate(PropertyValue<float>(22.0), 4));
+ EXPECT_EQ(2.0f, evaluate(PropertyValue<float>(2.0), 22));
+ EXPECT_EQ(3.8f, evaluate(PropertyValue<float>(3.8), 22));
+ EXPECT_EQ(22.0f, evaluate(PropertyValue<float>(22.0), 22));
}
TEST(Function, Stops) {
@@ -60,10 +63,17 @@ TEST(Function, Stops) {
EXPECT_EQ(10, evaluate(slope_4, 8));
// discrete values
- Function<std::string> discrete_0({{ 3, "string0"}, {6, "string1"}, {9, "string2"}}, 1);
+ 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));
+
+ Function<bool> discreteBool({{1, false}, {3, true}}, 1);
+ EXPECT_EQ(false, evaluate(discreteBool, 0));
+ EXPECT_EQ(false, evaluate(discreteBool, 1));
+ EXPECT_EQ(false, evaluate(discreteBool, 2));
+ EXPECT_EQ(true, evaluate(discreteBool, 3));
+ EXPECT_EQ(true, evaluate(discreteBool, 4));
}