Skip to content

assert.Equal and similar output should be explicit about type inequality #322

@bombela

Description

@bombela

In assert.Equal(t, a, b) if a and b do not have the same type, the test will fail, but the output will be the same as a value equality test failure.

It is confusing, because on complex equality assertion, ones might not realize the problem is different type, not unequal values.

Consider this example:

type struct Foo { V int }
type Foos []Foo
assert.Equal(t, Foos{{1}, {2}}, Foos{{1}, {2})

compared to:

assert.Equal(t, Foos{{1}, {2}}, []Foo{{1}, {2})

The second case will fail with a "not equal" message.

Instead, assert.Equal and similar should output an explicit message about type inequality.

cc @abhinav @prashantv @breerly

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