summaryrefslogtreecommitdiff
path: root/test/util
diff options
context:
space:
mode:
authorLauren Budorick <lauren@mapbox.com>2017-04-27 15:56:55 -0700
committerGitHub <noreply@github.com>2017-04-27 15:56:55 -0700
commitf6e79d70735361438655f279c8699a786d25458c (patch)
treecc01ae7aba097bae4aa84beb12ac6b8f34f4d51a /test/util
parent839ad87f37a4880804fb4c79157d998ac59954b5 (diff)
downloadqtlocation-mapboxgl-f6e79d70735361438655f279c8699a786d25458c.tar.gz
[core] Render fill-extrusion layers (#8431)
Diffstat (limited to 'test/util')
-rw-r--r--test/util/position.test.cpp49
-rw-r--r--test/util/tile_cover.test.cpp5
2 files changed, 52 insertions, 2 deletions
diff --git a/test/util/position.test.cpp b/test/util/position.test.cpp
new file mode 100644
index 0000000000..938a08dded
--- /dev/null
+++ b/test/util/position.test.cpp
@@ -0,0 +1,49 @@
+#include <mbgl/test/util.hpp>
+
+#include <mbgl/style/types.hpp>
+#include <mbgl/style/position.hpp>
+#include <mbgl/util/constants.hpp>
+
+using namespace mbgl;
+using namespace style;
+
+void expectArrayEQ(std::array<float, 3> got, std::array<float, 3> expected) {
+ for (int i = 0; i < 3; i++) {
+ EXPECT_NEAR(got[i], expected[i], 0.00001);
+ }
+};
+
+void expectArrayNE(std::array<float, 3> got, std::array<float, 3> expected) {
+ short eq = 0;
+ for (int i = 0; i < 3; i++) {
+ if (got[i] == expected[i]) {
+ eq++;
+ }
+ }
+ EXPECT_NE(eq, 3);
+};
+
+Position createPosition(std::array<float, 3> pos) {
+ return Position(pos);
+}
+
+TEST(Position, Calculations) {
+ std::array<float, 3> spherical{{ 2, 10, 270 }};
+
+ Position position(spherical);
+
+ expectArrayNE(position.getCartesian(), spherical);
+ expectArrayEQ(position.getSpherical(), spherical);
+
+ expectArrayEQ(position.getCartesian(), {{ 0.34729638695716858, -1.9696154594421387, 2.384976127700611e-08 }});
+
+ expectArrayNE(createPosition({{ 2, 30, 10 }}).getSpherical(), createPosition({{ 2, 30, 370 }}).getSpherical());
+ expectArrayEQ(createPosition({{ 2, 30, 10 }}).getCartesian(), createPosition({{ 2, 30, 370 }}).getCartesian());
+
+ std::array<float, 3> newSpherical = {{ 1, 80, 270 }};
+ position.set(newSpherical);
+
+ expectArrayNE(position.getSpherical(), spherical);
+ expectArrayNE(position.getCartesian(), {{ 0.34729638695716858, -1.9696154594421387, 2.384976127700611e-08 }});
+ expectArrayEQ(position.getCartesian(), {{ 0.98480772972106934, -0.17364829778671265, 1.1924880638503055e-08 }});
+}
diff --git a/test/util/tile_cover.test.cpp b/test/util/tile_cover.test.cpp
index 809b7df9f2..c746e6dab5 100644
--- a/test/util/tile_cover.test.cpp
+++ b/test/util/tile_cover.test.cpp
@@ -31,12 +31,13 @@ TEST(TileCover, Pitch) {
Transform transform;
transform.resize({ 512, 512 });
// slightly offset center so that tile order is better defined
- transform.setLatLng({ 0.01, -0.01 });
+ transform.setLatLng({ 0.1, -0.1 });
transform.setZoom(2);
+ transform.setAngle(5.0);
transform.setPitch(40.0 * M_PI / 180.0);
EXPECT_EQ((std::vector<UnwrappedTileID>{
- { 2, 1, 1 }, { 2, 1, 2 }, { 2, 2, 1 }, { 2, 2, 2 },
+ { 2, 1, 2 }, { 2, 1, 1 }, { 2, 2, 2 }, { 2, 2, 1 }, { 2, 3, 2 }
}),
util::tileCover(transform.getState(), 2));
}