Documentation ¶
Overview ¶
Package require includes test assertions that fail the test immediately. This is like to testify, but without a dependency.
Note: Assertions here are internal and are free to be customized to only support valid WebAssembly types, or to reduce code in tests that only require certain types.
Index ¶
- func CapturePanic(panics func()) (err error)
- func Contains(t TestingT, s, substr string, formatWithArgs ...interface{})
- func Equal(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})
- func EqualErrno(t TestingT, expected syscall.Errno, err error, formatWithArgs ...interface{})
- func EqualError(t TestingT, err error, expected string, formatWithArgs ...interface{})
- func Error(t TestingT, err error, formatWithArgs ...interface{})
- func ErrorIs(t TestingT, err, target error, formatWithArgs ...interface{})
- func False(t TestingT, actual bool, formatWithArgs ...interface{})
- func Nil(t TestingT, object interface{}, formatWithArgs ...interface{})
- func NoError(t TestingT, err error, formatWithArgs ...interface{})
- func NotEqual(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})
- func NotNil(t TestingT, object interface{}, formatWithArgs ...interface{})
- func NotSame(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})
- func Same(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})
- func True(t TestingT, actual bool, formatWithArgs ...interface{})
- func Zero(t TestingT, i interface{}, formatWithArgs ...interface{})
- type EqualTo
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CapturePanic ¶
func CapturePanic(panics func()) (err error)
CapturePanic returns an error recovered from a panic. If the panic was not an error, this converts it to one.
func Contains ¶
Contains fails if `s` does not contain `substr` using strings.Contains.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func Equal ¶
func Equal(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})
Equal fails if the actual value is not equal to the expected.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func EqualErrno ¶
EqualErrno should be used for functions that return syscall.Errno or nil.
func EqualError ¶
EqualError fails if the error is nil or its `Error()` value is not equal to the expected string.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func Error ¶
Error fails if the err is nil.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func ErrorIs ¶
ErrorIs fails if the err is nil or errors.Is fails against the expected.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func False ¶
False fails if the actual value was true.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func Nil ¶
func Nil(t TestingT, object interface{}, formatWithArgs ...interface{})
Nil fails if the object is not nil.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func NoError ¶
NoError fails if the err is not nil.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func NotEqual ¶
func NotEqual(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})
NotEqual fails if the actual value is equal to the expected.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func NotNil ¶
func NotNil(t TestingT, object interface{}, formatWithArgs ...interface{})
NotNil fails if the object is nil.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func NotSame ¶
func NotSame(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})
NotSame fails if the inputs point to the same object.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func Same ¶
func Same(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})
Same fails if the inputs don't point to the same object.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func True ¶
True fails if the actual value wasn't.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
func Zero ¶
func Zero(t TestingT, i interface{}, formatWithArgs ...interface{})
Zero fails if the actual value wasn't.
- formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.
Note: This isn't precise to numeric types, but we don't care as being more precise is more code and tests.