akshayjshah / attest

Type-safe assertion helpers for Go
https://pkg.go.dev/go.akshayshah.org/attest
MIT License
15 stars 2 forks source link

add attest.NotEqual #5

Closed komuw closed 2 years ago

komuw commented 2 years ago

currently you have to do attest.True(t, a!=b) which does not work for all types. eg;

type foo struct{ Name []string }

the following works;

attest.Equal(t, foo{Name: []string{"a"}}, foo{Name: []string{"a"}})

whereas the following fails to compile(invalid operation: foo{…} != foo{…} (struct containing []string cannot be compared));

attest.True(t, foo{Name: []string{"a"}} != foo{Name: []string{"b"}})

That's why I think we need a NotEqual so that we can write;`

attest.NotEqual(t, foo{Name: []string{"a"}}, foo{Name: []string{"b"}})
akshayjshah commented 2 years ago

Makes sense to me! I'll add this later tonight.