Documentation ¶
Overview ¶
Package assert provides C-like assertions for Go. For more information, see assert(3) (e.g. `man 3 assert`).
The T variants operating on *testing.T values; instead of killing the program, they call the Fatal method.
If GOTRACEBACK is set to enable coredumps, assertions will generate coredumps.
Index ¶
- Variables
- func Bool(cond bool, s ...string)
- func BoolT(t *testing.T, cond bool, s ...string)
- func Error(err error, s ...string)
- func ErrorEq(expected, actual error)
- func ErrorEqT(t *testing.T, expected, actual error)
- func ErrorT(t *testing.T, err error, s ...string)
- func NoError(err error, s ...string)
- func NoErrorT(t *testing.T, err error)
Constants ¶
This section is empty.
Variables ¶
var NoDebug bool
NoDebug can be set to true to cause all asserts to be ignored.
Functions ¶
func Bool ¶
Bool asserts that cond is false.
For example, this would replace
if x < 0 { log.Fatal("x is subzero") }
The same assertion would be
assert.Bool(x, "x is subzero")
func Error ¶
Error asserts that err is not nil, e.g. that an error has occurred.
For example,
if err == nil { log.Fatal("call to <something> should have failed") } // becomes assert.Error(err, "call to <something> should have failed")
func ErrorEq ¶
func ErrorEq(expected, actual error)
ErrorEq asserts that the actual error is the expected error.
func ErrorT ¶
ErrorT asserts that err is not nil, e.g. asserting that an error has occurred. See also NoErrorT.
Types ¶
This section is empty.