All

func All(expectedValues ...interface{}) TestDeep

All operator compares data against several expected values. During a match, all of them have to match to succeed. Consider it as a “AND” logical operator.

td.Cmp(t, "foobar", td.All(
  td.Len(6),
  td.HasPrefix("fo"),
  td.HasSuffix("ar"),
)) // succeeds

TypeBehind method can return a non-nil reflect.Type if all items known non-interface types are equal, or if only interface types are found (mostly issued from Isa()) and they are equal.

See also All godoc.

Examples

Base example

CmpAll shortcut

func CmpAll(t TestingT, got interface{}, expectedValues []interface{}, args ...interface{}) bool

CmpAll is a shortcut for:

td.Cmp(t, got, td.All(expectedValues...), 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 CmpAll godoc.

Examples

Base example

T.All shortcut

func (t *T) All(got interface{}, expectedValues []interface{}, args ...interface{}) bool

All is a shortcut for:

t.Cmp(got, td.All(expectedValues...), 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.All godoc.

Examples

Base example