SuperSetOf

func SuperSetOf(expectedItems ...interface{}) TestDeep

SuperSetOf operator compares the contents of an array or a slice (or a pointer on array/slice) ignoring duplicates and without taking care of the order of items.

During a match, each expected item should match in the compared array/slice. But some items in the compared array/slice may not be expected.

td.Cmp(t, []int{1, 1, 2}, td.SuperSetOf(1))    // succeeds
td.Cmp(t, []int{1, 1, 2}, td.SuperSetOf(1, 3)) // fails, 3 is missing

See also SuperSetOf godoc.

Examples

Base example

CmpSuperSetOf shortcut

func CmpSuperSetOf(t TestingT, got interface{}, expectedItems []interface{}, args ...interface{}) bool

CmpSuperSetOf is a shortcut for:

td.Cmp(t, got, td.SuperSetOf(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 CmpSuperSetOf godoc.

Examples

Base example

T.SuperSetOf shortcut

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

SuperSetOf is a shortcut for:

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

Examples

Base example