Files
MapLibreParticleLab/test/style/conversion/source_options.test.cpp
Bart Louwers 550f64be22 core: rename mbgl namespace to mln (#4487)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-14 23:25:20 +02:00

73 lines
1.9 KiB
C++

#include <mbgl/test/util.hpp>
#include <mbgl/style/conversion/json.hpp>
#include <mbgl/style/conversion/source_options.hpp>
#include <mbgl/util/tileset.hpp>
#include <mbgl/util/logging.hpp>
using namespace mln;
using namespace mln::style;
using namespace mln::style::conversion;
TEST(SourceOptions, Basic) {
Error error;
auto converted = convertJSON<SourceOptions>("{}", error);
ASSERT_FALSE(converted);
}
TEST(SourceOptions, ErrorHandling) {
Error error;
auto converted = convertJSON<SourceOptions>(
R"JSON({
"encoding": "this isn't a valid encoding"
})JSON",
error);
ASSERT_FALSE(converted);
ASSERT_EQ(0, error.message.find("invalid encoding"));
}
TEST(SourceOptions, TerrariumEncodingParsed) {
Error error;
auto converted = convertJSON<SourceOptions>(
R"JSON({
"encoding": "terrarium"
})JSON",
error);
ASSERT_EQ(converted.value().rasterEncoding, Tileset::RasterEncoding::Terrarium);
ASSERT_FALSE(converted.value().vectorEncoding);
}
TEST(SourceOptions, MapboxEncodingParsed) {
Error error;
auto converted = convertJSON<SourceOptions>(
R"JSON({
"encoding": "mapbox"
})JSON",
error);
ASSERT_EQ(converted.value().rasterEncoding, Tileset::RasterEncoding::Mapbox);
ASSERT_FALSE(converted.value().vectorEncoding);
}
TEST(SourceOptions, MVTEncodingParsed) {
Error error;
auto converted = convertJSON<SourceOptions>(
R"JSON({
"encoding": "mvt"
})JSON",
error);
ASSERT_EQ(converted.value().vectorEncoding, Tileset::VectorEncoding::Mapbox);
ASSERT_FALSE(converted.value().rasterEncoding);
}
TEST(SourceOptions, MLTEncodingParsed) {
Error error;
auto converted = convertJSON<SourceOptions>(
R"JSON({
"encoding": "mlt"
})JSON",
error);
ASSERT_EQ(converted.value().vectorEncoding, Tileset::VectorEncoding::MLT);
ASSERT_FALSE(converted.value().rasterEncoding);
}