From 13d628aa3756b0e4762f2347c63e74d15dddae79 Mon Sep 17 00:00:00 2001 From: Jonathan Flat Date: Tue, 5 Nov 2024 19:35:54 -0800 Subject: [PATCH] Fix Dictionary ordering in TestHTTPURLResponse.test_NSCoding --- Tests/Foundation/TestHTTPURLResponse.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/Foundation/TestHTTPURLResponse.swift b/Tests/Foundation/TestHTTPURLResponse.swift index 08e27279f5..b06ed20eb2 100644 --- a/Tests/Foundation/TestHTTPURLResponse.swift +++ b/Tests/Foundation/TestHTTPURLResponse.swift @@ -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.")