Files
SwiftLint/Tests/SwiftLintFrameworkTests/NumberSeparatorRuleTests.swift
T
JP Simard b83e0991b9 Remove all file headers
The MIT license doesn't require that all files be prepended with this
licensing or copyright information. Realm confirmed that they're ok with this
change. This will enable some companies to contribute to SwiftLint and the
date & authorship information will remain accessible via git source control.
2018-05-04 13:42:02 -07:00

63 lines
2.0 KiB
Swift

import SwiftLintFramework
import XCTest
class NumberSeparatorRuleTests: XCTestCase {
func testNumberSeparatorWithDefaultConfiguration() {
verifyRule(NumberSeparatorRule.description)
}
func testNumberSeparatorWithMinimumLength() {
let nonTriggeringExamples = [
"let foo = 10_000",
"let foo = 1000",
"let foo = 1000.0001",
"let foo = 10_000.0001",
"let foo = 1000.000_01"
]
let triggeringExamples = [
"let foo = ↓1_000",
"let foo = ↓1.000_1",
"let foo = ↓1_000.000_1"
]
let corrections = [
"let foo = ↓1_000": "let foo = 1000",
"let foo = ↓1.000_1": "let foo = 1.0001",
"let foo = ↓1_000.000_1": "let foo = 1000.0001"
]
let description = NumberSeparatorRule.description
.with(triggeringExamples: triggeringExamples)
.with(nonTriggeringExamples: nonTriggeringExamples)
.with(corrections: corrections)
verifyRule(description, ruleConfiguration: ["minimum_length": 5])
}
func testNumberSeparatorWithMinimumFractionLength() {
let nonTriggeringExamples = [
"let foo = 1_000.000_000_1",
"let foo = 1.000_001",
"let foo = 100.0001",
"let foo = 1_000.000_01"
]
let triggeringExamples = [
"let foo = ↓1000",
"let foo = ↓1.000_1",
"let foo = ↓1_000.000_1"
]
let corrections = [
"let foo = ↓1000": "let foo = 1_000",
"let foo = ↓1.000_1": "let foo = 1.0001",
"let foo = ↓1_000.000_1": "let foo = 1_000.0001"
]
let description = NumberSeparatorRule.description
.with(triggeringExamples: triggeringExamples)
.with(nonTriggeringExamples: nonTriggeringExamples)
.with(corrections: corrections)
verifyRule(description, ruleConfiguration: ["minimum_fraction_length": 5])
}
}