Documentation
¶
Index ¶
- type Is
- func (is *Is) Equal(a interface{}, b interface{})
- func (is *Is) Err(e error)
- func (is *Is) False(b bool)
- func (is *Is) Msg(format string, args ...interface{}) *Is
- func (is *Is) Nil(o interface{})
- func (is *Is) NotEqual(a interface{}, b interface{})
- func (is *Is) NotErr(e error)
- func (is *Is) NotNil(o interface{})
- func (is *Is) NotZero(o interface{})
- func (is *Is) True(b bool)
- func (is *Is) Zero(o interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Is ¶
Is provides methods that leverage the existing testing capabilities found in the Go test framework. The methods provided allow for a more natural, efficient and expressive approach to writing tests. The goal is to write fewer lines of code while improving communication of intent.
func New ¶
New creates a new instance of the Is object and stores a reference to the provided testing object.
func (*Is) Equal ¶
func (is *Is) Equal(a interface{}, b interface{})
Equal performs a deep compare of the provided objects and fails if they are not equal.
Equal does not respect type differences. If the types are different and comparable (eg int32 and int64), but the values are the same, the objects are considered equal.
func (*Is) Msg ¶
Msg defines a message to print in the event of a failure. This allows you to print out additional information about a failure if it happens.
func (*Is) Nil ¶
func (is *Is) Nil(o interface{})
Nil checks the provided object to determine if it is nil.
func (*Is) NotEqual ¶
func (is *Is) NotEqual(a interface{}, b interface{})
NotEqual performs a deep compare of the provided objects and fails if they are equal.
NotEqual does not respect type differences. If the types are different and comparable (eg int32 and int64), but the values are different, the objects are considered not equal.
func (*Is) NotErr ¶
NotErr checks the provided error object to determine if an error is not present.
func (*Is) NotNil ¶
func (is *Is) NotNil(o interface{})
NotNil checks the provided object to determine if it is not nil.
func (*Is) NotZero ¶
func (is *Is) NotZero(o interface{})
NotZero checks the provided object to determine if it is not the zero value for the type of that object. The zero value is the same as what the object would contain when initialized but not assigned.
This method, for example, would be used to determine if a string is not empty, an array is not empty or a map is not empty. It could also be used to determine if a number is not 0.
In cases such as slice, map, array and chan, a nil value is treated the same as an object with len == 0
func (*Is) Zero ¶
func (is *Is) Zero(o interface{})
Zero checks the provided object to determine if it is the zero value for the type of that object. The zero value is the same as what the object would contain when initialized but not assigned.
This method, for example, would be used to determine if a string is empty, an array is empty or a map is empty. It could also be used to determine if a number is 0.
In cases such as slice, map, array and chan, a nil value is treated the same as an object with len == 0
