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
25 lines
1.0 KiB
Swift
25 lines
1.0 KiB
Swift
import SourceKittenFramework
|
|
import Testing
|
|
|
|
@Suite
|
|
struct ExtendedNSStringTests {
|
|
@Test
|
|
func lineAndCharacterForByteOffset_forContentsContainingMultibyteCharacters() {
|
|
let contents = "" +
|
|
"import Foundation\n" + // 18 characters
|
|
"class Test {\n" + // 13 characters
|
|
"func test() {\n" + // 14 characters
|
|
"// 日本語コメント : comment in Japanese\n" + // 33 characters
|
|
"// do something\n" + // 16 characters
|
|
"}\n" +
|
|
"}"
|
|
// A character placed on 80 offset indicates a white-space before 'do' at 5th line.
|
|
if let lineAndCharacter = StringView(contents).lineAndCharacter(forCharacterOffset: 80) {
|
|
#expect(lineAndCharacter.line == 5)
|
|
#expect(lineAndCharacter.character == 3)
|
|
} else {
|
|
Issue.record("NSString.lineAndCharacterForByteOffset should return non-nil tuple.")
|
|
}
|
|
}
|
|
}
|