Between

func Between(from interface{}, to interface{}, bounds ...BoundsKind) TestDeep

Between operator checks that data is between from and to. from and to can be any numeric, string or time.Time (or assignable) value. from and to must be the same kind as the compared value if numeric, and the same type if string or time.Time (or assignable). bounds allows to specify whether bounds are included or not:

If bounds is missing, it defaults to BoundsInIn.

tc.Cmp(t, 17, td.Between(17, 20))               // succeeds, BoundsInIn by default
tc.Cmp(t, 17, td.Between(10, 17, BoundsInOut))  // fails
tc.Cmp(t, 17, td.Between(10, 17, BoundsOutIn))  // succeeds
tc.Cmp(t, 17, td.Between(17, 20, BoundsOutOut)) // fails

TypeBehind method returns the reflect.Type of from (same as the to one.)

See also Between godoc.

Examples

Int example
String example

CmpBetween shortcut

func CmpBetween(t TestingT, got interface{}, from interface{}, to interface{}, bounds BoundsKind, args ...interface{}) bool

CmpBetween is a shortcut for:

td.Cmp(t, got, td.Between(from, to, bounds), args...)

See above for details.

Between() optional parameter bounds is here mandatory. td.BoundsInIn value should be passed to mimic its absence in original Between() call.

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 CmpBetween godoc.

Examples

Int example
String example

T.Between shortcut

func (t *T) Between(got interface{}, from interface{}, to interface{}, bounds BoundsKind, args ...interface{}) bool

Between is a shortcut for:

t.Cmp(got, td.Between(from, to, bounds), args...)

See above for details.

Between() optional parameter bounds is here mandatory. td.BoundsInIn value should be passed to mimic its absence in original Between() call.

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.Between godoc.

Examples

Int example
String example