diff options
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLStyleValue.mm | 4 | ||||
-rw-r--r-- | platform/darwin/test/MGLStyleValueTests.h | 4 | ||||
-rw-r--r-- | platform/darwin/test/MGLStyleValueTests.m | 13 | ||||
-rw-r--r-- | platform/darwin/test/MGLStyleValueTests.swift | 6 | ||||
-rw-r--r-- | platform/darwin/test/test-Bridging-Header.h | 1 |
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" |