@@ -94,7 +94,8 @@ class TestNSString: LoopbackServerTest {
94
94
( " test_substringWithRange " , test_substringWithRange) ,
95
95
( " test_substringFromCFString " , test_substringFromCFString) ,
96
96
( " test_createCopy " , test_createCopy) ,
97
- ( " test_commonPrefix " , test_commonPrefix)
97
+ ( " test_commonPrefix " , test_commonPrefix) ,
98
+ ( " test_lineRangeFor " , test_lineRangeFor)
98
99
]
99
100
}
100
101
@@ -1330,6 +1331,18 @@ class TestNSString: LoopbackServerTest {
1330
1331
XCTAssertEqual ( " m \u{E4} dchen " . commonPrefix ( with: " M \u{E4} dchenschule " , options: [ . caseInsensitive, . literal] ) , " mädchen " )
1331
1332
XCTAssertEqual ( " ma \u{308} dchen " . commonPrefix ( with: " M \u{E4} dchenschule " , options: [ . caseInsensitive, . literal] ) , " m " )
1332
1333
}
1334
+
1335
+ func test_lineRangeFor( ) {
1336
+ // column 1 2 3 4 5 6 7 8 9 10 11
1337
+ // line 1 L I N E 1 _ 6 7 あ \n
1338
+ // line 2 L I N E 2 _ 7 8 9 0 \n
1339
+ // line 3 L I N E 3 _ 8 9 0 1 \n
1340
+ let string = " LINE1_67あ \n LINE2_7890 \n LINE3_8901 \n "
1341
+ let rangeOfFirstLine = string. lineRange ( for: string. startIndex..< string. startIndex)
1342
+ XCTAssertEqual ( string. distance ( from: rangeOfFirstLine. lowerBound, to: rangeOfFirstLine. upperBound) , 10 )
1343
+ let firstLine = string [ rangeOfFirstLine]
1344
+ XCTAssertEqual ( firstLine, " LINE1_67あ \n " )
1345
+ }
1333
1346
}
1334
1347
1335
1348
func test_reflection( ) {
0 commit comments