func NotAny(expectedItems ...interface{}) TestDeep
NotAny
operator checks that the contents of an array or a slice (or
a pointer on array/slice) does not contain any of expectedItems.
td.Cmp(t, []int{1}, td.NotAny(1, 2, 3)) // fails
td.Cmp(t, []int{5}, td.NotAny(1, 2, 3)) // succeeds
Beware that NotAny(…)
is not equivalent to Not(Any(…)
).
See also NotAny godoc.
t := &testing.T{}
got := []int{4, 5, 9, 42}
ok := td.Cmp(t, got, td.NotAny(3, 6, 8, 41, 43),
"checks %v contains no item listed in NotAny()", got)
fmt.Println(ok)
ok = td.Cmp(t, got, td.NotAny(3, 6, 8, 42, 43),
"checks %v contains no item listed in NotAny()", got)
fmt.Println(ok)
// Output:
// true
// false
func CmpNotAny(t TestingT, got interface{}, expectedItems []interface{}, args ...interface{}) bool
CmpNotAny is a shortcut for:
td.Cmp(t, got, td.NotAny(expectedItems...), 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 CmpNotAny godoc.
t := &testing.T{}
got := []int{4, 5, 9, 42}
ok := td.CmpNotAny(t, got, []interface{}{3, 6, 8, 41, 43},
"checks %v contains no item listed in NotAny()", got)
fmt.Println(ok)
ok = td.CmpNotAny(t, got, []interface{}{3, 6, 8, 42, 43},
"checks %v contains no item listed in NotAny()", got)
fmt.Println(ok)
// Output:
// true
// false
func (t *T) NotAny(got interface{}, expectedItems []interface{}, args ...interface{}) bool
NotAny
is a shortcut for:
t.Cmp(got, td.NotAny(expectedItems...), 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.NotAny godoc.
t := td.NewT(&testing.T{})
got := []int{4, 5, 9, 42}
ok := t.NotAny(got, []interface{}{3, 6, 8, 41, 43},
"checks %v contains no item listed in NotAny()", got)
fmt.Println(ok)
ok = t.NotAny(got, []interface{}{3, 6, 8, 42, 43},
"checks %v contains no item listed in NotAny()", got)
fmt.Println(ok)
// Output:
// true
// false