Documentation
¶
Overview ¶
Package assert provides JUnit-style assertions for go testing.
Index ¶
- Variables
- func DeepEquals(target interface{}, expected, actual interface{}) error
- func Equals(target interface{}, expected, actual interface{}) error
- func False(target interface{}, condition bool) error
- func Nil(target interface{}, pointer interface{}) error
- func NotDeepEquals(target interface{}, expected, actual interface{}) error
- func NotEquals(target interface{}, expected, actual interface{}) error
- func NotNil(target interface{}, pointer interface{}) error
- func True(target interface{}, condition bool) error
Constants ¶
This section is empty.
Variables ¶
var Fail = func(target interface{}, err error) error { if t, _ := target.(*testing.T); t != nil { t.Error(err) } return err }
Fail is a pointer to a function that fails a test. It takes two arguments, the target and the error. The default implementation assumes that the target is of type *testing.T and invokes its Error() function. Reassign this function pointer if you are working with a framework other than "testing".
Functions ¶
func DeepEquals ¶
func DeepEquals(target interface{}, expected, actual interface{}) error
DeepEquals asserts that two arguments are equal, performing a deep comparison. The first argument target is to be forwarded to Fail(target interface{}, msg string) in case the assertion fails. In case of "testing", pass t *testing.T as the first argument. Implemented using reflect.DeepEqual
func Equals ¶
func Equals(target interface{}, expected, actual interface{}) error
Equals asserts that two arguments are equal. The first argument target is to be forwarded to Fail(target interface{}, msg string) in case the assertion fails. In case of "testing", pass t *testing.T as the first argument. Currently, it supports the following types of arguments: - []byte - Everything that supports ==/!=
func False ¶
False asserts that a condition is false. The first argument target is to be forwarded to Fail(target interface{}, msg string) in case the assertion fails. In case of "testing", pass t *testing.T as the first argument.
func Nil ¶
func Nil(target interface{}, pointer interface{}) error
Nil asserts that a pointer is nil. The first argument target is to be forwarded to Fail(target interface{}, msg string) in case the assertion fails. In case of "testing", pass t *testing.T as the first argument.
func NotDeepEquals ¶
func NotDeepEquals(target interface{}, expected, actual interface{}) error
NotDeepEquals asserts that two arguments are not equal, performing a deep comparison. The first argument target is to be forwarded to Fail(target interface{}, msg string) in case the assertion fails. In case of "testing", pass t *testing.T as the first argument. Implemented using reflect.DeepEqual
func NotEquals ¶
func NotEquals(target interface{}, expected, actual interface{}) error
NotEquals asserts that two arguments are not equal. The first argument target is to be forwarded to Fail(target interface{}, msg string) in case the assertion fails. In case of "testing", pass t *testing.T as the first argument. Currently, it supports the following types of arguments: - []byte - Everything that supports ==/!=
Types ¶
This section is empty.