mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
48 lines
1.8 KiB
Swift
48 lines
1.8 KiB
Swift
@testable import SwiftLintBuiltInRules
|
|
import XCTest
|
|
|
|
class TodoRuleTests: SwiftLintTestCase {
|
|
func testTodo() {
|
|
verifyRule(TodoRule.description, commentDoesntViolate: false)
|
|
}
|
|
|
|
func testTodoMessage() {
|
|
let example = Example("fatalError() // TODO: Implement")
|
|
let violations = self.violations(example)
|
|
XCTAssertEqual(violations.count, 1)
|
|
XCTAssertEqual(violations.first!.reason, "TODOs should be resolved (Implement)")
|
|
}
|
|
|
|
func testFixMeMessage() {
|
|
let example = Example("fatalError() // FIXME: Implement")
|
|
let violations = self.violations(example)
|
|
XCTAssertEqual(violations.count, 1)
|
|
XCTAssertEqual(violations.first!.reason, "FIXMEs should be resolved (Implement)")
|
|
}
|
|
|
|
func testOnlyFixMe() {
|
|
let example = Example("""
|
|
fatalError() // TODO: Implement todo
|
|
fatalError() // FIXME: Implement fixme
|
|
""")
|
|
let violations = self.violations(example, config: ["only": ["FIXME"]])
|
|
XCTAssertEqual(violations.count, 1)
|
|
XCTAssertEqual(violations.first!.reason, "FIXMEs should be resolved (Implement fixme)")
|
|
}
|
|
|
|
func testOnlyTodo() {
|
|
let example = Example("""
|
|
fatalError() // TODO: Implement todo
|
|
fatalError() // FIXME: Implement fixme
|
|
""")
|
|
let violations = self.violations(example, config: ["only": ["TODO"]])
|
|
XCTAssertEqual(violations.count, 1)
|
|
XCTAssertEqual(violations.first!.reason, "TODOs should be resolved (Implement todo)")
|
|
}
|
|
|
|
private func violations(_ example: Example, config: Any? = nil) -> [StyleViolation] {
|
|
let config = makeConfig(config, TodoRule.description.identifier)!
|
|
return SwiftLintFrameworkTests.violations(example, config: config)
|
|
}
|
|
}
|