func Tag(tag string, expectedValue any) TestDeep
Tag is a smuggler operator. It only allows to name expectedValue,
which can be an operator or a value. The data is then compared
against expectedValue as if Tag was never called. It is only useful
as JSON
operator parameter, to name placeholders. See JSON
operator for more details.
td.Cmp(t, gotValue,
td.JSON(`{"fullname": $name, "age": $age, "gender": $gender}`,
td.Tag("name", td.HasPrefix("Foo")), // matches $name
td.Tag("age", td.Between(41, 43)), // matches $age
td.Tag("gender", "male"))) // matches $gender
TypeBehind
method is delegated to expectedValue one if
expectedValue is a TestDeep operator, otherwise it returns the
type of expectedValue (or nil
if it is originally untyped nil
).
See also Tag godoc.