summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2016-11-28 17:35:10 +0200
committerJesse Bounds <jesse@rebounds.net>2016-12-02 11:25:30 -0800
commit2c4e7ae70f68eecf56707f0ebd9810340f41e6a3 (patch)
tree5a62004e9238cb329d7ec7bd050c2180960a44c2 /test
parent8317a11a10400c28e36017a9441e18d49f99acd0 (diff)
downloadqtlocation-mapboxgl-2c4e7ae70f68eecf56707f0ebd9810340f41e6a3.tar.gz
[core] guard against duplicate source id’s
Diffstat (limited to 'test')
-rw-r--r--test/style/style.test.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/style/style.test.cpp b/test/style/style.test.cpp
index 41f12f6ff7..89c5c4ce6f 100644
--- a/test/style/style.test.cpp
+++ b/test/style/style.test.cpp
@@ -3,10 +3,13 @@
#include <mbgl/style/style.hpp>
#include <mbgl/style/source_impl.hpp>
+#include <mbgl/style/sources/vector_source.hpp>
#include <mbgl/style/layer.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
+#include <memory>
+
using namespace mbgl;
using namespace mbgl::style;
@@ -113,3 +116,21 @@ TEST(Style, Properties) {
ASSERT_EQ(0, style.getDefaultZoom());
ASSERT_EQ(0, style.getDefaultPitch());
}
+
+TEST(Style, DuplicateSource) {
+ util::RunLoop loop;
+
+ StubFileSource fileSource;
+ Style style { fileSource, 1.0 };
+
+ style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
+
+ style.addSource(std::make_unique<VectorSource>("sourceId", "mapbox://mapbox.mapbox-terrain-v2"));
+
+ try {
+ style.addSource(std::make_unique<VectorSource>("sourceId", "mapbox://mapbox.mapbox-terrain-v2"));
+ FAIL() << "Should not have been allowed to add a duplicate source id";
+ } catch (std::runtime_error) {
+ //Expected
+ }
+}