port tests for mergeLines
js: 867b7f4be01126663df609756049515a41e700d1
This commit is contained in:
73
test/merge_lines.cpp
Normal file
73
test/merge_lines.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <mbgl/util/merge_lines.hpp>
|
||||
|
||||
|
||||
TEST(mergeLines, mergeLines) {
|
||||
|
||||
std::u32string a = U"a";
|
||||
std::u32string b = U"b";
|
||||
|
||||
// merges lines with the same text
|
||||
std::vector<mbgl::SymbolFeature> input1 = {
|
||||
{ {{{0, 0}, {1, 0}, {2, 0}}}, a, "" },
|
||||
{ {{{4, 0}, {5, 0}, {6, 0}}}, b, "" },
|
||||
{ {{{8, 0}, {9, 0}}}, a, "" },
|
||||
{ {{{2, 0}, {3, 0}, {4, 0}}}, a, "" },
|
||||
{ {{{6, 0}, {7, 0}, {8, 0}}}, a, "" },
|
||||
{ {{{5, 0}, {6, 0}}}, a, "" }
|
||||
};
|
||||
|
||||
std::vector<mbgl::SymbolFeature> expected1 = {
|
||||
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, a, "" },
|
||||
{ {{{4, 0}, {5, 0}, {6, 0}}}, b, "" },
|
||||
{ {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, a, "" },
|
||||
{ {{}}, a, "" },
|
||||
{ {{}}, a, "" },
|
||||
{ {{}}, a, "" }
|
||||
};
|
||||
|
||||
mbgl::util::mergeLines(input1);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
EXPECT_EQ(input1[i].geometry, expected1[i].geometry);
|
||||
}
|
||||
|
||||
// mergeLines handles merge from both ends
|
||||
std::vector<mbgl::SymbolFeature> input2 = {
|
||||
{ {{{0, 0}, {1, 0}, {2, 0}}}, a, "" },
|
||||
{ {{{4, 0}, {5, 0}, {6, 0}}}, a, "" },
|
||||
{ {{{2, 0}, {3, 0}, {4, 0}}}, a, "" }
|
||||
};
|
||||
|
||||
std::vector<mbgl::SymbolFeature> expected2 = {
|
||||
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, a, "" },
|
||||
{ {{}}, a, "" },
|
||||
{ {{}}, a, "" }
|
||||
};
|
||||
|
||||
mbgl::util::mergeLines(input2);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
EXPECT_EQ(input2[i].geometry, expected2[i].geometry);
|
||||
}
|
||||
|
||||
// mergeLines handles circular lines
|
||||
std::vector<mbgl::SymbolFeature> input3 = {
|
||||
{ {{{0, 0}, {1, 0}, {2, 0}}}, a, "" },
|
||||
{ {{{2, 0}, {3, 0}, {4, 0}}}, a, "" },
|
||||
{ {{{4, 0}, {0, 0}}}, a, "" }
|
||||
};
|
||||
|
||||
std::vector<mbgl::SymbolFeature> expected3 = {
|
||||
{ {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, a, "" },
|
||||
{ {{}}, a, "" },
|
||||
{ {{}}, a, "" }
|
||||
};
|
||||
|
||||
mbgl::util::mergeLines(input3);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
EXPECT_EQ(input3[i].geometry, expected3[i].geometry);
|
||||
}
|
||||
}
|
||||
@@ -167,6 +167,25 @@
|
||||
}]
|
||||
]
|
||||
},
|
||||
{ 'target_name': 'merge_lines',
|
||||
'product_name': 'test_merge_lines',
|
||||
'type': 'executable',
|
||||
'sources': [
|
||||
'./main.cpp',
|
||||
'./merge_lines.cpp',
|
||||
],
|
||||
'dependencies': [
|
||||
'../deps/gtest/gtest.gyp:gtest',
|
||||
'../mapboxgl.gyp:mbgl-standalone',
|
||||
],
|
||||
'include_dirs': [ '../src' ],
|
||||
'conditions': [
|
||||
['OS == "mac"', { 'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(ldflags)' ] }
|
||||
}, {
|
||||
'libraries': [ '<@(ldflags)' ],
|
||||
}]
|
||||
]
|
||||
},
|
||||
{ 'target_name': 'headless',
|
||||
'product_name': 'test_headless',
|
||||
'type': 'executable',
|
||||
@@ -236,6 +255,7 @@
|
||||
'variant',
|
||||
'tile',
|
||||
'functions',
|
||||
'merge_lines',
|
||||
'headless',
|
||||
'style_parser',
|
||||
'comparisons',
|
||||
|
||||
Reference in New Issue
Block a user