Skip to content

Commit

Permalink
Merge pull request #5133 from jrflat/httpurlresponse-coding-test
Browse files Browse the repository at this point in the history
Fix Dictionary ordering in TestHTTPURLResponse.test_NSCoding
  • Loading branch information
rintaro authored Nov 6, 2024
2 parents f812a85 + 13d628a commit cb8377e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Tests/Foundation/TestHTTPURLResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ class TestHTTPURLResponse: XCTestCase {

//On macOS unarchived Archived then unarchived `URLResponse` is not equal.
XCTAssertEqual(responseA.statusCode, responseB.statusCode, "Archived then unarchived http url response must be equal.")
XCTAssertEqual(Array(responseA.allHeaderFields.keys), Array(responseB.allHeaderFields.keys), "Archived then unarchived http url response must be equal.")
// Dictionary ordering is unpredictable after encoding/decoding because every Dictionary instance has its own hash table salt. Compare Sets of the keys instead.
XCTAssertEqual(Set(responseA.allHeaderFields.keys), Set(responseB.allHeaderFields.keys), "Archived then unarchived http url response must be equal.")

for key in responseA.allHeaderFields.keys {
XCTAssertEqual(responseA.allHeaderFields[key] as? String, responseB.allHeaderFields[key] as? String, "Archived then unarchived http url response must be equal.")
Expand Down

0 comments on commit cb8377e

Please sign in to comment.