Files
SwiftLint/Tests/BuiltInRulesTests/PrivateOverFilePrivateRuleTests.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

33 lines
1.5 KiB
Swift

@testable import SwiftLintBuiltInRules
import TestHelpers
final class PrivateOverFilePrivateRuleTests: SwiftLintTestCase {
func testPrivateOverFilePrivateValidatingExtensions() {
let baseDescription = PrivateOverFilePrivateRule.description
let triggeringExamples = baseDescription.triggeringExamples + [
Example("↓fileprivate extension String {}"),
Example("↓fileprivate \n extension String {}"),
Example("↓fileprivate extension \n String {}"),
]
let corrections = [
Example("↓fileprivate extension String {}"): Example("private extension String {}"),
Example("↓fileprivate \n extension String {}"): Example("private \n extension String {}"),
Example("↓fileprivate extension \n String {}"): Example("private extension \n String {}"),
]
let description = baseDescription.with(nonTriggeringExamples: [])
.with(triggeringExamples: triggeringExamples).with(corrections: corrections)
verifyRule(description, ruleConfiguration: ["validate_extensions": true])
}
func testPrivateOverFilePrivateNotValidatingExtensions() {
let baseDescription = PrivateOverFilePrivateRule.description
let nonTriggeringExamples = baseDescription.nonTriggeringExamples + [
Example("fileprivate extension String {}")
]
let description = baseDescription.with(nonTriggeringExamples: nonTriggeringExamples)
verifyRule(description, ruleConfiguration: ["validate_extensions": false])
}
}