gotest.tools: gotest.tools/assert/opt Index | Files

package opt

import "gotest.tools/assert/opt"

Package opt provides common go-cmp.Options for use with assert.DeepEqual.

Index

Package Files

opt.go

func DurationWithThreshold Uses

func DurationWithThreshold(threshold time.Duration) gocmp.Option

DurationWithThreshold returns a gocmp.Comparer for comparing time.Duration. The Comparer returns true if the difference between the two Duration values is within the threshold and neither value is zero.

func PathDebug Uses

func PathDebug(path gocmp.Path) bool

PathDebug is a gocmp.FilerPath filter that always returns false. It prints each path it receives. It can be used to debug path matching problems.

func PathField Uses

func PathField(structType interface{}, field string) func(gocmp.Path) bool

PathField is a gocmp.FilerPath filter that matches a struct field by name. PathField will match every instance of the field in a recursive or nested structure.

func PathString Uses

func PathString(specs ...string) func(path gocmp.Path) bool

PathString is a gocmp.FilterPath filter that returns true when path.String() matches any of the specs.

The path spec is a dot separated string where each segment is a field name. Slices, Arrays, and Maps are always matched against every element in the sequence. gocmp.Indirect, gocmp.Transform, and gocmp.TypeAssertion are always ignored.

Note: this path filter is not type safe. Incorrect paths will be silently ignored. Consider using a type safe path filter for more complex paths.

func TimeWithThreshold Uses

func TimeWithThreshold(threshold time.Duration) gocmp.Option

TimeWithThreshold returns a gocmp.Comparer for comparing time.Time. The Comparer returns true if the difference between the two Time values is within the threshold and neither value is zero.

Package opt imports 5 packages (graph). Updated 2018-08-04. Refresh now. Tools for package owners.