Skip to content

Support Custom Equality and Diff in Assert and Require #1616

Open
@nathanjsweet

Description

@nathanjsweet

Description

Update assert to compare data structures that are isomorphically equal (such as a Tree, Trie, etc) to one another, but not equal by value or reference.

Proposed solution

Define an Equal and Diff interface that structures can implement that the require/assert package will check on equality assertion (e.g. require.Equal(t, expected, actual)) rather than using DeepEqual.

Use case

Currently, the Cilium codebase uses a require.Truef as a workaround, calling into a custom Equals method and a custom Diff method.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions