mirror of
https://github.com/restic/restic.git
synced 2026-02-03 04:20:45 -05:00
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:
parent
24d56fe2a6
commit
e1a5550a27
4 changed files with 4 additions and 4 deletions
|
|
@ -29,7 +29,7 @@ func TestParse(t *testing.T) {
|
|||
u, err := location.Parse(registry, path)
|
||||
test.OK(t, err)
|
||||
test.Equals(t, "local", u.Scheme)
|
||||
test.Equals(t, &testConfig{loc: path}, u.Config)
|
||||
test.Equals(t, any(&testConfig{loc: path}), u.Config)
|
||||
}
|
||||
|
||||
func TestParseFallback(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func TestDefaultLoad(t *testing.T) {
|
|||
|
||||
return rd, nil
|
||||
}, func(ird io.Reader) error {
|
||||
rtest.Equals(t, rd, ird)
|
||||
rtest.Equals(t, io.Reader(rd), ird)
|
||||
return nil
|
||||
})
|
||||
rtest.OK(t, err)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ func TestRawInputOutput(t *testing.T) {
|
|||
defer cancel()
|
||||
rtest.Equals(t, input, term.InputRaw())
|
||||
rtest.Equals(t, false, term.InputIsTerminal())
|
||||
rtest.Equals(t, &output, term.OutputRaw())
|
||||
rtest.Equals(t, io.Writer(&output), term.OutputRaw())
|
||||
rtest.Equals(t, false, term.OutputIsTerminal())
|
||||
rtest.Equals(t, false, term.CanUpdateStatus())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue