Skip to content

NSError: add a test for bridging an NSDictionary containing an NSError to a Dictionary containing an Error. #1619

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 1 commit into from
Jul 2, 2018
Merged
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
9 changes: 9 additions & 0 deletions TestFoundation/TestNSError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TestNSError : XCTestCase {
return [
("test_LocalizedError_errorDescription", test_LocalizedError_errorDescription),
("test_NSErrorAsError_localizedDescription", test_NSErrorAsError_localizedDescription),
("test_NSError_inDictionary", test_NSError_inDictionary),
("test_CustomNSError_domain", test_CustomNSError_domain),
("test_CustomNSError_userInfo", test_CustomNSError_userInfo),
("test_CustomNSError_errorCode", test_CustomNSError_errorCode),
Expand All @@ -39,6 +40,14 @@ class TestNSError : XCTestCase {
let error = nsError as Error
XCTAssertEqual(error.localizedDescription, "Localized!")
}

func test_NSError_inDictionary() {
let error = NSError(domain: "domain", code: 42, userInfo: nil)
let nsdictionary = ["error": error] as NSDictionary
let dictionary = nsdictionary as? Dictionary<String, Error>
XCTAssertNotNil(dictionary)
XCTAssertEqual(error, dictionary?["error"] as NSError?)
}

func test_CustomNSError_domain() {
let name = testBundleName()
Expand Down