Skip to content

Commit e9627d8

Browse files
committed
Merge remote-tracking branch 'origin/master' into swift-4.0-branch
2 parents c613134 + 53317ff commit e9627d8

File tree

2 files changed

+2
-41
lines changed

2 files changed

+2
-41
lines changed

Foundation/ExtraStringAPIs.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,9 @@
1313
// Random access for String.UTF16View, only when Foundation is
1414
// imported. Making this API dependent on Foundation decouples the
1515
// Swift core from a UTF16 representation.
16-
extension String.UTF16View.Index : Strideable {
17-
/// Construct from an integer offset.
18-
public init(_ offset: Int) {
19-
_precondition(offset >= 0, "Negative UTF16 index offset not allowed")
20-
self.init(encodedOffset: offset)
21-
}
22-
23-
public func distance(to other: String.UTF16View.Index) -> Int {
24-
return encodedOffset.distance(to: other.encodedOffset)
25-
}
26-
16+
extension String.UTF16View.Index {
2717
public func advanced(by n: Int) -> String.UTF16View.Index {
28-
return String.UTF16View.Index(encodedOffset.advanced(by: n))
18+
return String.UTF16View.Index(encodedOffset: encodedOffset.advanced(by: n))
2919
}
3020
}
3121

TestFoundation/TestNSString.swift

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class TestNSString : XCTestCase {
9696
("test_mutableStringConstructor", test_mutableStringConstructor),
9797
("test_emptyStringPrefixAndSuffix",test_emptyStringPrefixAndSuffix),
9898
("test_PrefixSuffix", test_PrefixSuffix),
99-
("test_utf16StringRangeCount", test_StringUTF16ViewIndexStrideableRange),
10099
("test_reflection", { _ in test_reflection }),
101100
("test_replacingOccurrences", test_replacingOccurrences),
102101
("test_getLineStart", test_getLineStart),
@@ -1070,34 +1069,6 @@ class TestNSString : XCTestCase {
10701069
}
10711070
}
10721071

1073-
//[SR-1988] Ranges of String.UTF16View.Index have negative count
1074-
func test_StringUTF16ViewIndexStrideableRange(){
1075-
let testStrings = ["", "\u{0000}", "a", "aa", "ab", "\u{007f}", "\u{0430}", "\u{0430}\u{0431}\u{0432}","\u{1f425}"]
1076-
1077-
func checkStrideable<S : Strideable>(
1078-
instances: [S],
1079-
distances: [S.Stride],
1080-
distanceOracle: (Int, Int) -> S.Stride
1081-
) {
1082-
for i in instances.indices {
1083-
let first = instances[i]
1084-
for j in instances.indices {
1085-
let second = instances[j]
1086-
XCTAssertTrue(distanceOracle(i, j) == first.distance(to: second))
1087-
XCTAssertTrue(second == first.advanced(by: distanceOracle(i, j)))
1088-
}
1089-
}
1090-
}
1091-
testStrings.forEach{
1092-
let utf16 = $0.utf16
1093-
var indicies = Array(utf16.indices)
1094-
indicies.append(utf16.indices.endIndex)
1095-
checkStrideable(instances: indicies,
1096-
distances: Array(0..<utf16.count),
1097-
distanceOracle: {$1 - $0})
1098-
}
1099-
}
1100-
11011072
func test_mutableStringConstructor() {
11021073
let mutableString = NSMutableString(string: "Test")
11031074
XCTAssertEqual(mutableString, "Test")

0 commit comments

Comments
 (0)