Skip to content

Commit 53fcee7

Browse files
committed
testcase for HTTPCookieStorage.description
1 parent ce0122b commit 53fcee7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

TestFoundation/TestHTTPCookieStorage.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class TestHTTPCookieStorage: XCTestCase {
3232
("test_cookiesForURL", test_cookiesForURL),
3333
("test_cookiesForURLWithMainDocumentURL", test_cookiesForURLWithMainDocumentURL),
3434
("test_cookieInXDGSpecPath", test_cookieInXDGSpecPath),
35+
("test_descriptionCookie", test_descriptionCookie)
3536
]
3637
}
3738

@@ -90,6 +91,11 @@ class TestHTTPCookieStorage: XCTestCase {
9091
setCookiesForURLWithMainDocumentURL(with: .groupContainer("test"))
9192
}
9293

94+
func test_descriptionCookie() {
95+
descriptionCookie(with: .shared)
96+
descriptionCookie(with: .groupContainer("test"))
97+
}
98+
9399
func getStorage(for type: _StorageType) -> HTTPCookieStorage {
94100
switch type {
95101
case .shared:
@@ -246,6 +252,23 @@ class TestHTTPCookieStorage: XCTestCase {
246252
XCTAssertEqual(storage.cookies(for: url1!)!.count, 0)
247253
}
248254

255+
func descriptionCookie(with storageType: _StorageType) {
256+
let storage = getStorage(for: storageType)
257+
XCTAssertEqual(storage.description, "<NSHTTPCookieStorage cookies count:\(storage.cookies!.count)>")
258+
259+
let simpleCookie = HTTPCookie(properties: [
260+
.name: "TestCookie1",
261+
.value: "Test value @#$%^$&*99",
262+
.path: "/",
263+
.domain: "swift.org",
264+
.expires: Date(timeIntervalSince1970: Date().timeIntervalSince1970 + 1000)
265+
])!
266+
storage.setCookie(simpleCookie)
267+
XCTAssertEqual(storage.description, "<NSHTTPCookieStorage cookies count:\(storage.cookies!.count)>")
268+
storage.deleteCookie(simpleCookie)
269+
XCTAssertEqual(storage.description, "<NSHTTPCookieStorage cookies count:\(storage.cookies!.count)>")
270+
}
271+
249272
func test_cookieInXDGSpecPath() {
250273
#if !os(Android) && !DARWIN_COMPATIBILITY_TESTS
251274
//Test without setting the environment variable

0 commit comments

Comments
 (0)