Files
SwiftLint/Tests/SwiftLintFrameworkTests/ExtendedNSStringTests.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

25 lines
1.1 KiB
Swift

import Foundation
import XCTest
class ExtendedNSStringTests: XCTestCase {
func testLineAndCharacterForByteOffset_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" +
"}"
let string = NSString(string: contents)
// A character placed on 80 offset indicates a white-space before 'do' at 5th line.
if let lineAndCharacter = string.lineAndCharacter(forCharacterOffset: 80) {
XCTAssertEqual(lineAndCharacter.line, 5)
XCTAssertEqual(lineAndCharacter.character, 3)
} else {
XCTFail("NSString.lineAndCharacterForByteOffset should return non-nil tuple.")
}
}
}