summaryrefslogtreecommitdiff
path: root/test/util/tile_cover.test.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-09-28 11:45:33 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-09-28 16:34:22 +0200
commit3f3fc7b7723698e44427e2a14a2f4906832800bf (patch)
tree5acadfa4d77817c41f612c89c93925a149cbcfc0 /test/util/tile_cover.test.cpp
parenta8b007daa0e85ea4b1a4898fd591d55d0117cc85 (diff)
downloadqtlocation-mapboxgl-3f3fc7b7723698e44427e2a14a2f4906832800bf.tar.gz
[test] add .test.cpp suffix to test case files
Diffstat (limited to 'test/util/tile_cover.test.cpp')
-rw-r--r--test/util/tile_cover.test.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/util/tile_cover.test.cpp b/test/util/tile_cover.test.cpp
new file mode 100644
index 0000000000..cc183509d9
--- /dev/null
+++ b/test/util/tile_cover.test.cpp
@@ -0,0 +1,83 @@
+#include <mbgl/util/tile_cover.hpp>
+#include <mbgl/util/geo.hpp>
+#include <mbgl/map/transform.hpp>
+
+#include <gtest/gtest.h>
+
+using namespace mbgl;
+
+TEST(TileCover, Empty) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{}), util::tileCover(LatLngBounds::empty(), 0));
+}
+
+TEST(TileCover, Arctic) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{}),
+ util::tileCover(LatLngBounds::hull({ 86, -180 }, { 90, 180 }), 0));
+}
+
+TEST(TileCover, Antarctic) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{}),
+ util::tileCover(LatLngBounds::hull({ -86, -180 }, { -90, 180 }), 0));
+}
+
+TEST(TileCover, WorldZ0) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{
+ { 0, 0, 0 },
+ }),
+ util::tileCover(LatLngBounds::world(), 0));
+}
+
+TEST(TileCover, Pitch) {
+ Transform transform;
+ transform.resize({ { 512, 512 } });
+ transform.setZoom(2);
+ 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 },
+ }),
+ util::tileCover(transform.getState(), 2));
+}
+
+TEST(TileCover, WorldZ1) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{
+ { 1, 0, 0 }, { 1, 0, 1 }, { 1, 1, 0 }, { 1, 1, 1 },
+ }),
+ util::tileCover(LatLngBounds::world(), 1));
+}
+
+TEST(TileCover, SingletonZ0) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{}),
+ util::tileCover(LatLngBounds::singleton({ 0, 0 }), 0));
+}
+
+TEST(TileCover, SingletonZ1) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{}),
+ util::tileCover(LatLngBounds::singleton({ 0, 0 }), 1));
+}
+
+static const LatLngBounds sanFrancisco =
+ LatLngBounds::hull({ 37.6609, -122.5744 }, { 37.8271, -122.3204 });
+
+TEST(TileCover, SanFranciscoZ0) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{
+ { 0, 0, 0 },
+ }),
+ util::tileCover(sanFrancisco, 0));
+}
+
+TEST(TileCover, SanFranciscoZ10) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{
+ { 10, 163, 395 }, { 10, 163, 396 }, { 10, 164, 395 }, { 10, 164, 396 },
+
+ }),
+ util::tileCover(sanFrancisco, 10));
+}
+
+static const LatLngBounds sanFranciscoWrapped =
+ LatLngBounds::hull({ 37.6609, 238.5744 }, { 37.8271, 238.3204 });
+
+TEST(TileCover, SanFranciscoZ0Wrapped) {
+ EXPECT_EQ((std::vector<UnwrappedTileID>{ { 0, 1, 0 } }),
+ util::tileCover(sanFranciscoWrapped, 0));
+}