diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-09-28 11:45:33 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-09-28 16:34:22 +0200 |
commit | 3f3fc7b7723698e44427e2a14a2f4906832800bf (patch) | |
tree | 5acadfa4d77817c41f612c89c93925a149cbcfc0 /test/util/merge_lines.test.cpp | |
parent | a8b007daa0e85ea4b1a4898fd591d55d0117cc85 (diff) | |
download | qtlocation-mapboxgl-3f3fc7b7723698e44427e2a14a2f4906832800bf.tar.gz |
[test] add .test.cpp suffix to test case files
Diffstat (limited to 'test/util/merge_lines.test.cpp')
-rw-r--r-- | test/util/merge_lines.test.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/test/util/merge_lines.test.cpp b/test/util/merge_lines.test.cpp new file mode 100644 index 0000000000..db81d8b209 --- /dev/null +++ b/test/util/merge_lines.test.cpp @@ -0,0 +1,76 @@ +#include <mbgl/test/util.hpp> + +#include <mbgl/layout/merge_lines.hpp> +#include <mbgl/layout/symbol_feature.hpp> + +const std::u32string aaa = U"a"; +const std::u32string bbb = U"b"; + +TEST(MergeLines, SameText) { + // merges lines with the same text + std::vector<mbgl::SymbolFeature> input1 = { + { {{{0, 0}, {1, 0}, {2, 0}}}, aaa, {}, 0 }, + { {{{4, 0}, {5, 0}, {6, 0}}}, bbb, {}, 0 }, + { {{{8, 0}, {9, 0}}}, aaa, {}, 0 }, + { {{{2, 0}, {3, 0}, {4, 0}}}, aaa, {}, 0 }, + { {{{6, 0}, {7, 0}, {8, 0}}}, aaa, {}, 0 }, + { {{{5, 0}, {6, 0}}}, aaa, {}, 0 } + }; + + const std::vector<mbgl::SymbolFeature> expected1 = { + { {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, aaa, {}, 0 }, + { {{{4, 0}, {5, 0}, {6, 0}}}, bbb, {}, 0 }, + { {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, aaa, {}, 0 }, + { {{}}, aaa, {}, 0 }, + { {{}}, aaa, {}, 0 }, + { {{}}, aaa, {}, 0 } + }; + + mbgl::util::mergeLines(input1); + + for (int i = 0; i < 6; i++) { + EXPECT_TRUE(input1[i].geometry == expected1[i].geometry); + } +} + +TEST(MergeLines, BothEnds) { + // mergeLines handles merge from both ends + std::vector<mbgl::SymbolFeature> input2 = { + { {{{0, 0}, {1, 0}, {2, 0}}}, aaa, {}, 0 }, + { {{{4, 0}, {5, 0}, {6, 0}}}, aaa, {}, 0 }, + { {{{2, 0}, {3, 0}, {4, 0}}}, aaa, {}, 0 } + }; + + const std::vector<mbgl::SymbolFeature> expected2 = { + { {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, aaa, {}, 0 }, + { {{}}, aaa, {}, 0 }, + { {{}}, aaa, {}, 0 } + }; + + mbgl::util::mergeLines(input2); + + for (int i = 0; i < 3; i++) { + EXPECT_TRUE(input2[i].geometry == expected2[i].geometry); + } +} + +TEST(MergeLines, CircularLines) { + // mergeLines handles circular lines + std::vector<mbgl::SymbolFeature> input3 = { + { {{{0, 0}, {1, 0}, {2, 0}}}, aaa, {}, 0 }, + { {{{2, 0}, {3, 0}, {4, 0}}}, aaa, {}, 0 }, + { {{{4, 0}, {0, 0}}}, aaa, {}, 0 } + }; + + const std::vector<mbgl::SymbolFeature> expected3 = { + { {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, aaa, {}, 0 }, + { {{}}, aaa, {}, 0 }, + { {{}}, aaa, {}, 0 } + }; + + mbgl::util::mergeLines(input3); + + for (int i = 0; i < 3; i++) { + EXPECT_TRUE(input3[i].geometry == expected3[i].geometry); + } +} |