Skip to content

Commit 47b4180

Browse files
committed
Fix more warnings.
- Use 'let' instead of 'var' on some immutable variables. - TestJSONEncoder: Change a test struct from Codable to Encodable as the contents are constant and cant be used for Decoding.
1 parent ff75ac8 commit 47b4180

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Tests/Foundation/Tests/TestJSONEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ class TestJSONEncoder : XCTestCase {
623623
// UInt and Int
624624
func test_codingOfUIntMinMax() {
625625

626-
struct MyValue: Codable {
626+
struct MyValue: Encodable {
627627
let int64Min = Int64.min
628628
let int64Max = Int64.max
629629
let uint64Min = UInt64.min

Tests/Foundation/Tests/TestNSString.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TestNSString: LoopbackServerTest {
3333
let testString = "\u{00} This is a test string"
3434
let data = testString.data(using: .utf8)!
3535
XCTAssertEqual(data.count, 23)
36-
_ = data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) in
36+
data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) in
3737
if let text1 = NSString(bytes: bytes.baseAddress!, length: data.count, encoding: String.Encoding.utf8.rawValue) {
3838
XCTAssertEqual(text1.length, data.count)
3939
XCTAssertEqual(text1, testString as NSString)

Tests/Foundation/Tests/TestStream.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class TestStream : XCTestCase {
162162
XCTAssertEqual(try testSubdata(UInt64(str.count))!.count, 0) // It shouldbe end
163163

164164
do {
165-
try testSubdata(UInt64(str.count + 1)) // out of boundaries
165+
_ = try testSubdata(UInt64(str.count + 1)) // out of boundaries
166166
XCTFail()
167167
} catch let error as InputStream._Error {
168168
XCTAssertEqual(error, .cantSeekInputStream)

Tests/Foundation/Tests/TestURLSession.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class TestURLSession: LoopbackServerTest {
357357
config.timeoutIntervalForRequest = 5
358358
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/requestHeaders"
359359
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
360-
var expect = expectation(description: "POST \(urlString): get request headers")
360+
let expect = expectation(description: "POST \(urlString): get request headers")
361361
var req = URLRequest(url: URL(string: urlString)!)
362362
let headers = ["header1": "value1"]
363363
req.httpMethod = "POST"
@@ -384,7 +384,7 @@ class TestURLSession: LoopbackServerTest {
384384
config.httpAdditionalHeaders = ["header2": "svalue2", "header3": "svalue3", "header4": "svalue4"]
385385
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/requestHeaders"
386386
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
387-
var expect = expectation(description: "POST \(urlString) with additional headers")
387+
let expect = expectation(description: "POST \(urlString) with additional headers")
388388
var req = URLRequest(url: URL(string: urlString)!)
389389
let headers = ["header1": "rvalue1", "header2": "rvalue2", "Header4": "rvalue4"]
390390
req.httpMethod = "POST"
@@ -411,7 +411,7 @@ class TestURLSession: LoopbackServerTest {
411411
config.timeoutIntervalForRequest = 5
412412
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/Peru"
413413
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
414-
var expect = expectation(description: "GET \(urlString): no timeout")
414+
let expect = expectation(description: "GET \(urlString): no timeout")
415415
let req = URLRequest(url: URL(string: urlString)!)
416416
let task = session.dataTask(with: req) { (data, _, error) -> Void in
417417
defer { expect.fulfill() }
@@ -427,7 +427,7 @@ class TestURLSession: LoopbackServerTest {
427427
config.timeoutIntervalForRequest = 10
428428
let urlString = "http://127.0.0.1:-1/Peru"
429429
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
430-
var expect = expectation(description: "GET \(urlString): will timeout")
430+
let expect = expectation(description: "GET \(urlString): will timeout")
431431
var req = URLRequest(url: URL(string: "http://127.0.0.1:-1/Peru")!)
432432
req.timeoutInterval = 1
433433
let task = session.dataTask(with: req) { (data, _, error) -> Void in
@@ -754,7 +754,7 @@ class TestURLSession: LoopbackServerTest {
754754
var req = URLRequest(url: URL(string: urlString)!)
755755
req.timeoutInterval = 3
756756
let config = URLSessionConfiguration.default
757-
var expect = expectation(description: "GET \(urlString): timeout with redirection ")
757+
let expect = expectation(description: "GET \(urlString): timeout with redirection ")
758758
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
759759
let task = session.dataTask(with: req) { data, response, error in
760760
defer { expect.fulfill() }
@@ -1176,7 +1176,7 @@ class TestURLSession: LoopbackServerTest {
11761176
XCTAssertEqual(config.httpCookieStorage?.cookies?.count, 0)
11771177
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/requestCookies"
11781178
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
1179-
var expect = expectation(description: "POST \(urlString)")
1179+
let expect = expectation(description: "POST \(urlString)")
11801180
var req = URLRequest(url: URL(string: urlString)!)
11811181
req.httpMethod = "POST"
11821182
let task = session.dataTask(with: req) { (data, response, error) -> Void in
@@ -1201,7 +1201,7 @@ class TestURLSession: LoopbackServerTest {
12011201
emptyCookieStorage(storage: config.httpCookieStorage)
12021202
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/requestCookies"
12031203
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
1204-
var expect = expectation(description: "POST \(urlString)")
1204+
let expect = expectation(description: "POST \(urlString)")
12051205
var req = URLRequest(url: URL(string: urlString)!)
12061206
req.httpMethod = "POST"
12071207
let task = session.dataTask(with: req) { (data, response, error) -> Void in
@@ -1226,7 +1226,7 @@ class TestURLSession: LoopbackServerTest {
12261226
emptyCookieStorage(storage: config.httpCookieStorage)
12271227
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/redirectToEchoHeaders"
12281228
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
1229-
var expect = expectation(description: "POST \(urlString)")
1229+
let expect = expectation(description: "POST \(urlString)")
12301230
let req = URLRequest(url: URL(string: urlString)!)
12311231
let task = session.dataTask(with: req) { (data, _, error) -> Void in
12321232
defer { expect.fulfill() }
@@ -1294,7 +1294,7 @@ class TestURLSession: LoopbackServerTest {
12941294

12951295
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/requestCookies"
12961296
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
1297-
var expect = expectation(description: "POST \(urlString)")
1297+
let expect = expectation(description: "POST \(urlString)")
12981298
var req = URLRequest(url: URL(string: urlString)!)
12991299
req.httpMethod = "POST"
13001300
let task = session.dataTask(with: req) { (data, _, error) -> Void in
@@ -1404,7 +1404,7 @@ class TestURLSession: LoopbackServerTest {
14041404
config.timeoutIntervalForRequest = 5
14051405
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/emptyPost"
14061406
let session = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
1407-
var expect = expectation(description: "POST \(urlString): post with empty body")
1407+
let expect = expectation(description: "POST \(urlString): post with empty body")
14081408
var req = URLRequest(url: URL(string: urlString)!)
14091409
req.httpMethod = "POST"
14101410
let task = session.dataTask(with: req) { (_, response, error) -> Void in

0 commit comments

Comments
 (0)