mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
b83e0991b9
The MIT license doesn't require that all files be prepended with this licensing or copyright information. Realm confirmed that they're ok with this change. This will enable some companies to contribute to SwiftLint and the date & authorship information will remain accessible via git source control.
46 lines
1.9 KiB
Swift
46 lines
1.9 KiB
Swift
import SourceKittenFramework
|
|
@testable import SwiftLintFramework
|
|
import XCTest
|
|
|
|
// swiftlint:disable:next type_name
|
|
class ImplicitlyUnwrappedOptionalConfigurationTests: XCTestCase {
|
|
|
|
func testImplicitlyUnwrappedOptionalConfigurationProperlyAppliesConfigurationFromDictionary() throws {
|
|
var configuration = ImplicitlyUnwrappedOptionalConfiguration(mode: .allExceptIBOutlets,
|
|
severity: SeverityConfiguration(.warning))
|
|
|
|
try configuration.apply(configuration: ["mode": "all", "severity": "error"])
|
|
XCTAssertEqual(configuration.mode, .all)
|
|
XCTAssertEqual(configuration.severity.severity, .error)
|
|
|
|
try configuration.apply(configuration: ["mode": "all_except_iboutlets"])
|
|
XCTAssertEqual(configuration.mode, .allExceptIBOutlets)
|
|
XCTAssertEqual(configuration.severity.severity, .error)
|
|
|
|
try configuration.apply(configuration: ["severity": "warning"])
|
|
XCTAssertEqual(configuration.mode, .allExceptIBOutlets)
|
|
XCTAssertEqual(configuration.severity.severity, .warning)
|
|
|
|
try configuration.apply(configuration: ["mode": "all", "severity": "warning"])
|
|
XCTAssertEqual(configuration.mode, .all)
|
|
XCTAssertEqual(configuration.severity.severity, .warning)
|
|
}
|
|
|
|
func testImplicitlyUnwrappedOptionalConfigurationThrowsOnBadConfig() {
|
|
let badConfigs: [[String: Any]] = [
|
|
["mode": "everything"],
|
|
["mode": false],
|
|
["mode": 42]
|
|
]
|
|
|
|
for badConfig in badConfigs {
|
|
var configuration = ImplicitlyUnwrappedOptionalConfiguration(mode: .allExceptIBOutlets,
|
|
severity: SeverityConfiguration(.warning))
|
|
checkError(ConfigurationError.unknownConfiguration) {
|
|
try configuration.apply(configuration: badConfig)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|