Skip to content

Not(DeepEquals) succeeds even though go-cmp panicked #153

@lmb

Description

@lmb

The following test cases succeeds somewhat surprisingly:

func TestNotDeepEquals(t *testing.T) {
	type a struct {
		v int
	}

	v1 := a{1}
	qt.Assert(t, v1, qt.Not(qt.DeepEquals), v1)
}

Dropping the Not reveals that go-cmp actually returned an error:

        error:
          cannot handle unexported field at {testutils.a}.v:
          	"github.com/cilium/ebpf/internal/testutils".a
          consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported
        got:
          testutils.a{v:1}
        want:
          <same as "got">
        stack:
          /home/lorenz/dev/ebpf/internal/testutils/cmp_test.go:15
            qt.Assert(t, v1, qt.DeepEquals, v1)

Seems like Not treats an error from the checker which means "wasn't able to compare" the same as "not equal".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions