MCPcopy
hub / github.com/kopia/kopia / EnsureType

Function EnsureType

internal/testutil/testutil.go:165–176  ·  view source on GitHub ↗

EnsureType asserts that v of type E.

(tb testing.TB, v any)

Source from the content-addressed store, hash-verified

163
164// EnsureType asserts that v of type E.
165func EnsureType[E any](tb testing.TB, v any) E {
166 tb.Helper()
167
168 var e E
169
170 // require.IsType would not elide the forced type assertion
171 e, ok := v.(E)
172
173 require.Truef(tb, ok, "%T is not of type %T", v, e)
174
175 return e
176}

Calls 1

HelperMethod · 0.80