Skip to content

Commit 266b466

Browse files
committed
Remove deprecated String .characters from tests
1 parent 57147be commit 266b466

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

TestFoundation/HTTPServer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class _TCPSocket {
100100
}
101101

102102
func split(_ str: String, _ count: Int) -> [String] {
103-
return stride(from: 0, to: str.characters.count, by: count).map { i -> String in
103+
return stride(from: 0, to: str.count, by: count).map { i -> String in
104104
let startIndex = str.index(str.startIndex, offsetBy: i)
105105
let endIndex = str.index(startIndex, offsetBy: count, limitedBy: str.endIndex) ?? str.endIndex
106106
return String(str[startIndex..<endIndex])
@@ -346,7 +346,7 @@ public class TestURLSessionServer {
346346
}
347347

348348
if uri == "/country.txt" {
349-
let text = capitals[String(uri.characters.dropFirst())]!
349+
let text = capitals[String(uri.dropFirst())]!
350350
return _HTTPResponse(response: .OK, headers: "Content-Length: \(text.data(using: .utf8)!.count)", body: text)
351351
}
352352

@@ -356,7 +356,7 @@ public class TestURLSessionServer {
356356
}
357357

358358
if uri == "/UnitedStates" {
359-
let value = capitals[String(uri.characters.dropFirst())]!
359+
let value = capitals[String(uri.dropFirst())]!
360360
let text = request.getCommaSeparatedHeaders()
361361
let host = request.headers[1].components(separatedBy: " ")[1]
362362
let ip = host.components(separatedBy: ":")[0]
@@ -366,7 +366,7 @@ public class TestURLSessionServer {
366366
let httpResponse = _HTTPResponse(response: .REDIRECT, headers: "Location: http://\(newHost + "/" + value)", body: text)
367367
return httpResponse
368368
}
369-
return _HTTPResponse(response: .OK, body: capitals[String(uri.characters.dropFirst())]!)
369+
return _HTTPResponse(response: .OK, body: capitals[String(uri.dropFirst())]!)
370370
}
371371

372372
func stop() {

TestFoundation/TestDecimal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class TestDecimal: XCTestCase {
260260
var failed: Bool = false
261261
var count = 0
262262
let SIG_FIG = 14
263-
for (a, b) in zip(answerDescription.characters, approximationDescription.characters) {
263+
for (a, b) in zip(answerDescription, approximationDescription) {
264264
if a != b {
265265
failed = true
266266
break

TestFoundation/TestNSString.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,11 +1298,11 @@ func checkHasPrefixHasSuffix(_ lhs: String, _ rhs: String, _ stack: [UInt]) -> I
12981298
// To determine the expected results, compare grapheme clusters,
12991299
// scalar-to-scalar, of the NFD form of the strings.
13001300
let lhsNFDGraphemeClusters =
1301-
lhs.decomposedStringWithCanonicalMapping.characters.map {
1301+
lhs.decomposedStringWithCanonicalMapping.map {
13021302
Array(String($0).unicodeScalars)
13031303
}
13041304
let rhsNFDGraphemeClusters =
1305-
rhs.decomposedStringWithCanonicalMapping.characters.map {
1305+
rhs.decomposedStringWithCanonicalMapping.map {
13061306
Array(String($0).unicodeScalars)
13071307
}
13081308
let expectHasPrefix = lhsNFDGraphemeClusters.starts(

TestFoundation/TestPipe.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TestPipe : XCTestCase {
3535
aPipe.fileHandleForWriting.write(stringAsData!)
3636

3737
// Then read it out again
38-
let data = aPipe.fileHandleForReading.readData(ofLength: text.characters.count)
38+
let data = aPipe.fileHandleForReading.readData(ofLength: text.count)
3939

4040
// Confirm that we did read data
4141
XCTAssertNotNil(data)

TestFoundation/TestStream.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class TestStream : XCTestCase {
135135
XCTAssertEqual(Stream.Status.open, outputStream!.streamStatus)
136136
let result: Int? = outputStream?.write(encodedData, maxLength: encodedData.count)
137137
outputStream?.close()
138-
XCTAssertEqual(myString.characters.count, result)
138+
XCTAssertEqual(myString.count, result)
139139
XCTAssertEqual(Stream.Status.closed, outputStream!.streamStatus)
140140
removeTestFile(filePath!)
141141
} else {
@@ -154,7 +154,7 @@ class TestStream : XCTestCase {
154154
let result: Int? = outputStream.write(encodedData, maxLength: encodedData.count)
155155
outputStream.close()
156156
XCTAssertEqual(Stream.Status.closed, outputStream.streamStatus)
157-
XCTAssertEqual(myString.characters.count, result)
157+
XCTAssertEqual(myString.count, result)
158158
XCTAssertEqual(NSString(bytes: &buffer, length: buffer.count, encoding: String.Encoding.utf8.rawValue), NSString(string: myString))
159159
}
160160

@@ -169,7 +169,7 @@ class TestStream : XCTestCase {
169169
XCTAssertEqual(Stream.Status.open, outputStream!.streamStatus)
170170
let result: Int? = outputStream?.write(encodedData, maxLength: encodedData.count)
171171
outputStream?.close()
172-
XCTAssertEqual(myString.characters.count, result)
172+
XCTAssertEqual(myString.count, result)
173173
XCTAssertEqual(Stream.Status.closed, outputStream!.streamStatus)
174174
removeTestFile(filePath!)
175175
} else {
@@ -186,7 +186,7 @@ class TestStream : XCTestCase {
186186
outputStream.open()
187187
XCTAssertEqual(Stream.Status.open, outputStream.streamStatus)
188188
let result: Int? = outputStream.write(encodedData, maxLength: encodedData.count)
189-
XCTAssertEqual(myString.characters.count, result)
189+
XCTAssertEqual(myString.count, result)
190190
//verify the data written
191191
let dataWritten = outputStream.property(forKey: Stream.PropertyKey.dataWrittenToMemoryStreamKey)
192192
if let nsdataWritten = dataWritten as? NSData {

0 commit comments

Comments
 (0)