func Lte(maxExpectedValue interface{}) TestDeep
Lte
operator checks that data is lesser or equal than
maxExpectedValue. maxExpectedValue can be any numeric or
time.Time
(or assignable) value. maxExpectedValue must be the
same kind as the compared value if numeric, and the same type if
time.Time
(or assignable).
TypeBehind method returns the reflect.Type
of maxExpectedValue.
See also Lte godoc.
t := &testing.T{}
got := 156
ok := Cmp(t, got, Lte(156), "checks %v is ≤ 156", got)
fmt.Println(ok)
ok = Cmp(t, got, Lte(157), "checks %v is ≤ 157", got)
fmt.Println(ok)
ok = Cmp(t, got, Lte(155), "checks %v is ≤ 155", got)
fmt.Println(ok)
// Output:
// true
// true
// false
t := &testing.T{}
got := "abc"
ok := Cmp(t, got, Lte("abc"), `checks "%v" is ≤ "abc"`, got)
fmt.Println(ok)
ok = Cmp(t, got, Lte("abd"), `checks "%v" is ≤ "abd"`, got)
fmt.Println(ok)
ok = Cmp(t, got, Lte("abb"), `checks "%v" is ≤ "abb"`, got)
fmt.Println(ok)
// Output:
// true
// true
// false
func CmpLte(t TestingT, got interface{}, maxExpectedValue interface{}, args ...interface{}) bool
CmpLte is a shortcut for:
Cmp(t, got, Lte(maxExpectedValue), 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 CmpLte godoc.
t := &testing.T{}
got := 156
ok := CmpLte(t, got, 156, "checks %v is ≤ 156", got)
fmt.Println(ok)
ok = CmpLte(t, got, 157, "checks %v is ≤ 157", got)
fmt.Println(ok)
ok = CmpLte(t, got, 155, "checks %v is ≤ 155", got)
fmt.Println(ok)
// Output:
// true
// true
// false
t := &testing.T{}
got := "abc"
ok := CmpLte(t, got, "abc", `checks "%v" is ≤ "abc"`, got)
fmt.Println(ok)
ok = CmpLte(t, got, "abd", `checks "%v" is ≤ "abd"`, got)
fmt.Println(ok)
ok = CmpLte(t, got, "abb", `checks "%v" is ≤ "abb"`, got)
fmt.Println(ok)
// Output:
// true
// true
// false
func (t *T) Lte(got interface{}, maxExpectedValue interface{}, args ...interface{}) bool
Lte
is a shortcut for:
t.Cmp(got, Lte(maxExpectedValue), 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.Lte godoc.
t := NewT(&testing.T{})
got := 156
ok := t.Lte(got, 156, "checks %v is ≤ 156", got)
fmt.Println(ok)
ok = t.Lte(got, 157, "checks %v is ≤ 157", got)
fmt.Println(ok)
ok = t.Lte(got, 155, "checks %v is ≤ 155", got)
fmt.Println(ok)
// Output:
// true
// true
// false
t := NewT(&testing.T{})
got := "abc"
ok := t.Lte(got, "abc", `checks "%v" is ≤ "abc"`, got)
fmt.Println(ok)
ok = t.Lte(got, "abd", `checks "%v" is ≤ "abd"`, got)
fmt.Println(ok)
ok = t.Lte(got, "abb", `checks "%v" is ≤ "abb"`, got)
fmt.Println(ok)
// Output:
// true
// true
// false