assert

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 8 Imported by: 0

README

equify

Testify-style assertions that respect your types' Equal methods.

English | 日本語

equify combines the familiar API of testify with the comparison rules of go-cmp. Use assert.Equal(t, want, got) as usual, and let a type's Equal method define equality—even when that type is nested inside a struct, slice, or map.

  • Package functions, assert.New(t) methods, and require assertions.
  • Custom messages and formatted variants such as Equalf.
  • Testify-style failure summaries with go-cmp diffs.
  • Comparison options for ignoring fields, equating empty collections, and more.
  • Other assertions delegate to testify.

Installation

Requires Go 1.23 or later.

go get github.com/k-shimada-e/equify@v0.1.1

Import the root package as assert and the require subpackage as shown below.

Quick start

Two time.Time values can represent the same instant with different internal representations. equify uses Time.Equal to compare them:

package example_test

import (
	"testing"
	"time"

	assert "github.com/k-shimada-e/equify"
	"github.com/k-shimada-e/equify/require"
)

func TestInstant(t *testing.T) {
	want := time.Unix(100, 0).UTC()
	got := want.In(time.FixedZone("offset", 3600))

	assert.Equal(t, want, got)
	assert.Equalf(t, want, got, "event %d", 42)
	assert.New(t).Equal(want, got)

	// Stop the test immediately if the assertion fails.
	require.Equal(t, want, got)
	require.New(t).Equal(want, got)
}

assert.Equal and assert.NotEqual return a bool and allow the test to continue after failure. Their require counterparts have no return value and call FailNow on failure. Call require assertions from the goroutine running the test.

Define equality for your own types

When a type has a supported Equal method, its result determines equality. In this example, users are equal when their IDs match:

package example_test

import (
	"testing"

	assert "github.com/k-shimada-e/equify"
)

type User struct {
	ID   int
	Name string
}

func (u User) Equal(other User) bool {
	return u.ID == other.ID
}

func TestUsers(t *testing.T) {
	want := User{ID: 1, Name: "Alice"}
	got := User{ID: 1, Name: "Alicia"}

	assert.Equal(t, want, got) // Passes: the IDs match.
	assert.Equal(t, []User{want}, []User{got}) // Elements use User.Equal too.
}

Method signatures must follow go-cmp's rules, such as Equal(T) bool or Equal(interface{}) bool. Arbitrarily named comparison methods are not detected. Your Equal method must be deterministic and symmetric.

Failure output

Comparing users with different IDs produces output like this. Paths, line numbers, and whitespace may vary:

Error Trace: example_test.go:42
Error:       Not equal:
             expected: example_test.User{ID:1, Name:"Alice"}
             actual  : example_test.User{ID:2, Name:"Bob"}

             Diff:
             --- Expected
             +++ Actual
               example_test.User(
             -   {ID: 1, Name: "Alice"},
             +   {ID: 2, Name: "Bob"},
               )
Messages:    user comparison

The Messages entry appears when you supply a message, for example assert.Equal(t, want, got, "user comparison").

The Not equal: summary, expected/actual values, and Diff: headings follow testify's layout. Diff lines marked - show the expected value; + shows the actual value. The diff body uses go-cmp's format.

An Equal method returns only a bool, so it cannot explain why a comparison failed. go-cmp displays the entire value at that comparison point, including fields the method does not compare. Types compared recursively without an Equal method can produce field-level diffs.

Customize comparisons

Keep existing Equal signatures and pass options through NewWithOptions or the explicit options functions:

package example_test

import (
	"testing"

	assert "github.com/k-shimada-e/equify"
	"github.com/k-shimada-e/equify/require"
	"github.com/google/go-cmp/cmp"
	"github.com/google/go-cmp/cmp/cmpopts"
)

type Record struct {
	ID    int
	Cache string
}

func TestComparisonOptions(t *testing.T) {
	// Apply options to this instance's equality assertions.
	a := assert.NewWithOptions(t, cmpopts.EquateEmpty())
	a.Equal([]int(nil), []int{})

	// Apply options to one comparison.
	want := Record{ID: 1, Cache: "old"}
	got := Record{ID: 1, Cache: "new"}
	assert.EqualWithOptions(t, want, got,
		[]cmp.Option{cmpopts.IgnoreFields(Record{}, "Cache")})

	// Configure a require instance in the same way.
	r := require.NewWithOptions(t, cmpopts.EquateEmpty())
	r.Equal([]int(nil), []int{})
}

assert.NotEqualWithOptions is also available. Instance options apply to Equal, Equalf, NotEqual, and NotEqualf; they do not affect delegated methods such as EqualValues.

Migrate from testify

Replace the imports and keep your assertion calls:

- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
+ assert "github.com/k-shimada-e/equify"
+ "github.com/k-shimada-e/equify/require"

Run your tests after migrating: the API is familiar, but equality semantics change.

APIs with new comparison behavior
API Behavior
Equal, Equalf Compare with go-cmp; show a diff on failure
NotEqual, NotEqualf Use the same comparison rules; fail when values are equal
assert.ObjectsAreEqual Use the same comparison rules; return a bool
Other public APIs Delegate to testify

Changes to the Equal/NotEqual family apply to package functions, assertion methods, and require variants.

EqualValues, NotEqualValues, EqualExportedValues, Exactly, ElementsMatch, and ObjectsAreEqualValues keep testify's internal comparisons. equify does not replace every comparison in testify with go-cmp.

Compatibility scope

This initial implementation targets testify v1.11.1 package function signatures and the assertion methods available through New(t).

  • equify's *Assertions is a different type from upstream's *Assertions. Code accepting the upstream concrete type needs adaptation.
  • Assertions created internally by testify/suite still use testify. Call equify functions or create a equify instance explicitly to use its comparisons.
  • This library does not provide replacements for testify/mock or testify/suite.
  • Failure output follows testify's layout, but diff bodies are not byte-for-byte identical.
Default comparison rules
  • Supported Equal methods define equality, including for nested values.
  • Structs without those methods include unexported fields in comparisons. Unlike plain go-cmp, equify enables access to those fields with cmp.Exporter.
  • nil and empty slices remain different. int and int64 remain different.
  • Top-level function arguments to Equal/NotEqual fail the assertion, as they do in testify.
  • Panics from invalid comparison options or comparison methods propagate to the caller.

Other behavior, including cyclic value comparisons, follows go-cmp. There is no fallback to testify's reflect.DeepEqual when options are omitted.

Development

Dependency versions are pinned in go.mod and go.sum.

go mod download
go test ./...
go vet ./...

forward.go and require/forward.go are generated wrappers around the pinned testify version. Do not edit them manually. After changing that dependency, regenerate and validate:

go generate ./...
go test ./...
go vet ./...

Tests cover custom and nested Equal methods, time.Time, comparison options, testify-style failure summaries, caller locations, and require stopping on failure.

License

MIT License, the same license used by testify. Failure-summary formatting is adapted from testify; its copyright notice is retained in the license file. Dependencies retain their respective licenses.

Documentation

Overview

Package assert provides testify-compatible assertions with go-cmp equality.

Code generated by go generate; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var AnError = upstream.AnError

Functions

func CallerInfo

func CallerInfo() []string

func Condition

func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool

func Conditionf

func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool

func Contains

func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool

func Containsf

func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool

func DirExists

func DirExists(t TestingT, path string, msgAndArgs ...interface{}) bool

func DirExistsf

func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool

func ElementsMatch

func ElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool)

func ElementsMatchf

func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool

func Empty

func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool

func Emptyf

func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool

func Equal

func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

Equal compares values using go-cmp, including supported Equal methods.

func EqualError

func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool

func EqualErrorf

func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool

func EqualExportedValues

func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

func EqualExportedValuesf

func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func EqualValues

func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

func EqualValuesf

func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func EqualWithOptions

func EqualWithOptions(t TestingT, expected, actual interface{}, opts []cmp.Option, msgAndArgs ...interface{}) bool

EqualWithOptions accepts explicit go-cmp options without changing Equal's signature.

func Equalf

func Equalf(t TestingT, expected, actual interface{}, msg string, args ...interface{}) bool

func Error

func Error(t TestingT, err error, msgAndArgs ...interface{}) bool

func ErrorAs

func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) bool

func ErrorAsf

func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool

func ErrorContains

func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) bool

func ErrorContainsf

func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) bool

func ErrorIs

func ErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool

func ErrorIsf

func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool

func Errorf

func Errorf(t TestingT, err error, msg string, args ...interface{}) bool

func Eventually

func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool

func EventuallyWithT

func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool

func EventuallyWithTf

func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool

func Eventuallyf

func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool

func Exactly

func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

func Exactlyf

func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func Fail

func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool

func FailNow

func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool

func FailNowf

func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool

func Failf

func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool

func False

func False(t TestingT, value bool, msgAndArgs ...interface{}) bool

func Falsef

func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool

func FileExists

func FileExists(t TestingT, path string, msgAndArgs ...interface{}) bool

func FileExistsf

func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool

func Greater

func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool

func GreaterOrEqual

func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool

func GreaterOrEqualf

func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool

func Greaterf

func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool

func HTTPBody

func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string

func HTTPBodyContains

func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool

func HTTPBodyContainsf

func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool

func HTTPBodyNotContains

func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool

func HTTPBodyNotContainsf

func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool

func HTTPError

func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool

func HTTPErrorf

func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool

func HTTPRedirect

func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool

func HTTPRedirectf

func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool

func HTTPStatusCode

func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool

func HTTPStatusCodef

func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool

func HTTPSuccess

func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool

func HTTPSuccessf

func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool

func Implements

func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool

func Implementsf

func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool

func InDelta

func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool

func InDeltaMapValues

func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool

func InDeltaMapValuesf

func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool

func InDeltaSlice

func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool

func InDeltaSlicef

func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool

func InDeltaf

func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool

func InEpsilon

func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool

func InEpsilonSlice

func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool

func InEpsilonSlicef

func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool

func InEpsilonf

func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool

func IsDecreasing

func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool

func IsDecreasingf

func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool

func IsIncreasing

func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool

func IsIncreasingf

func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool

func IsNonDecreasing

func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool

func IsNonDecreasingf

func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool

func IsNonIncreasing

func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool

func IsNonIncreasingf

func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool

func IsNotType

func IsNotType(t TestingT, theType, object interface{}, msgAndArgs ...interface{}) bool

func IsNotTypef

func IsNotTypef(t TestingT, theType interface{}, object interface{}, msg string, args ...interface{}) bool

func IsType

func IsType(t TestingT, expectedType, object interface{}, msgAndArgs ...interface{}) bool

func IsTypef

func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool

func JSONEq

func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool

func JSONEqf

func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool

func Len

func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool

func Lenf

func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool

func Less

func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool

func LessOrEqual

func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool

func LessOrEqualf

func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool

func Lessf

func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool

func Negative

func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool

func Negativef

func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool

func Never

func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool

func Neverf

func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool

func Nil

func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool

func Nilf

func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool

func NoDirExists

func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) bool

func NoDirExistsf

func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool

func NoError

func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool

func NoErrorf

func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool

func NoFileExists

func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) bool

func NoFileExistsf

func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool

func NotContains

func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool

func NotContainsf

func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool

func NotElementsMatch

func NotElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool)

func NotElementsMatchf

func NotElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool

func NotEmpty

func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool

func NotEmptyf

func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool

func NotEqual

func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

func NotEqualValues

func NotEqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

func NotEqualValuesf

func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func NotEqualWithOptions

func NotEqualWithOptions(t TestingT, expected, actual interface{}, opts []cmp.Option, msgAndArgs ...interface{}) bool

func NotEqualf

func NotEqualf(t TestingT, expected, actual interface{}, msg string, args ...interface{}) bool

func NotErrorAs

func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) bool

func NotErrorAsf

func NotErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool

func NotErrorIs

func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool

func NotErrorIsf

func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool

func NotImplements

func NotImplements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool

func NotImplementsf

func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool

func NotNil

func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool

func NotNilf

func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool

func NotPanics

func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool

func NotPanicsf

func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool

func NotRegexp

func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool

func NotRegexpf

func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool

func NotSame

func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

func NotSamef

func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func NotSubset

func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool)

func NotSubsetf

func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool

func NotZero

func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool

func NotZerof

func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool

func ObjectsAreEqual

func ObjectsAreEqual(expected, actual interface{}) bool

func ObjectsAreEqualValues

func ObjectsAreEqualValues(expected, actual interface{}) bool

func ObjectsExportedFieldsAreEqual

func ObjectsExportedFieldsAreEqual(expected, actual interface{}) bool

func Panics

func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool

func PanicsWithError

func PanicsWithError(t TestingT, errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool

func PanicsWithErrorf

func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, args ...interface{}) bool

func PanicsWithValue

func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool

func PanicsWithValuef

func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool

func Panicsf

func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool

func Positive

func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool

func Positivef

func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool

func Regexp

func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool

func Regexpf

func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool

func Same

func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

func Samef

func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func Subset

func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool)

func Subsetf

func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool

func True

func True(t TestingT, value bool, msgAndArgs ...interface{}) bool

func Truef

func Truef(t TestingT, value bool, msg string, args ...interface{}) bool

func WithinDuration

func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool

func WithinDurationf

func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool

func WithinRange

func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{}) bool

func WithinRangef

func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool

func YAMLEq

func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool

func YAMLEqf

func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool

func Zero

func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool

func Zerof

func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool

Types

type Assertions

type Assertions struct {
	*testify.Assertions
	// contains filtered or unexported fields
}

Assertions preserves testify's methods and overrides Equal and NotEqual.

func New

func New(t TestingT) *Assertions

func NewWithOptions

func NewWithOptions(t TestingT, opts ...cmp.Option) *Assertions

NewWithOptions applies comparison options to this instance's equality methods. Other methods retain testify's behavior.

func (*Assertions) Equal

func (a *Assertions) Equal(expected, actual interface{}, msgAndArgs ...interface{}) bool

func (*Assertions) Equalf

func (a *Assertions) Equalf(expected, actual interface{}, msg string, args ...interface{}) bool

func (*Assertions) NotEqual

func (a *Assertions) NotEqual(expected, actual interface{}, msgAndArgs ...interface{}) bool

func (*Assertions) NotEqualf

func (a *Assertions) NotEqualf(expected, actual interface{}, msg string, args ...interface{}) bool

type BoolAssertionFunc

type BoolAssertionFunc = upstream.BoolAssertionFunc

type CollectT

type CollectT = upstream.CollectT

type CompareType

type CompareType = upstream.CompareType

type Comparison

type Comparison = upstream.Comparison

type ComparisonAssertionFunc

type ComparisonAssertionFunc = upstream.ComparisonAssertionFunc

type ErrorAssertionFunc

type ErrorAssertionFunc = upstream.ErrorAssertionFunc

type PanicAssertionFunc

type PanicAssertionFunc = upstream.PanicAssertionFunc

type PanicTestFunc

type PanicTestFunc = upstream.PanicTestFunc

type TestingT

type TestingT = upstream.TestingT

type ValueAssertionFunc

type ValueAssertionFunc = upstream.ValueAssertionFunc

Directories

Path Synopsis
internal
gen command
Command gen forwards the public API of the pinned testify dependency.
Command gen forwards the public API of the pinned testify dependency.
Code generated by go generate; DO NOT EDIT.
Code generated by go generate; DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL