Skip to content

Fix failure in setter for NSURLComponents.port #300

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
Mar 24, 2016
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
2 changes: 1 addition & 1 deletion CoreFoundation/URL.subproj/CFURLComponents.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ CF_EXPORT Boolean _CFURLComponentsSetPort(CFURLComponentsRef components, CFNumbe
} else {
components->_portComponent = NULL;
}
components->_passwordComponentValid = true;
components->_portComponentValid = true;
__CFUnlock(&components->_lock);
return true;
}
Expand Down
11 changes: 11 additions & 0 deletions TestFoundation/TestNSURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ class TestNSURLComponents : XCTestCase {
static var allTests: [(String, TestNSURLComponents -> () throws -> Void)] {
return [
("test_string", test_string),
("test_port", test_portSetter),
]
}

Expand All @@ -435,5 +436,15 @@ class TestNSURLComponents : XCTestCase {
XCTAssertEqual(components.string!, expectedString, "should be the expected string (\(components.string!) != \(expectedString))")
}
}

func test_portSetter() {
let urlString = "http://myhost.mydomain.com"
let port: NSNumber = 8080
let expectedString = "http://myhost.mydomain.com:8080"
let url = NSURLComponents(string: urlString)
url!.port = port
let receivedString = url!.string
XCTAssertEqual(receivedString, expectedString, "expected \(expectedString) but received \(receivedString)")
}

}