1 // Utility functions useful for tests
3 // SPDX-License-Identifier: GPL-3.0-or-later
4 // Copyright (C) 2021-2024 Simon Ruderich
13 "github.com/google/go-cmp/cmp"
16 func AssertEqual(t *testing.T, name string, act, exp interface{}) {
19 if !reflect.DeepEqual(act, exp) {
20 t.Errorf("%s: %s", name, cmp.Diff(exp, act))
24 func AssertErrorEqual(t *testing.T, name string, act, exp error) {
27 // Ugly but the simplest way to compare errors (including nil)
28 actStr := fmt.Sprintf("%v", act)
29 expStr := fmt.Sprintf("%v", exp)
31 t.Errorf("err = %s (%#v), want %s (%#v)",
32 actStr, act, expStr, exp)