Files
SwiftLint/Tests/SwiftLintFrameworkTests/EmptyCountRuleTests.swift
Zsolt KovácsandGitHub ab8cd43e67 Empty count configuration (#3052)
* Add `only_after_dot` configuration option to `empty_count` rule

* Update CHANGELOG.md

* Adopt Example wrapper

* Change severity level to error
2020-02-09 15:12:54 -08:00

41 lines
1.4 KiB
Swift

@testable import SwiftLintFramework
import XCTest
class EmptyCountRuleTests: XCTestCase {
func testEmptyCountWithDefaultConfiguration() {
// Test with default parameters
verifyRule(EmptyCountRule.description)
}
func testEmptyCountWithOnlyAfterDot() {
// Test with `only_after_dot` set to true
let nonTriggeringExamples = [
Example("var count = 0\n"),
Example("[Int]().isEmpty\n"),
Example("[Int]().count > 1\n"),
Example("[Int]().count == 1\n"),
Example("[Int]().count == 0xff\n"),
Example("[Int]().count == 0b01\n"),
Example("[Int]().count == 0o07\n"),
Example("discount == 0\n"),
Example("order.discount == 0\n"),
Example("count == 0\n")
]
let triggeringExamples = [
Example("[Int]().↓count == 0\n"),
Example("[Int]().↓count > 0\n"),
Example("[Int]().↓count != 0\n"),
Example("[Int]().↓count == 0x0\n"),
Example("[Int]().↓count == 0x00_00\n"),
Example("[Int]().↓count == 0b00\n"),
Example("[Int]().↓count == 0o00\n")
]
let description = EmptyCountRule.description
.with(triggeringExamples: triggeringExamples)
.with(nonTriggeringExamples: nonTriggeringExamples)
verifyRule(description, ruleConfiguration: ["only_after_dot": true])
}
}