Documentation
¶
Index ¶
- func Or[T comparable](values ...T) T
- type Comparison
- func Contains(collection, item any) Comparison
- func DeepEqual[T any](x, y T, opts ...gocmp.Option) Comparison
- func Equal[T any](x, y T) Comparison
- func Len[Slice ~[]E, E any](actual Slice, expected int) Comparison
- func LenMap[Map ~map[K]V, K comparable, V any](actual Map, expected int) Comparison
- func MarshalContains(actual any, expected string) Comparison
- func MarshalMatches(actual any, expected string) Comparison
- func Regexp[RE *regexp.Regexp | ~string](regex RE, value string) Comparison
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Or ¶ added in v2.9.0
func Or[T comparable](values ...T) T
Or is an alias to stdcmp.Or in the standard library:
- It returns the leftmost argument that is not zero.
- It returns zero when all its arguments are zero.
This is here so test authors can import fewer "cmp" packages.
Types ¶
type Comparison ¶
type Comparison = gotest.Comparison
func Contains ¶
func Contains(collection, item any) Comparison
Contains succeeds if item is in collection. The collection may be a string, map, slice, or array. See gotest.tools/v3/assert/cmp.Contains. When either item or collection is a multi-line string, the failure message contains a multi-line report of the differences.
func DeepEqual ¶
func DeepEqual[T any](x, y T, opts ...gocmp.Option) Comparison
DeepEqual compares two values using github.com/google/go-cmp/cmp and succeeds if the values are equal. The comparison can be customized using comparison Options. See github.com/google/go-cmp/cmp.Option constructors and github.com/google/go-cmp/cmp/cmpopts.
func Equal ¶ added in v2.9.0
func Equal[T any](x, y T) Comparison
Equal succeeds if x == y, the same as gotest.tools/v3/assert.Equal. The type constraint makes it easier to compare against numeric literals and typed constants.
func Len ¶ added in v2.9.0
func Len[Slice ~[]E, E any](actual Slice, expected int) Comparison
Len succeeds if actual has the expected length.
func LenMap ¶ added in v2.9.0
func LenMap[Map ~map[K]V, K comparable, V any](actual Map, expected int) Comparison
LenMap succeeds if actual has the expected length.
func MarshalContains ¶
func MarshalContains(actual any, expected string) Comparison
MarshalContains converts actual to YAML and succeeds if expected is in the result.
func MarshalMatches ¶
func MarshalMatches(actual any, expected string) Comparison
MarshalMatches converts actual to YAML and compares that to expected.