Skip to content

Implementing HTTPCookieStorage.description #1313

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 3 commits into from
Nov 24, 2017
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
4 changes: 4 additions & 0 deletions Foundation/HTTPCookieStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ open class HTTPCookieStorage: NSObject {
}
}

open override var description: String {
return "<NSHTTPCookieStorage cookies count:\(cookies?.count ?? 0)>"
}

private func createCookie(_ properties: [String: Any]) -> HTTPCookie? {
var cookieProperties: [HTTPCookiePropertyKey: Any] = [:]
for (key, value) in properties {
Expand Down
3 changes: 3 additions & 0 deletions TestFoundation/TestHTTPCookieStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class TestHTTPCookieStorage: XCTestCase {

storage.setCookie(simpleCookie)
XCTAssertEqual(storage.cookies!.count, 0)
XCTAssertEqual(storage.description, "<NSHTTPCookieStorage cookies count:0>")

let simpleCookie0 = HTTPCookie(properties: [ //no expiry date
.name: "TestCookie1",
Expand All @@ -119,6 +120,7 @@ class TestHTTPCookieStorage: XCTestCase {

storage.setCookie(simpleCookie0)
XCTAssertEqual(storage.cookies!.count, 1)
XCTAssertEqual(storage.description, "<NSHTTPCookieStorage cookies count:1>")

let simpleCookie1 = HTTPCookie(properties: [
.name: "TestCookie1",
Expand All @@ -139,6 +141,7 @@ class TestHTTPCookieStorage: XCTestCase {

storage.setCookie(simpleCookie2)
XCTAssertEqual(storage.cookies!.count, 2)
XCTAssertEqual(storage.description, "<NSHTTPCookieStorage cookies count:2>")
}

func deleteCookie(with storageType: _StorageType) {
Expand Down