import (
"testing"
"github.com/maxatome/go-testdeep/td"
)
func TestMyFunc(t *testing.T) {
// Compares MyFunc() result against a fixed value
td.Cmp(t, MyFunc(), 128, "MyFunc() result is 128")
// Compares MyFunc() result using the Between Testdeep operator
td.Cmp(t, MyFunc(), td.Between(100, 199),
"MyFunc() result is between 100 and 199")
}
func Cmp(t TestingT, got, expected any, args ...any) bool
func CmpError(t TestingT, got error, args ...any) bool
func CmpFalse(t TestingT, got any, args ...any) bool
func CmpLax(t TestingT, got, expected any, args ...any) bool
(in fact the shortcut of Lax
operator)func CmpNoError(t TestingT, got error, args ...any) bool
func CmpNot(t TestingT, got, notExpected any, args ...any) bool
(in fact the shortcut of Not
operator)func CmpNotPanic(t TestingT, fn func(), args ...any) bool
func CmpPanic(t TestingT, fn func(), expectedPanic any, args ...any) bool
func CmpTrue(t TestingT, got any, args ...any) bool
func EqDeeply(got, expected any) bool
func EqDeeplyError(got, expected any) error
CmpDeeply()
is now replaced by
Cmp()
, but it
is still available for backward compatibility purpose.
import (
"testing"
"github.com/maxatome/go-testdeep/td"
)
func TestMyFunc(t *testing.T) {
td.CmpBetween(t, MyFunc(), 100, 199, td.BoundsInIn,
"MyFunc() result is between 100 and 199")
}
For each of these functions, it is always a shortcut on
Cmp()
and
the correponding Testdeep operator:
CmpHasPrefix(t, got, expected, …) ⇒ Cmp(t, got, HasPrefix(expected), …)
^-------^ ^-------^
+--------------------------------------------+
Each shortcut method is described in the corresponding operator page. See operators list.