Functions
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) boolfunc CmpError(t TestingT, got error, args ...any) boolfunc CmpFalse(t TestingT, got any, args ...any) boolfunc CmpLax(t TestingT, got, expected any, args ...any) bool(in fact the shortcut ofLaxoperator)func CmpNoError(t TestingT, got error, args ...any) boolfunc CmpNot(t TestingT, got, notExpected any, args ...any) bool(in fact the shortcut ofNotoperator)func CmpNotPanic(t TestingT, fn func(), args ...any) boolfunc CmpPanic(t TestingT, fn func(), expectedPanic any, args ...any) boolfunc CmpTrue(t TestingT, got any, args ...any) boolfunc EqDeeply(got, expected any) boolfunc EqDeeplyError(got, expected any) error
CmpDeeply()
is now replaced by
Cmp(), but it
is still available for backward compatibility purpose.
Main shortcut functions
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.