Skip to content

Commit 57e5f7f

Browse files
authored
Merge pull request swiftlang#1516 from otaviolima/remove-superfluous-XCTAssertNotNil
2 parents c2a4159 + 71f5e10 commit 57e5f7f

13 files changed

+2
-23
lines changed

TestFoundation/TestDateFormatter.swift

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class TestDateFormatter: XCTestCase {
5656
"shortStandaloneQuarterSymbols" : ["Q1", "Q2", "Q3", "Q4"]]
5757

5858
let f = DateFormatter()
59-
XCTAssertNotNil(f)
6059
XCTAssertNotNil(f.timeZone)
6160
XCTAssertNotNil(f.locale)
6261

TestFoundation/TestFileManager.swift

-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ class TestFileManager : XCTestCase {
153153
func test_fileSystemRepresentation() {
154154
let str = ""
155155
let result = FileManager.default.fileSystemRepresentation(withPath: str)
156-
XCTAssertNotNil(result)
157156
XCTAssertEqual(UInt8(bitPattern: result[0]), 0xE2)
158157
XCTAssertEqual(UInt8(bitPattern: result[1]), 0x98)
159158
XCTAssertEqual(UInt8(bitPattern: result[2]), 0x83)
@@ -657,7 +656,6 @@ class TestFileManager : XCTestCase {
657656
func test_temporaryDirectoryForUser() {
658657
let filemanger = FileManager.default
659658
let tmpDir = filemanger.temporaryDirectory
660-
XCTAssertNotNil(tmpDir)
661659
let tmpFileUrl = tmpDir.appendingPathComponent("test.bin")
662660
let tmpFilePath = tmpFileUrl.path
663661

TestFoundation/TestNSData.swift

-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,6 @@ class TestNSData: LoopbackServerTest {
833833
// Check all of the NSMutableData constructors are available.
834834
func test_initNSMutableData() {
835835
let mData = NSMutableData()
836-
XCTAssertNotNil(mData)
837836
XCTAssertEqual(mData.length, 0)
838837
}
839838

TestFoundation/TestNSURLRequest.swift

-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class TestNSURLRequest : XCTestCase {
4040
func test_construction() {
4141
let request = NSURLRequest(url: url)
4242
// Match macOS Foundation responses
43-
XCTAssertNotNil(request)
4443
XCTAssertEqual(request.url, url)
4544
XCTAssertEqual(request.httpMethod, "GET")
4645
XCTAssertNil(request.allHTTPHeaderFields)
@@ -52,7 +51,6 @@ class TestNSURLRequest : XCTestCase {
5251
let request = NSMutableURLRequest(url: url)
5352

5453
//Confirm initial state matches NSURLRequest responses
55-
XCTAssertNotNil(request)
5654
XCTAssertEqual(request.url, url)
5755
XCTAssertEqual(request.httpMethod, "GET")
5856
XCTAssertNil(request.allHTTPHeaderFields)

TestFoundation/TestNotificationCenter.swift

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class TestNotificationCenter : XCTestCase {
3535

3636
func test_defaultCenter() {
3737
let defaultCenter1 = NotificationCenter.default
38-
XCTAssertNotNil(defaultCenter1)
3938
let defaultCenter2 = NotificationCenter.default
4039
XCTAssertEqual(defaultCenter1, defaultCenter2)
4140
}

TestFoundation/TestNotificationQueue.swift

-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ FIXME SR-4280 timeouts in TestNSNotificationQueue tests
3838

3939
func test_defaultQueue() {
4040
let defaultQueue1 = NotificationQueue.default
41-
XCTAssertNotNil(defaultQueue1)
4241
let defaultQueue2 = NotificationQueue.default
4342
XCTAssertEqual(defaultQueue1, defaultQueue2)
4443

4544
executeInBackgroundThread() {
4645
let defaultQueueForBackgroundThread = NotificationQueue.default
47-
XCTAssertNotNil(defaultQueueForBackgroundThread)
4846
XCTAssertEqual(defaultQueueForBackgroundThread, NotificationQueue.default)
4947
XCTAssertNotEqual(defaultQueueForBackgroundThread, defaultQueue1)
5048
}

TestFoundation/TestPipe.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TestPipe : XCTestCase {
3838
let data = aPipe.fileHandleForReading.readData(ofLength: text.count)
3939

4040
// Confirm that we did read data
41-
XCTAssertNotNil(data)
41+
XCTAssertEqual(data.count, stringAsData?.count, "Expected to read \(String(describing:stringAsData?.count)) from pipe but read \(data.count) instead")
4242

4343
// Confirm the data can be converted to a String
4444
let convertedData = String(data: data, encoding: .utf8)

TestFoundation/TestProcessInfo.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TestProcessInfo : XCTestCase {
3434
XCTAssertFalse(versionString.isEmpty)
3535

3636
let version = processInfo.operatingSystemVersion
37-
XCTAssertNotNil(version.majorVersion != 0)
37+
XCTAssert(version.majorVersion != 0)
3838
}
3939

4040
func test_processName() {

TestFoundation/TestRunLoop.swift

-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ class TestRunLoop : XCTestCase {
3838

3939
func test_runLoopInit() {
4040
let mainRunLoop = RunLoop.main
41-
XCTAssertNotNil(mainRunLoop)
4241
let currentRunLoop = RunLoop.current
43-
XCTAssertNotNil(currentRunLoop)
4442

4543
let secondAccessOfMainLoop = RunLoop.main
4644
XCTAssertEqual(mainRunLoop, secondAccessOfMainLoop, "fetching the main loop a second time should be equal")

TestFoundation/TestThread.swift

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class TestThread : XCTestCase {
3939
func test_currentThread() {
4040
let thread1 = Thread.current
4141
let thread2 = Thread.current
42-
XCTAssertNotNil(thread1)
43-
XCTAssertNotNil(thread2)
4442
XCTAssertEqual(thread1, thread2)
4543
XCTAssertEqual(thread1, Thread.mainThread)
4644
}

TestFoundation/TestURL.swift

-5
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ class TestURL : XCTestCase {
7171

7272
func test_fileURLWithPath_relativeTo() {
7373
let homeDirectory = NSHomeDirectory()
74-
XCTAssertNotNil(homeDirectory, "Failed to find home directory")
7574
let homeURL = URL(fileURLWithPath: homeDirectory, isDirectory: true)
76-
XCTAssertNotNil(homeURL, "fileURLWithPath:isDirectory: failed")
7775
XCTAssertEqual(homeDirectory, homeURL.path)
7876

7977
#if os(macOS)
@@ -88,14 +86,11 @@ class TestURL : XCTestCase {
8886
#endif
8987
// we're telling fileURLWithPath:isDirectory:relativeTo: Documents is a directory
9088
let url1 = URL(fileURLWithFileSystemRepresentation: relativePath, isDirectory: true, relativeTo: baseURL)
91-
XCTAssertNotNil(url1, "fileURLWithPath:isDirectory:relativeTo: failed")
9289
// we're letting fileURLWithPath:relativeTo: determine Documents is a directory with I/O
9390
let url2 = URL(fileURLWithPath: relativePath, relativeTo: baseURL)
94-
XCTAssertNotNil(url2, "fileURLWithPath:relativeTo: failed")
9591
XCTAssertEqual(url1, url2, "\(url1) was not equal to \(url2)")
9692
// we're telling fileURLWithPath:relativeTo: Documents is a directory with a trailing slash
9793
let url3 = URL(fileURLWithPath: relativePath + "/", relativeTo: baseURL)
98-
XCTAssertNotNil(url3, "fileURLWithPath:relativeTo: failed")
9994
XCTAssertEqual(url1, url3, "\(url1) was not equal to \(url3)")
10095
}
10196

TestFoundation/TestURLCredential.swift

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class TestURLCredential : XCTestCase {
2828

2929
func test_construction() {
3030
let credential = URLCredential(user: "swiftUser", password: "swiftPassword", persistence: .forSession)
31-
XCTAssertNotNil(credential)
3231
XCTAssertEqual(credential.user, "swiftUser")
3332
XCTAssertEqual(credential.password, "swiftPassword")
3433
XCTAssertEqual(credential.persistence, URLCredential.Persistence.forSession)

TestFoundation/TestURLRequest.swift

-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class TestURLRequest : XCTestCase {
3737
func test_construction() {
3838
let request = URLRequest(url: url)
3939
// Match macOS Foundation responses
40-
XCTAssertNotNil(request)
4140
XCTAssertEqual(request.url, url)
4241
XCTAssertEqual(request.httpMethod, "GET")
4342
XCTAssertNil(request.allHTTPHeaderFields)
@@ -49,7 +48,6 @@ class TestURLRequest : XCTestCase {
4948
var request = URLRequest(url: url)
5049

5150
//Confirm initial state matches NSURLRequest responses
52-
XCTAssertNotNil(request)
5351
XCTAssertEqual(request.url, url)
5452
XCTAssertEqual(request.httpMethod, "GET")
5553
XCTAssertNil(request.allHTTPHeaderFields)

0 commit comments

Comments
 (0)