summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLStyleValueTests.swift
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/test/MGLStyleValueTests.swift')
-rw-r--r--platform/darwin/test/MGLStyleValueTests.swift36
1 files changed, 36 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLStyleValueTests.swift b/platform/darwin/test/MGLStyleValueTests.swift
new file mode 100644
index 0000000000..f7bf343852
--- /dev/null
+++ b/platform/darwin/test/MGLStyleValueTests.swift
@@ -0,0 +1,36 @@
+import XCTest
+import Mapbox
+
+class MGLStyleValueTests: XCTestCase {
+ func testConstantValues() {
+ let geoJSONSource = MGLGeoJSONSource(identifier: "test", features: [], options: nil)
+ let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "test", source: geoJSONSource)
+
+ // Boolean
+ symbolStyleLayer.iconAllowOverlap = MGLStyleConstantValue(rawValue: true)
+ XCTAssertEqual((symbolStyleLayer.iconAllowOverlap as! MGLStyleConstantValue<NSNumber>).rawValue, true)
+
+ // Number
+ symbolStyleLayer.iconHaloWidth = MGLStyleConstantValue(rawValue: 3)
+ XCTAssertEqual((symbolStyleLayer.iconHaloWidth as! MGLStyleConstantValue<NSNumber>).rawValue, 3)
+
+ // String
+ symbolStyleLayer.textField = MGLStyleConstantValue(rawValue: "{name}")
+ XCTAssertEqual((symbolStyleLayer.textField as! MGLStyleConstantValue<NSString>).rawValue, "{name}")
+ }
+
+ func testFunctions() {
+ let geoJSONSource = MGLGeoJSONSource(identifier: "test", features: [], options: nil)
+ let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "test", source: geoJSONSource)
+
+ // Boolean
+ let stops: [NSNumber: MGLStyleValue<NSNumber>] = [
+ 1: MGLStyleValue(rawValue: true),
+ 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))
+ }
+}