*testdeep.T
import (
"testing"
"github.com/maxatome/go-testdeep"
)
func TestMyFunc(tt *testing.T) {
t := testdeep.NewT(tt)
t.Cmp(MyFunc(), 12)
}
*testdeep.T
func TestMyFunc(tt *testing.T) {
t := testdeep.NewT(tt).UseEqual().RootName("RECORD")
...
}
func (t *T) BeLax(enable ...bool) *T
func (t *T) FailureIsFatal(enable ...bool) *T
func (t *T) RootName(rootName string) *T
func (t *T) UseEqual(enable ...bool) *T
*testdeep.T
import (
"testing"
"github.com/maxatome/go-testdeep"
)
func TestMyFunc(tt *testing.T) {
t := testdeep.NewT(tt).UseEqual()
// Compares MyFunc() result against a fixed value
t.Cmp(MyFunc(), 128, "MyFunc() result is 128")
// Compares MyFunc() result using the Between Testdeep operator
t.Cmp(MyFunc(), testdeep.Between(100, 199),
"MyFunc() result is between 100 and 199")
}
func (t *T) Cmp(got, expected interface{}, args ...interface{}) bool
func (t *T) CmpError(got error, args ...interface{}) bool
func (t *T) CmpLax(got interface{}, expected interface{}, args ...interface{}) bool
(in fact the shortcut of Lax
operator)func (t *T) CmpNoError(got error, args ...interface{}) bool
func (t *T) CmpNotPanic(fn func(), args ...interface{}) bool
func (t *T) CmpPanic(fn func(), expected interface{}, args ...interface{}) bool
func (t *T) False(got interface{}, args ...interface{}) bool
func (t *T) Not(got interface{}, notExpected interface{}, args ...interface{}) bool
(in fact the shortcut of Not
operator)func (t *T) RunT(name string, f func(t *T)) bool
func (t *T) True(got interface{}, args ...interface{}) bool
CmpDeeply()
method is now replaced by
Cmp()
,
but it is still available for backward compatibility purpose.
*testdeep.T
import (
"testing"
"github.com/maxatome/go-testdeep"
)
func TestMyFunc(tt *testing.T) {
t := testdeep.NewT(tt).UseEqual()
t.Between(MyFunc(), 100, 199, testdeep.BoundsInIn,
"MyFunc() result is between 100 and 199")
}
For each of these methods, it is always a shortcut on
T.Cmp()
and
the correponding Testdeep operator:
T.HasPrefix(got, expected, …) ⇒ T.Cmp(t, got, HasPrefix(expected), …)
^-------^ ^-------^
+-------------------------------------------+
Excluding Lax
operator for which the
shortcut method stays CmpLax
.
Each shortcut method is described in the corresponding operator page. See operators list.