Equal asserts that [got] and [want] are Equal. Under the hood, this uses the go-cmp package in combination with protocmp and also supplies a diff, in case the messages to do not match. Note: By default the option protocmp.Transform() will be used. This can cause problems with structs that are NOT p
(t TestingT, want T, got T, opts ...cmp.Option)
| 51 | // Note: By default the option protocmp.Transform() will be used. This can cause problems with structs that are NOT |
| 52 | // protobuf messages and contain un-exported fields. In this case, [CompareAllUnexported] can be used instead. |
| 53 | func Equal[T any](t TestingT, want T, got T, opts ...cmp.Option) bool { |
| 54 | tt, ok := t.(*testing.T) |
| 55 | if ok { |
| 56 | tt.Helper() |
| 57 | } |
| 58 | |
| 59 | opts = append(opts, protocmp.Transform()) |
| 60 | |
| 61 | if cmp.Equal(got, want, opts...) { |
| 62 | return true |
| 63 | } |
| 64 | |
| 65 | return assert.Fail(t, "Not equal, but expected to be equal", cmp.Diff(got, want, opts...)) |
| 66 | } |
| 67 | |
| 68 | // NotEqual is similar to [Equal], but inverse. |
| 69 | func NotEqual[T any](t TestingT, want T, got T, opts ...cmp.Option) bool { |
no outgoing calls