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 interface{}, args ...interface{}) bool
func CmpError(t TestingT, got error, args ...interface{}) bool
func CmpFalse(t TestingT, got interface{}, args ...interface{}) bool
func CmpLax(t TestingT, got, expected interface{}, args ...interface{}) bool
(in fact the shortcut of Lax
operator)func CmpNoError(t TestingT, got error, args ...interface{}) bool
func CmpNot(t TestingT, got, notExpected interface{}, args ...interface{}) bool
(in fact the shortcut of Not
operator)func CmpNotPanic(t TestingT, fn func(), args ...interface{}) bool
func CmpPanic(t TestingT, fn func(), expectedPanic interface{}, args ...interface{}) bool
func CmpTrue(t TestingT, got interface{}, args ...interface{}) bool
func EqDeeply(got, expected interface{}) bool
func EqDeeplyError(got, expected interface{}) 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.