summaryrefslogtreecommitdiff
path: root/platform/darwin
diff options
context:
space:
mode:
authorFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-12-07 17:19:15 +0100
committerGitHub <noreply@github.com>2016-12-07 17:19:15 +0100
commit508f020eb5f8665e9cb53fb319440216d134e299 (patch)
tree613fc7cb875819ad21e545e145b9a7150a3fba46 /platform/darwin
parent3b7e98d0b126fdc97ba0ae21412ac35508ccf5b0 (diff)
downloadqtlocation-mapboxgl-508f020eb5f8665e9cb53fb319440216d134e299.tar.gz
Prevent stopless functions (#7309)
* [ios, macos] prevent stopless functions * [ios, macos] removed unused bridging header and fixed naming
Diffstat (limited to 'platform/darwin')
-rw-r--r--platform/darwin/src/MGLStyleValue.mm4
-rw-r--r--platform/darwin/test/MGLStyleValueTests.h4
-rw-r--r--platform/darwin/test/MGLStyleValueTests.m13
-rw-r--r--platform/darwin/test/MGLStyleValueTests.swift6
-rw-r--r--platform/darwin/test/test-Bridging-Header.h1
5 files changed, 26 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLStyleValue.mm b/platform/darwin/src/MGLStyleValue.mm
index 43b51d6788..6ced819cd1 100644
--- a/platform/darwin/src/MGLStyleValue.mm
+++ b/platform/darwin/src/MGLStyleValue.mm
@@ -63,6 +63,10 @@
- (instancetype)initWithBase:(CGFloat)base stops:(NSDictionary *)stops {
if (self = [super init]) {
+ if (!stops.count)
+ {
+ [NSException raise:NSInvalidArgumentException format:@"%@ requires at least one stop.", self];
+ }
_base = base;
_stops = stops;
}
diff --git a/platform/darwin/test/MGLStyleValueTests.h b/platform/darwin/test/MGLStyleValueTests.h
new file mode 100644
index 0000000000..a563de39f0
--- /dev/null
+++ b/platform/darwin/test/MGLStyleValueTests.h
@@ -0,0 +1,4 @@
+#import <XCTest/XCTest.h>
+
+@interface MGLStyleValueTests : XCTestCase
+@end
diff --git a/platform/darwin/test/MGLStyleValueTests.m b/platform/darwin/test/MGLStyleValueTests.m
new file mode 100644
index 0000000000..fe6096584d
--- /dev/null
+++ b/platform/darwin/test/MGLStyleValueTests.m
@@ -0,0 +1,13 @@
+#import <XCTest/XCTest.h>
+#import <Mapbox/Mapbox.h>
+
+@interface MGLStyleValueTests : XCTestCase
+@end
+
+@implementation MGLStyleValueTests
+
+- (void)testStoplessFunction {
+ XCTAssertThrowsSpecificNamed([MGLStyleValue<NSNumber *> valueWithStops:@{}], NSException, NSInvalidArgumentException, @"Stopless function should raise an exception");
+}
+
+@end
diff --git a/platform/darwin/test/MGLStyleValueTests.swift b/platform/darwin/test/MGLStyleValueTests.swift
index aa9b003236..7a266a495f 100644
--- a/platform/darwin/test/MGLStyleValueTests.swift
+++ b/platform/darwin/test/MGLStyleValueTests.swift
@@ -1,7 +1,9 @@
import XCTest
import Mapbox
-class MGLStyleValueTests: XCTestCase {
+
+extension MGLStyleValueTests {
+
func testConstantValues() {
let geoJSONSource = MGLGeoJSONSource(identifier: "test", shape: nil, options: nil)
let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "test", source: geoJSONSource)
@@ -29,7 +31,7 @@ class MGLStyleValueTests: XCTestCase {
2: MGLStyleValue(rawValue: false),
3: MGLStyleValue(rawValue: true),
4: MGLStyleValue(rawValue: false),
- ]
+ ]
symbolStyleLayer.iconAllowOverlap = MGLStyleFunction<NSNumber>(base: 1, stops: stops)
XCTAssertEqual((symbolStyleLayer.iconAllowOverlap as! MGLStyleFunction<NSNumber>), MGLStyleFunction(base: 1, stops: stops))
}
diff --git a/platform/darwin/test/test-Bridging-Header.h b/platform/darwin/test/test-Bridging-Header.h
index e11d920b12..5d23e9d6c5 100644
--- a/platform/darwin/test/test-Bridging-Header.h
+++ b/platform/darwin/test/test-Bridging-Header.h
@@ -1,3 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
+#import "MGLStyleValueTests.h"