Documentation ¶
Overview ¶
Package assert provides easy assertion for your golang test cases
Index ¶
- Constants
- func DiffValues(a, b interface{}) string
- func DiffValuesDefault(a, b interface{}) string
- func Equal(t testing.TB, expect, actual interface{})
- func EqualFalse(t testing.TB, actual bool)
- func EqualSkip(t testing.TB, skip int, expect, actual interface{})
- func EqualTrue(t testing.TB, actual bool)
- func Error(t testing.TB, err error)
- func Match(t *testing.T, value string, regex interface{})
- func MatchSkip(t *testing.T, skip int, value string, regex interface{})
- func Nil(t testing.TB, value interface{})
- func NilSkip(t testing.TB, skip int, value interface{})
- func NoError(t testing.TB, err error)
- func NotEqual(t *testing.T, expect, actual interface{})
- func NotEqualSkip(t *testing.T, skip int, expect, actual interface{})
- func NotMatch(t *testing.T, value string, regex interface{})
- func NotMatchSkip(t *testing.T, skip int, value string, regex interface{})
- func NotNil(t testing.TB, value interface{})
- func NotNilSkip(t testing.TB, skip int, value interface{})
- func PanicMatches(t testing.TB, fn func(), matches interface{})
- func PanicMatchesSkip(t testing.TB, skip int, fn func(), matches interface{})
Constants ¶
const ( // AppName const AppName = "assert" // Version const Version = "0.1.3" // VersionInt const VersionInt = 0x000103 )
Variables ¶
This section is empty.
Functions ¶
func DiffValues ¶
func DiffValues(a, b interface{}) string
DiffValues compares 'a' and 'b' and return its differences as a text string with terminal escaped sequences.
func DiffValuesDefault ¶
func DiffValuesDefault(a, b interface{}) string
DiffValuesDefault compares 'a' and 'b' and return its differences as a text string with terminal escaped sequences.
func Equal ¶
Equal validates that 'actual' is equal to 'expect' and throws an error with line number
func EqualFalse ¶
EqualFalse validates that 'actual' is false
func EqualSkip ¶
EqualSkip validates that 'actual' is equal to 'expect' and throws an error with line number but the skip variable tells EqualSkip how far back on the stack to report the error. This is a building block to creating your own more complex validation functions.
func Error ¶
Error asserts that a function returned an error (i.e. not `nil`).
actualObj, err := SomeFunction() if assert.Error(t, err) { assert.Equal(t, expectedError, err) }
func Match ¶
Match validates that value matches the regex, either string or *regex and throws an error with line number
func MatchSkip ¶
MatchSkip validates that value matches the regex, either string or *regex and throws an error with line number but the skip variable tells MatchRegexSkip how far back on the stack to report the error. This is a building block to creating your own more complex validation functions.
func NoError ¶
NoError asserts that a function returned no error (i.e. `nil`).
actualObj, err := SomeFunction() if assert.NoError(t, err) { assert.Equal(t, expectedObj, actualObj) }
func NotEqualSkip ¶
NotEqualSkip validates that val1 is not equal to val2 and throws an error with line number but the skip variable tells NotEqualSkip how far back on the stack to report the error. This is a building block to creating your own more complex validation functions.
func NotMatch ¶
NotMatch validates that value matches the regex, either string or *regex and throws an error with line number
func NotMatchSkip ¶
NotMatchSkip validates that value matches the regex, either string or *regex and throws an error with line number but the skip variable tells NotMatchRegexSkip how far back on the stack to report the error. This is a building block to creating your own more complex validation functions.
func NotNilSkip ¶
NotNilSkip asserts that the specified object is not nil.
assert.NotNilSkip(t, 1, err)
func PanicMatches ¶
PanicMatches validates that the panic output of running fn matches the supplied string
func PanicMatchesSkip ¶
PanicMatchesSkip validates that the panic output of running fn matches the supplied string but the skip variable tells PanicMatchesSkip how far back on the stack to report the error. This is a building block to creating your own more complex validation functions.
Types ¶
This section is empty.