summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLStyleValueTests.swift
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-10-25 23:23:11 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-10-26 15:16:15 -0700
commit12093c10ad7557a92c8852bd6b61428990311dd4 (patch)
tree6265047947e613e8b46bf1fff75fdb1fa08e24a8 /platform/darwin/test/MGLStyleValueTests.swift
parent62647a013ff398c28c8a2c2f37c2737006181302 (diff)
downloadqtlocation-mapboxgl-12093c10ad7557a92c8852bd6b61428990311dd4.tar.gz
[ios, macos] Added Swift MGLStyleValue tests
Added tests of MGLStyleValue written in Swift, along with bridging headers just in case they become needed in the future.
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))
+ }
+}