Skip to content

[gardening] Remove XCTAssertNotNil calls where parameter is a non-optional type #1516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion TestFoundation/TestDateFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class TestDateFormatter: XCTestCase {
"shortStandaloneQuarterSymbols" : ["Q1", "Q2", "Q3", "Q4"]]

let f = DateFormatter()
XCTAssertNotNil(f)
XCTAssertNotNil(f.timeZone)
XCTAssertNotNil(f.locale)

Expand Down
2 changes: 0 additions & 2 deletions TestFoundation/TestFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ class TestFileManager : XCTestCase {
func test_fileSystemRepresentation() {
let str = "☃"
let result = FileManager.default.fileSystemRepresentation(withPath: str)
XCTAssertNotNil(result)
XCTAssertEqual(UInt8(bitPattern: result[0]), 0xE2)
XCTAssertEqual(UInt8(bitPattern: result[1]), 0x98)
XCTAssertEqual(UInt8(bitPattern: result[2]), 0x83)
Expand Down Expand Up @@ -657,7 +656,6 @@ class TestFileManager : XCTestCase {
func test_temporaryDirectoryForUser() {
let filemanger = FileManager.default
let tmpDir = filemanger.temporaryDirectory
XCTAssertNotNil(tmpDir)
let tmpFileUrl = tmpDir.appendingPathComponent("test.bin")
let tmpFilePath = tmpFileUrl.path

Expand Down
1 change: 0 additions & 1 deletion TestFoundation/TestNSData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,6 @@ class TestNSData: LoopbackServerTest {
// Check all of the NSMutableData constructors are available.
func test_initNSMutableData() {
let mData = NSMutableData()
XCTAssertNotNil(mData)
XCTAssertEqual(mData.length, 0)
}

Expand Down
2 changes: 0 additions & 2 deletions TestFoundation/TestNSURLRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class TestNSURLRequest : XCTestCase {
func test_construction() {
let request = NSURLRequest(url: url)
// Match macOS Foundation responses
XCTAssertNotNil(request)
XCTAssertEqual(request.url, url)
XCTAssertEqual(request.httpMethod, "GET")
XCTAssertNil(request.allHTTPHeaderFields)
Expand All @@ -52,7 +51,6 @@ class TestNSURLRequest : XCTestCase {
let request = NSMutableURLRequest(url: url)

//Confirm initial state matches NSURLRequest responses
XCTAssertNotNil(request)
XCTAssertEqual(request.url, url)
XCTAssertEqual(request.httpMethod, "GET")
XCTAssertNil(request.allHTTPHeaderFields)
Expand Down
1 change: 0 additions & 1 deletion TestFoundation/TestNotificationCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class TestNotificationCenter : XCTestCase {

func test_defaultCenter() {
let defaultCenter1 = NotificationCenter.default
XCTAssertNotNil(defaultCenter1)
let defaultCenter2 = NotificationCenter.default
XCTAssertEqual(defaultCenter1, defaultCenter2)
}
Expand Down
2 changes: 0 additions & 2 deletions TestFoundation/TestNotificationQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ FIXME SR-4280 timeouts in TestNSNotificationQueue tests

func test_defaultQueue() {
let defaultQueue1 = NotificationQueue.default
XCTAssertNotNil(defaultQueue1)
let defaultQueue2 = NotificationQueue.default
XCTAssertEqual(defaultQueue1, defaultQueue2)

executeInBackgroundThread() {
let defaultQueueForBackgroundThread = NotificationQueue.default
XCTAssertNotNil(defaultQueueForBackgroundThread)
XCTAssertEqual(defaultQueueForBackgroundThread, NotificationQueue.default)
XCTAssertNotEqual(defaultQueueForBackgroundThread, defaultQueue1)
}
Expand Down
2 changes: 1 addition & 1 deletion TestFoundation/TestPipe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TestPipe : XCTestCase {
let data = aPipe.fileHandleForReading.readData(ofLength: text.count)

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

// Confirm the data can be converted to a String
let convertedData = String(data: data, encoding: .utf8)
Expand Down
2 changes: 1 addition & 1 deletion TestFoundation/TestProcessInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TestProcessInfo : XCTestCase {
XCTAssertFalse(versionString.isEmpty)

let version = processInfo.operatingSystemVersion
XCTAssertNotNil(version.majorVersion != 0)
XCTAssert(version.majorVersion != 0)
}

func test_processName() {
Expand Down
2 changes: 0 additions & 2 deletions TestFoundation/TestRunLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ class TestRunLoop : XCTestCase {

func test_runLoopInit() {
let mainRunLoop = RunLoop.main
XCTAssertNotNil(mainRunLoop)
let currentRunLoop = RunLoop.current
XCTAssertNotNil(currentRunLoop)

let secondAccessOfMainLoop = RunLoop.main
XCTAssertEqual(mainRunLoop, secondAccessOfMainLoop, "fetching the main loop a second time should be equal")
Expand Down
2 changes: 0 additions & 2 deletions TestFoundation/TestThread.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class TestThread : XCTestCase {
func test_currentThread() {
let thread1 = Thread.current
let thread2 = Thread.current
XCTAssertNotNil(thread1)
XCTAssertNotNil(thread2)
XCTAssertEqual(thread1, thread2)
XCTAssertEqual(thread1, Thread.mainThread)
}
Expand Down
5 changes: 0 additions & 5 deletions TestFoundation/TestURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ class TestURL : XCTestCase {

func test_fileURLWithPath_relativeTo() {
let homeDirectory = NSHomeDirectory()
XCTAssertNotNil(homeDirectory, "Failed to find home directory")
let homeURL = URL(fileURLWithPath: homeDirectory, isDirectory: true)
XCTAssertNotNil(homeURL, "fileURLWithPath:isDirectory: failed")
XCTAssertEqual(homeDirectory, homeURL.path)

#if os(macOS)
Expand All @@ -88,14 +86,11 @@ class TestURL : XCTestCase {
#endif
// we're telling fileURLWithPath:isDirectory:relativeTo: Documents is a directory
let url1 = URL(fileURLWithFileSystemRepresentation: relativePath, isDirectory: true, relativeTo: baseURL)
XCTAssertNotNil(url1, "fileURLWithPath:isDirectory:relativeTo: failed")
// we're letting fileURLWithPath:relativeTo: determine Documents is a directory with I/O
let url2 = URL(fileURLWithPath: relativePath, relativeTo: baseURL)
XCTAssertNotNil(url2, "fileURLWithPath:relativeTo: failed")
XCTAssertEqual(url1, url2, "\(url1) was not equal to \(url2)")
// we're telling fileURLWithPath:relativeTo: Documents is a directory with a trailing slash
let url3 = URL(fileURLWithPath: relativePath + "/", relativeTo: baseURL)
XCTAssertNotNil(url3, "fileURLWithPath:relativeTo: failed")
XCTAssertEqual(url1, url3, "\(url1) was not equal to \(url3)")
}

Expand Down
1 change: 0 additions & 1 deletion TestFoundation/TestURLCredential.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class TestURLCredential : XCTestCase {

func test_construction() {
let credential = URLCredential(user: "swiftUser", password: "swiftPassword", persistence: .forSession)
XCTAssertNotNil(credential)
XCTAssertEqual(credential.user, "swiftUser")
XCTAssertEqual(credential.password, "swiftPassword")
XCTAssertEqual(credential.persistence, URLCredential.Persistence.forSession)
Expand Down
2 changes: 0 additions & 2 deletions TestFoundation/TestURLRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class TestURLRequest : XCTestCase {
func test_construction() {
let request = URLRequest(url: url)
// Match macOS Foundation responses
XCTAssertNotNil(request)
XCTAssertEqual(request.url, url)
XCTAssertEqual(request.httpMethod, "GET")
XCTAssertNil(request.allHTTPHeaderFields)
Expand All @@ -49,7 +48,6 @@ class TestURLRequest : XCTestCase {
var request = URLRequest(url: url)

//Confirm initial state matches NSURLRequest responses
XCTAssertNotNil(request)
XCTAssertEqual(request.url, url)
XCTAssertEqual(request.httpMethod, "GET")
XCTAssertNil(request.allHTTPHeaderFields)
Expand Down