Back to godoc.org

Package opt

v2.2.0+incompatible
Latest Go to latest
Published: Nov 11, 2018 | License: Apache-2.0 | Module: gotest.tools

Overview

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

Index

Package Files

func DurationWithThreshold

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

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

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

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

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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier