EnsureType asserts that v of type E.
(tb testing.TB, v any)
| 163 | |
| 164 | // EnsureType asserts that v of type E. |
| 165 | func 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 | } |