diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-02 11:09:16 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-02 11:31:13 -0800 |
commit | b97dcbc12592fc93d2c8137f3d56a523e994a136 (patch) | |
tree | 12e5f91d686f2853c5322a525663193a546ab130 /test/util/merge_lines.cpp | |
parent | ce8c6e26d58f91bba46576080caf48e4765c176f (diff) | |
download | qtlocation-mapboxgl-b97dcbc12592fc93d2c8137f3d56a523e994a136.tar.gz |
[tests] Reorganize tests to match src structure
Diffstat (limited to 'test/util/merge_lines.cpp')
-rw-r--r-- | test/util/merge_lines.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/test/util/merge_lines.cpp b/test/util/merge_lines.cpp new file mode 100644 index 0000000000..90625e9e0a --- /dev/null +++ b/test/util/merge_lines.cpp @@ -0,0 +1,75 @@ +#include "../fixtures/util.hpp" + +#include <mbgl/util/merge_lines.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, "" }, + { {{{4, 0}, {5, 0}, {6, 0}}}, bbb, "" }, + { {{{8, 0}, {9, 0}}}, aaa, "" }, + { {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "" }, + { {{{6, 0}, {7, 0}, {8, 0}}}, aaa, "" }, + { {{{5, 0}, {6, 0}}}, aaa, "" } + }; + + const std::vector<mbgl::SymbolFeature> expected1 = { + { {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, aaa, "" }, + { {{{4, 0}, {5, 0}, {6, 0}}}, bbb, "" }, + { {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, aaa, "" }, + { {{}}, aaa, "" }, + { {{}}, aaa, "" }, + { {{}}, aaa, "" } + }; + + mbgl::util::mergeLines(input1); + + for (int i = 0; i < 6; i++) { + EXPECT_EQ(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, "" }, + { {{{4, 0}, {5, 0}, {6, 0}}}, aaa, "" }, + { {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "" } + }; + + const std::vector<mbgl::SymbolFeature> expected2 = { + { {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, aaa, "" }, + { {{}}, aaa, "" }, + { {{}}, aaa, "" } + }; + + mbgl::util::mergeLines(input2); + + for (int i = 0; i < 3; i++) { + EXPECT_EQ(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, "" }, + { {{{2, 0}, {3, 0}, {4, 0}}}, aaa, "" }, + { {{{4, 0}, {0, 0}}}, aaa, "" } + }; + + const std::vector<mbgl::SymbolFeature> expected3 = { + { {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, aaa, "" }, + { {{}}, aaa, "" }, + { {{}}, aaa, "" } + }; + + mbgl::util::mergeLines(input3); + + for (int i = 0; i < 3; i++) { + EXPECT_EQ(input3[i].geometry, expected3[i].geometry); + } +} |