mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
# Conflicts: # Tests/BuiltInRulesTests/FileHeaderRuleTests.swift # Tests/BuiltInRulesTests/FileNameNoSpaceRuleTests.swift # Tests/BuiltInRulesTests/IndentationWidthRuleTests.swift # Tests/CoreTests/RegexConfigurationTests.swift # Tests/CoreTests/SwiftLintFileTests.swift # Tests/FileSystemAccessTests/BaselineTests.swift # Tests/FileSystemAccessTests/ConfigurationTests+Mock.swift # Tests/FileSystemAccessTests/ConfigurationTests.swift # Tests/FileSystemAccessTests/GlobTests.swift # Tests/FileSystemAccessTests/MultipleConfigurationsTests.swift # Tests/FileSystemAccessTests/ReporterTests.swift # Tests/FileSystemAccessTests/SourceKitCrashTests.swift # Tests/FrameworkTests/CustomRulesTests.swift # Tests/FrameworkTests/LinterCacheTests.swift # Tests/FrameworkTests/RuleConfigurationTests.swift # Tests/FrameworkTests/SwiftVersionTests.swift # Tests/GeneratedTests/GeneratedTests_02.swift # Tests/GeneratedTests/GeneratedTests_03.swift # Tests/GeneratedTests/GeneratedTests_04.swift # Tests/GeneratedTests/GeneratedTests_05.swift # Tests/GeneratedTests/GeneratedTests_06.swift # Tests/GeneratedTests/GeneratedTests_07.swift # Tests/GeneratedTests/GeneratedTests_08.swift # Tests/GeneratedTests/GeneratedTests_09.swift # Tests/GeneratedTests/GeneratedTests_10.swift # Tests/IntegrationTests/ConfigPathResolutionTests.swift # Tests/IntegrationTests/IntegrationTests.swift # Tests/TestHelpers/TestHelpers.swift
68 lines
1.9 KiB
Swift
68 lines
1.9 KiB
Swift
import SwiftLintFramework
|
|
import Testing
|
|
|
|
@Suite
|
|
struct ExampleTests {
|
|
@Test
|
|
func equatableDoesNotLookAtFile() {
|
|
let first = Example("foo", file: "a", line: 1)
|
|
let second = Example("foo", file: "b", line: 1)
|
|
#expect(first == second)
|
|
}
|
|
|
|
@Test
|
|
func equatableDoesNotLookAtLine() {
|
|
let first = Example("foo", file: "a", line: 1)
|
|
let second = Example("foo", file: "a", line: 2)
|
|
#expect(first == second)
|
|
}
|
|
|
|
@Test
|
|
func equatableLooksAtCode() {
|
|
let first = Example("a", file: "a", line: 1)
|
|
let second = Example("a", file: "x", line: 2)
|
|
let third = Example("c", file: "y", line: 2)
|
|
#expect(first == second)
|
|
#expect(first != third)
|
|
}
|
|
|
|
@Test
|
|
func multiByteOffsets() {
|
|
#expect(Example("").testMultiByteOffsets)
|
|
#expect(Example("", testMultiByteOffsets: true).testMultiByteOffsets)
|
|
#expect(!Example("", testMultiByteOffsets: false).testMultiByteOffsets)
|
|
}
|
|
|
|
@Test
|
|
func onLinux() {
|
|
#expect(Example("").testOnLinux)
|
|
#expect(Example("", testOnLinux: true).testOnLinux)
|
|
#expect(!Example("", testOnLinux: false).testOnLinux)
|
|
}
|
|
|
|
@Test
|
|
func removingViolationMarkers() {
|
|
let example = Example("↓T↓E↓S↓T")
|
|
#expect(example.removingViolationMarkers() == Example("TEST"))
|
|
}
|
|
|
|
@Test
|
|
func comparable() {
|
|
#expect(Example("a") < Example("b"))
|
|
}
|
|
|
|
@Test
|
|
func withCode() {
|
|
let original = Example("original code")
|
|
#expect(original.code == "original code")
|
|
|
|
let new = original.with(code: "new code")
|
|
#expect(new.code == "new code")
|
|
|
|
// When modifying the code, it's important that the file and line
|
|
// numbers remain intact
|
|
#expect(new.file.description == original.file.description)
|
|
#expect(new.line == original.line)
|
|
}
|
|
}
|