summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Morris <michael.patrick.morris@gmail.com>2014-07-17 17:58:13 -0400
committerMike Morris <michael.patrick.morris@gmail.com>2014-07-17 17:58:13 -0400
commit4b9e299d06fa2cb4232e4edbec74da48701fc740 (patch)
tree08deb81b7a141d96006bc007059d4a1109f52ff9 /test
parent50d9e6d84585b9c187099b24d86d258ae92812ab (diff)
parentafe069df2b4a4b3ef72328fc960389ea9cfb121b (diff)
downloadqtlocation-mapboxgl-4b9e299d06fa2cb4232e4edbec74da48701fc740.tar.gz
Merge branch 'master' into fuzz-pipe
Conflicts: src/style/style_parser.cpp
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/styles/road-width.style.json1
-rw-r--r--test/functions.cpp44
2 files changed, 12 insertions, 33 deletions
diff --git a/test/fixtures/styles/road-width.style.json b/test/fixtures/styles/road-width.style.json
index 5738546b33..76d7b5258c 100644
--- a/test/fixtures/styles/road-width.style.json
+++ b/test/fixtures/styles/road-width.style.json
@@ -23,7 +23,6 @@
"type": "line",
"style": {
"line-width": {
- "fn": "stops",
"stops": [[13, 0], [13.999, 0], [14, 4], [14.1, 10], [14.2, 20]]
}
}
diff --git a/test/functions.cpp b/test/functions.cpp
index a2ad93c4e1..56b2a31706 100644
--- a/test/functions.cpp
+++ b/test/functions.cpp
@@ -19,11 +19,11 @@ TEST(Function, Constant) {
TEST(Function, Stops) {
// Explicit constant slope in fringe regions.
- mbgl::StopsFunction<float> slope_1({ { 0, 1.5 }, { 6, 1.5 }, { 8, 3 }, { 22, 3 } });
+ mbgl::StopsFunction<float> slope_1({ { 0, 1.5 }, { 6, 1.5 }, { 8, 3 }, { 22, 3 } }, 1.75);
EXPECT_EQ(1.5, slope_1.evaluate(0));
EXPECT_EQ(1.5, slope_1.evaluate(4));
EXPECT_EQ(1.5, slope_1.evaluate(6));
- ASSERT_FLOAT_EQ(2.12132, slope_1.evaluate(7));
+ ASSERT_FLOAT_EQ(2.0454545454545454, slope_1.evaluate(7));
EXPECT_EQ(3.0, slope_1.evaluate(8));
EXPECT_EQ(3.0, slope_1.evaluate(9));
EXPECT_EQ(3.0, slope_1.evaluate(15));
@@ -31,48 +31,28 @@ TEST(Function, Stops) {
// Test constant values in fringe regions.
- mbgl::StopsFunction<float> slope_2({ { 6, 1.5 }, { 8, 3 } });
+ mbgl::StopsFunction<float> slope_2({ { 6, 1.5 }, { 8, 3 } }, 1.75);
EXPECT_EQ(1.5, slope_2.evaluate(0));
EXPECT_EQ(1.5, slope_2.evaluate(4));
EXPECT_EQ(1.5, slope_2.evaluate(6));
- ASSERT_FLOAT_EQ(2.12132, slope_2.evaluate(7));
+ ASSERT_FLOAT_EQ(2.0454545454545454, slope_2.evaluate(7));
EXPECT_EQ(3.0, slope_2.evaluate(8));
EXPECT_EQ(3.0, slope_2.evaluate(9));
EXPECT_EQ(3.0, slope_2.evaluate(15));
EXPECT_EQ(3.0, slope_2.evaluate(22));
// Test no values.
- mbgl::StopsFunction<float> slope_3({});
+ mbgl::StopsFunction<float> slope_3({}, 1.75);
EXPECT_EQ(1, slope_3.evaluate(2));
EXPECT_EQ(1, slope_3.evaluate(6));
EXPECT_EQ(1, slope_3.evaluate(12));
-}
-
-
-TEST(Function, Linear) {
- mbgl::LinearFunction<float> slope_1(/* val */ 7.5, /* z_base */ 4, /* slope */ 2, /* min */ 7.5, /* max */ 20);
- ASSERT_FLOAT_EQ(7.5, slope_1.evaluate(3));
- ASSERT_FLOAT_EQ(7.5, slope_1.evaluate(4));
- ASSERT_FLOAT_EQ(8.5, slope_1.evaluate(4.5));
- ASSERT_FLOAT_EQ(9.5, slope_1.evaluate(5));
- ASSERT_FLOAT_EQ(11.5, slope_1.evaluate(6));
- ASSERT_FLOAT_EQ(19.5, slope_1.evaluate(10));
- ASSERT_FLOAT_EQ(20, slope_1.evaluate(11));
- ASSERT_FLOAT_EQ(20, slope_1.evaluate(20));
-}
-TEST(Function, Exponential) {
- mbgl::ExponentialFunction<float> slope_1(/* val */ 7.5, /* z_base */ 4, /* exp_base */ 1.75, /* slope */ 2, /* min */ 7.5, /* max */ 20);
- ASSERT_FLOAT_EQ(8.6428576, slope_1.evaluate(3)); // 7.5 + 1.75^(3 - 4) * 2
- ASSERT_FLOAT_EQ(9.5, slope_1.evaluate(4)); // 7.5 + 1.75^(4 - 4) * 2
- ASSERT_FLOAT_EQ(10.145751, slope_1.evaluate(4.5)); // 7.5 + 1.75^(4.5 - 4) * 2
- ASSERT_FLOAT_EQ(11, slope_1.evaluate(5)); // 7.5 + 1.75^(5 - 4) * 2
- ASSERT_FLOAT_EQ(13.625, slope_1.evaluate(6)); // 7.5 + 1.75^(6 - 4) * 2
- ASSERT_FLOAT_EQ(18.21875, slope_1.evaluate(7)); // 7.5 + 1.75^(7 - 4) * 2
- ASSERT_FLOAT_EQ(20, slope_1.evaluate(8)); // 7.5 + 1.75^(8 - 4) * 2 ==> clamped to 20
- ASSERT_FLOAT_EQ(20, slope_1.evaluate(20)); // 7.5 + 1.75^(20 - 4) * 2 ==> clamped to 20
+ // Explicit constant slope in fringe regions.
+ mbgl::StopsFunction<float> slope_4({ { 0, 2 }, { 8, 10 } }, 1);
+ EXPECT_EQ(2, slope_4.evaluate(0));
+ EXPECT_EQ(3, slope_4.evaluate(1));
+ EXPECT_EQ(4, slope_4.evaluate(2));
+ EXPECT_EQ(4.75, slope_4.evaluate(2.75));
+ EXPECT_EQ(10, slope_4.evaluate(8));
}
-
-
-