summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-06-16 10:16:11 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-19 09:15:08 -0700
commit1de8aeed31226f167c528bfdcfae97d12c5d67ca (patch)
tree9104590c9c13d32878685ca4433780e0da96f259 /test
parent8699bcdbf07550107dee77e2fddf3aa982b9fbfd (diff)
downloadqtlocation-mapboxgl-1de8aeed31226f167c528bfdcfae97d12c5d67ca.tar.gz
[core] Fix composite function approximation for non-integer stops
Diffstat (limited to 'test')
-rw-r--r--test/style/function/composite_function.test.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/style/function/composite_function.test.cpp b/test/style/function/composite_function.test.cpp
index e0804d4b27..09b79a8b8f 100644
--- a/test/style/function/composite_function.test.cpp
+++ b/test/style/function/composite_function.test.cpp
@@ -44,3 +44,28 @@ TEST(CompositeFunction, ZoomInterpolation) {
}), 0.0f)
.evaluate(0.0f, oneInteger, -1.0f)) << "Should interpolate TO the first stop";
}
+
+TEST(CompositeFunction, Issue8460) {
+ CompositeFunction<float> fn1("property", CompositeExponentialStops<float>({
+ {15.0f, {{uint64_t(1), 0.0f}}},
+ {15.2f, {{uint64_t(1), 600.0f}}},
+ }), 0.0f);
+
+ EXPECT_NEAR( 0.0f, fn1.evaluate(15.0f, oneInteger, -1.0f), 0.00);
+ EXPECT_NEAR(300.0f, fn1.evaluate(15.1f, oneInteger, -1.0f), 0.01);
+ EXPECT_NEAR(600.0f, fn1.evaluate(15.2f, oneInteger, -1.0f), 0.00);
+ EXPECT_NEAR(600.0f, fn1.evaluate(16.0f, oneInteger, -1.0f), 0.00);
+
+ CompositeFunction<float> fn2("property", CompositeExponentialStops<float>({
+ {15.0f, {{uint64_t(1), 0.0f}}},
+ {15.2f, {{uint64_t(1), 300.0f}}},
+ {18.0f, {{uint64_t(1), 600.0f}}},
+ }), 0.0f);
+
+ EXPECT_NEAR( 0.0f, fn2.evaluate(15.0f, oneInteger, -1.0f), 0.00);
+ EXPECT_NEAR(150.0f, fn2.evaluate(15.1f, oneInteger, -1.0f), 0.01);
+ EXPECT_NEAR(300.0f, fn2.evaluate(15.2f, oneInteger, -1.0f), 0.00);
+ EXPECT_NEAR(385.71f, fn2.evaluate(16.0f, oneInteger, -1.0f), 0.01);
+ EXPECT_NEAR(600.0f, fn2.evaluate(18.0f, oneInteger, -1.0f), 0.00);
+ EXPECT_NEAR(600.0f, fn2.evaluate(19.0f, oneInteger, -1.0f), 0.00);
+}