Documentation ¶
Overview ¶
The deep package provides deep comparisons with options.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Config = NewComparer()
Config is the Comparer used by Equal.
Functions ¶
This section is empty.
Types ¶
type Comparer ¶
type Comparer struct { // CompareUnexportedFields, when true, causes unexported fields to be // compared. CompareUnexportedFields bool // FloatPrecision sets the amount of mantissa precision, in bits, used when // comparing floats. A value of zero or less uses an exact equality // comparison. FloatPrecision int // MaxDepth specifies the maximum depth below which values will be // automatically be considered equal. A value of zero or less indicates an // infinite maxmimum depth. MaxDepth int // MaxDiffs specifies the maximum number of diffs to be returned. A value of // zero or less indicates an infinite maximum amount. MaxDiffs int // NilMapsAreEmpty, when true, causes nil maps to be equal to maps with zero // elements. NilMapsAreEmpty bool // NilSlicesAreEmpty, when true, causes nil slices to be equal to slices // with zero elements. NilSlicesAreEmpty bool }
Comparer configures how comparisons are made.
func NewComparer ¶
func NewComparer() *Comparer
NewComparer returns a new Comparer with a sensible default configuration.
For the purposes of testing, NewComparer should be avoided. A Comparer with the desired options should be created manually.
func (Comparer) Equal ¶
Equal makes a comparison between two values, and returns a list of differences between them. If the values are equivalent according to the current configuration, then nil is returned.
Equal makes comparisons based on equivalency rather than equality. Values may or may not be equivalent depending on the tolerances configured by the Comparer. Generally, Equal is similar to reflect.Equal. Aside from the configurable options, there are several other differences:
- NaN is equivalent to NaN.
- Because of quirks with maps, maps containing NaN keys can be reported incorrectly.
type Diff ¶
type Diff struct {
// contains filtered or unexported fields
}
Diff represents a single unit of difference between two values.