Skip to content

Commit 48556cc

Browse files
mbvreddyparkera
authored andcommitted
Add implementation for NSURL copy() (#382)
check for isEqual in testcase instead of identical operator
1 parent 3aa3eea commit 48556cc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Foundation/NSURL.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ public class NSURLQueryItem : NSObject, NSSecureCoding, NSCopying {
783783
}
784784

785785
public func copy(with zone: NSZone? = nil) -> AnyObject {
786-
NSUnimplemented()
786+
return self
787787
}
788788

789789
public static func supportsSecureCoding() -> Bool {

TestFoundation/TestNSURL.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class TestNSURL : XCTestCase {
6060
// TODO: these tests fail on linux, more investigation is needed
6161
("test_fileURLWithPath", test_fileURLWithPath),
6262
("test_fileURLWithPath_isDirectory", test_fileURLWithPath_isDirectory),
63-
("test_URLByResolvingSymlinksInPath", test_URLByResolvingSymlinksInPath)
63+
("test_URLByResolvingSymlinksInPath", test_URLByResolvingSymlinksInPath),
64+
("test_copy", test_copy)
6465
]
6566
}
6667

@@ -447,6 +448,16 @@ class TestNSURL : XCTestCase {
447448
XCTFail()
448449
}
449450
}
451+
452+
func test_copy() {
453+
let url = NSURL(string: "https://www.swift.org")
454+
let urlCopy = url!.copy() as! NSURL
455+
XCTAssertTrue(url!.isEqual(urlCopy))
456+
457+
let queryItem = NSURLQueryItem(name: "id", value: "23")
458+
let queryItemCopy = queryItem.copy() as! NSURLQueryItem
459+
XCTAssertTrue(queryItem.isEqual(queryItemCopy))
460+
}
450461
}
451462

452463
class TestNSURLComponents : XCTestCase {

0 commit comments

Comments
 (0)