test: use generics in Equal function signature

This simplifies comparing a typed value against nil. Previously it was
necessary to case nil into the proper type.
This commit is contained in:
Michael Eischer
2025-11-22 22:10:46 +01:00
parent 24d56fe2a6
commit e1a5550a27
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ func OKs(tb testing.TB, errs []error) {
// Equals fails the test if exp is not equal to act.
// msg is optional message to be printed, first param being format string and rest being arguments.
func Equals(tb testing.TB, exp, act interface{}, msgs ...string) {
func Equals[T any](tb testing.TB, exp, act T, msgs ...string) {
tb.Helper()
if !reflect.DeepEqual(exp, act) {
var msgString string