Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
Equal Compare `expect` with `actual`. they are equal when: 1. Both types are same. 2. Length of map's key must be equal, each pair of (key,value) must be `Equal` to the other, except the key is in the IgnoreFields. 3. Length of array or slice must be `Equal`. Without IgnoreArrayOrder setting, each item in the array must be `Equal` one by one. 4. Each exportable fields in struct must be `Equal`. 5. Implemented IEqual method returns true. 6. Otherwise, including `Time` types, the `reflect.DeepEqual(expect, actual)` return `true`. If return error is not nil, it contains information which field and why they are not equal.
Types ¶
type IEqual ¶
type IEqual interface {
Equal(b interface{}) bool
}
If item implements IEqual interface, Equal will compare items with item.Equal.
type Option ¶
type Option struct { // Fields than in IgnoreFields will skip compare with each other. // This is useful when you compare with object which come from create api results, which auto create id, create_at, updated_at. IgnoreFields []string // ignore fields with tag, eg. `json` IgnoreByTagName string // If set true, compare ignore the items order, which means `[1, 2]` equals `[2, 1]`. // If compared items is top level, just set empty key to true. IgnoreArrayOrder map[string]bool // deep(default), or unixNano TimeEqual string // contains filtered or unexported fields }
Equal Option