func Ptr(val any) TestDeep
Ptr is a smuggler operator. It takes the address of data and compares it to val.
val depends on data type. For example, if the compared data is an
*int
, one can have:
num := 12
td.Cmp(t, &num, td.Ptr(12)) // succeeds
as well as an other operator:
num := 3
td.Cmp(t, &num, td.Ptr(td.Between(3, 4)))
TypeBehind
method returns the reflect.Type
of a pointer on val,
except if val is a TestDeep operator. In this case, it delegates
TypeBehind()
to the operator and returns the reflect.Type
of a
pointer on the returned value (if non-nil
of course).
See also Ptr godoc.
func CmpPtr(t TestingT, got, val any, args ...any) bool
CmpPtr is a shortcut for:
td.Cmp(t, got, td.Ptr(val), args...)
See above for details.
Returns true if the test is OK, false if it fails.
If t is a *T
then its Config field is inherited.
args… are optional and allow to name the test. This name is
used in case of failure to qualify the test. If len(args) > 1
and
the first item of args is a string
and contains a ‘%’ rune
then
fmt.Fprintf
is used to compose the name, else args are passed to
fmt.Fprint
. Do not forget it is the name of the test, not the
reason of a potential failure.
See also CmpPtr godoc.
func (t *T) Ptr(got, val any, args ...any) bool
Ptr is a shortcut for:
t.Cmp(got, td.Ptr(val), args...)
See above for details.
Returns true if the test is OK, false if it fails.
args… are optional and allow to name the test. This name is
used in case of failure to qualify the test. If len(args) > 1
and
the first item of args is a string
and contains a ‘%’ rune
then
fmt.Fprintf
is used to compose the name, else args are passed to
fmt.Fprint
. Do not forget it is the name of the test, not the
reason of a potential failure.
See also T.Ptr godoc.