diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test-files.json | 1 | ||||
-rw-r--r-- | test/text/calculate_tile_distances.test.cpp | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/test/test-files.json b/test/test-files.json index 012b381f87..b997503877 100644 --- a/test/test-files.json +++ b/test/test-files.json @@ -66,6 +66,7 @@ "test/style/style_layer.test.cpp", "test/style/style_parser.test.cpp", "test/text/bidi.test.cpp", + "test/text/calculate_tile_distances.test.cpp", "test/text/cross_tile_symbol_index.test.cpp", "test/text/formatted.test.cpp", "test/text/get_anchors.test.cpp", diff --git a/test/text/calculate_tile_distances.test.cpp b/test/text/calculate_tile_distances.test.cpp new file mode 100644 index 0000000000..990de3d4ec --- /dev/null +++ b/test/text/calculate_tile_distances.test.cpp @@ -0,0 +1,27 @@ +#include <mbgl/test/util.hpp> + +#include <mbgl/geometry/anchor.hpp> +#include <mbgl/layout/symbol_layout.hpp> +#include <mbgl/tile/geometry_tile_data.hpp> + +using namespace mbgl; + +TEST(calculateTileDistances, Point) { + const GeometryCoordinates line = {Point<int16_t>{1, 1}}; + const auto distances = SymbolLayout::calculateTileDistances(line, Anchor(1.0f, 1.0f, .0f, 0u)); + EXPECT_EQ(distances.size(), 1u); + EXPECT_EQ(distances[0], .0f); +} + +TEST(calculateTileDistances, Line) { + const GeometryCoordinates line = { + Point<int16_t>{1, 1}, Point<int16_t>{1, 2}, Point<int16_t>{1, 3}, Point<int16_t>{1, 4}}; + const auto distances = SymbolLayout::calculateTileDistances(line, Anchor(1.0f, 3.0f, .0f, 2u)); + EXPECT_EQ(distances, std::vector<float>({2.0f, 1.0f, 0.0f, 1.0f})); +} + +TEST(calculateTileDistances, EmptySegment) { + const GeometryCoordinates line = {}; + const auto distances = SymbolLayout::calculateTileDistances(line, Anchor(1.0f, 1.0f, .0f)); + EXPECT_EQ(distances.size(), 0u); +} |