Documentation
¶
Overview ¶
Package assertion is the implementation detail of package assert. One can use API to create a customized assert function with this package
Index ¶
- func Assert(t *testing.T, expr interface{}, trigger *Trigger)
- func AssertEqual(t *testing.T, v1, v2 interface{}, trigger *Trigger)
- func AssertNilError(t *testing.T, result []interface{}, trigger *Trigger)
- func AssertNonNilError(t *testing.T, result []interface{}, trigger *Trigger)
- func AssertNotEqual(t *testing.T, v1, v2 interface{}, trigger *Trigger)
- func ParseArgs(name string, skip int, argIndex []int) (args []string, filename string, line int, err error)
- func TriggerAssert(t *testing.T, name string, skip int, argIndex []int, k FalseKind)
- type FalseKind
- type Trigger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
Assert tests expr and call `t.Fatalf` to terminate test case if expr is false-equivalent value.
func AssertEqual ¶
AssertEqual uses `reflect.DeepEqual` to test v1 and v2 equality.
func AssertNilError ¶
AssertNilError expects a function return a nil error. Otherwise, it will terminate the test case using `t.Fatalf`.
func AssertNonNilError ¶
AssertNonNilError expects a function return a non-nil error. Otherwise, it will terminate the test case using `t.Fatalf`.
func AssertNotEqual ¶
AssertNotEqual uses `reflect.DeepEqual` to test v1 and v2 equality.
func ParseArgs ¶
func ParseArgs(name string, skip int, argIndex []int) (args []string, filename string, line int, err error)
ParseArgs parses caller's source code, finds out the right call expression by name and returns the argument source code.
Skip is the stack frame calling an assert function. If skip is 0, the stack frame for ParseArgs is selected. In most cases, caller should set skip to 1 to skip ParseArgs itself.
Types ¶
type FalseKind ¶
type FalseKind int
FalseKind is the kind of a false-equivalent value.
Valid kinds for all false-equivalent values.
func ParseFalseKind ¶
func ParseFalseKind(expr interface{}) FalseKind
ParseFalseKind checks expr value and return false when expr is `false`, 0, `nil` and empty string. Otherwise, return true.