summaryrefslogtreecommitdiff
path: root/test/algorithm/covered_by_children.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/algorithm/covered_by_children.test.cpp
parenta8b007daa0e85ea4b1a4898fd591d55d0117cc85 (diff)
downloadqtlocation-mapboxgl-3f3fc7b7723698e44427e2a14a2f4906832800bf.tar.gz
[test] add .test.cpp suffix to test case files
Diffstat (limited to 'test/algorithm/covered_by_children.test.cpp')
-rw-r--r--test/algorithm/covered_by_children.test.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/algorithm/covered_by_children.test.cpp b/test/algorithm/covered_by_children.test.cpp
new file mode 100644
index 0000000000..b2a219bf29
--- /dev/null
+++ b/test/algorithm/covered_by_children.test.cpp
@@ -0,0 +1,61 @@
+#include <mbgl/test/util.hpp>
+
+#include <mbgl/algorithm/covered_by_children.hpp>
+
+#include <map>
+
+using namespace mbgl;
+
+using List = std::map<UnwrappedTileID, bool>;
+
+TEST(CoveredByChildren, NotCovered) {
+ const List list1;
+ EXPECT_FALSE(algorithm::coveredByChildren(UnwrappedTileID{ 0, 0, 0 }, list1));
+
+ const List list2{
+ { UnwrappedTileID{ 0, 0, 0 }, true },
+ // 3 out of 4 child tiles
+ { UnwrappedTileID{ 1, 0, 0 }, true },
+ { UnwrappedTileID{ 1, 0, 1 }, true },
+ // missing 1/1/0
+ { UnwrappedTileID{ 1, 1, 1 }, true },
+ };
+ EXPECT_FALSE(algorithm::coveredByChildren(UnwrappedTileID{ 0, 0, 0 }, list2));
+
+ const List list3{
+ { UnwrappedTileID{ 0, 0, 0 }, true },
+ // all four child tiles, with with a different wrap index
+ { UnwrappedTileID{ 1, { 1, 0, 0 } }, true },
+ { UnwrappedTileID{ 1, { 1, 0, 1 } }, true },
+ { UnwrappedTileID{ 1, { 1, 1, 0 } }, true },
+ { UnwrappedTileID{ 1, { 1, 1, 1 } }, true },
+ };
+ EXPECT_FALSE(algorithm::coveredByChildren(UnwrappedTileID{ 0, 0, 0 }, list3));
+}
+
+TEST(CoveredByChildren, Covered) {
+ const List list1{
+ { UnwrappedTileID{ 0, 0, 0 }, true },
+ // all four child tiles
+ { UnwrappedTileID{ 1, 0, 0 }, true },
+ { UnwrappedTileID{ 1, 0, 1 }, true },
+ { UnwrappedTileID{ 1, 1, 0 }, true },
+ { UnwrappedTileID{ 1, 1, 1 }, true },
+ };
+ EXPECT_TRUE(algorithm::coveredByChildren(UnwrappedTileID{ 0, 0, 0 }, list1));
+
+ const List list2{
+ { UnwrappedTileID{ 0, 0, 0 }, true },
+ // missing 1/0/0
+ { UnwrappedTileID{ 1, 0, 1 }, true },
+ { UnwrappedTileID{ 1, 1, 0 }, true },
+ { UnwrappedTileID{ 1, 1, 1 }, true },
+ { UnwrappedTileID{ 2, 0, 0 }, true },
+ { UnwrappedTileID{ 2, 0, 1 }, true },
+ { UnwrappedTileID{ 2, 1, 0 }, true },
+ { UnwrappedTileID{ 2, 1, 1 }, true },
+ };
+ EXPECT_TRUE(algorithm::coveredByChildren(UnwrappedTileID{ 0, 0, 0 }, list2));
+ EXPECT_TRUE(algorithm::coveredByChildren(UnwrappedTileID{ 1, 0, 0 }, list2));
+ EXPECT_FALSE(algorithm::coveredByChildren(UnwrappedTileID{ 2, 0, 0 }, list2));
+}