File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ extension _NSRange {
39
39
public init ( _ x: Range < Int > ) {
40
40
if let start = x. first {
41
41
if let end = x. last {
42
- self . init ( location: start, length: end - start)
42
+ self . init ( location: start, length: end - start + 1 )
43
43
return
44
44
}
45
45
}
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class TestNSRange : XCTestCase {
23
23
return [
24
24
// currently disabled due to pending requirements for NSString
25
25
// ("test_NSRangeFromString", test_NSRangeFromString ),
26
+ ( " test_NSRangeBridging " , test_NSRangeBridging)
26
27
]
27
28
}
28
29
@@ -58,4 +59,11 @@ class TestNSRange : XCTestCase {
58
59
XCTAssert ( NSEqualRanges ( NSRangeFromString ( string) , fullRange) )
59
60
}
60
61
}
62
+
63
+ func test_NSRangeBridging( ) {
64
+ let swiftRange = 1 ..< 7
65
+ let range = NSRange ( swiftRange)
66
+ let swiftRange2 = range. toRange ( )
67
+ XCTAssertEqual ( swiftRange, swiftRange2)
68
+ }
61
69
}
You can’t perform that action at this time.
0 commit comments