Files
SwiftLint/Tests/BuiltInRulesTests/CompilerProtocolInitRuleTests.swift
Danny Mösch 15b285527a Separate built-in rule tests from framework tests (#5924)
* Short names for test modules
* Lint plugins and `Package.swift` in integration tests
* Simplify and merge file groups in Bazel
* Move common functions to `TestHelpers`
2024-12-30 12:26:46 +01:00

23 lines
884 B
Swift

@testable import SwiftLintBuiltInRules
import TestHelpers
import XCTest
final class CompilerProtocolInitRuleTests: SwiftLintTestCase {
private let ruleID = CompilerProtocolInitRule.identifier
func testViolationMessageForExpressibleByIntegerLiteral() throws {
let config = try XCTUnwrap(makeConfig(nil, ruleID))
let allViolations = violations(Example("let a = NSNumber(integerLiteral: 1)"), config: config)
let compilerProtocolInitViolation = allViolations.first { $0.ruleIdentifier == ruleID }
let violation = try XCTUnwrap(
compilerProtocolInitViolation,
"A compiler protocol init violation should have been triggered!"
)
XCTAssertEqual(
violation.reason,
"Initializers declared in compiler protocol ExpressibleByIntegerLiteral shouldn't be called directly"
)
}
}