|author||Joe Tsai <firstname.lastname@example.org>||Thu Aug 03 10:35:09 2017 -0700|
|committer||GitHub <email@example.com>||Thu Aug 03 10:35:09 2017 -0700|
Refactor option evaluation logic (#32) The previous implementation of options had a single "option" type that was used to represent either an Ignore, Comparer, or Transformer and all of the filters relevant to each of them. We refactor this logic by creating a new type to represent each of the fundamental options and filtering options. Construction of filtered options is now as simple as wrapping the input option with the appropriate filter type. Evaluation of filters now takes a top-down two-step approach where 1. We start with the set of all options, and recursively apply the filters to create the "applicable" set S. 2. We apply the set S. Both steps are represented as the filter and apply methods on each of the core options. This approach has the following advantages: * It is faster because the same filter that was applied to multiple options now only needs to execute once. * It more closely matches the documented algorithm in cmp.Equal. * It allows for easier extension of the API to add new fundamental option types.
This package is intended to be a more powerful and safer alternative to
reflect.DeepEqual for comparing whether two values are semantically equal.
The primary features of
When the default behavior of equality does not suit the needs of the test, custom equality functions can override the equality operation. For example, an equality function may report floats as equal so long as they are within some tolerance of each other.
Types that have an
Equal method may use that method to determine equality. This allows package authors to determine the equality operation for the types that they define.
If no custom equality functions are used and no
Equal method is defined, equality is determined by recursively comparing the primitive kinds on both values, much like
reflect.DeepEqual, unexported fields are not compared by default; they result in panics unless suppressed by using an
Ignore option (see
cmpopts.IgnoreUnexported) or explictly compared using the
See the GoDoc documentation for more information.
This is not an official Google product.
go get -u github.com/google/go-cmp/cmp
BSD - See LICENSE file