Skip to content

Hash implementation does not match Equals implementation #139

Description

@fabianfett

The hash implementation does not match the equals implementation.

See this test case

@Test func hashMatchesEqualityForDifferentOrder() {
let fields1: HTTPFields = [
.acceptEncoding: "br",
.acceptEncoding: "gzip",
.accept: "*/*",
]
// Fields with differently named fields in a different order are equal, since the
// relative order of same-named fields is preserved.
let fields2: HTTPFields = [
.acceptEncoding: "br",
.accept: "*/*",
.acceptEncoding: "gzip",
]
#expect(fields1 == fields2)
// Equal values must therefore hash equally.
withKnownIssue("HTTPFields.hash(into:) is order sensitive while == is not") {
#expect(fields1.hashValue == fields2.hashValue)
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions