Files
SwiftLint/Tests/BuiltInRulesTests/FileLengthRuleTests.swift
T
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

28 lines
1.1 KiB
Swift

@testable import SwiftLintBuiltInRules
import TestHelpers
final class FileLengthRuleTests: SwiftLintTestCase {
func testFileLengthWithDefaultConfiguration() {
verifyRule(FileLengthRule.description, commentDoesntViolate: false,
testMultiByteOffsets: false, testShebang: false)
}
func testFileLengthIgnoringLinesWithOnlyComments() {
let triggeringExamples = [
Example(repeatElement("print(\"swiftlint\")\n", count: 401).joined())
]
let nonTriggeringExamples = [
Example((repeatElement("print(\"swiftlint\")\n", count: 400) + ["//\n"]).joined()),
Example(repeatElement("print(\"swiftlint\")\n", count: 400).joined()),
Example(repeatElement("print(\"swiftlint\")\n\n", count: 201).joined()),
]
let description = FileLengthRule.description
.with(nonTriggeringExamples: nonTriggeringExamples)
.with(triggeringExamples: triggeringExamples)
verifyRule(description, ruleConfiguration: ["ignore_comment_only_lines": true],
testMultiByteOffsets: false, testShebang: false)
}
}