mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
b83e0991b9
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.
25 lines
1.1 KiB
Swift
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.")
|
|
}
|
|
}
|
|
}
|