require

package
v0.0.0-...-654f35c Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

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

Equal asserts that two objects are equal.

assert.Equal(t, 123, 123)

Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses). Function equality cannot be determined and will always fail.

func False

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

False asserts that the specified value is false.

assert.False(t, myBool)

func Len

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

Len asserts that the specified object has specific length. Len also fails if the object has a type that len() not accept.

assert.Len(t, mySlice, 3)

func Nil

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

Nil asserts that the specified object is nil.

assert.Nil(t, err)

func NoError

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

NoError asserts that a function returned no error (i.e. `nil`).

  actualObj, err := SomeFunction()
  if assert.NoError(t, err) {
	   assert.Equal(t, expectedObj, actualObj)
  }

func NotEmpty

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

NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either a slice or a channel with len == 0.

if assert.NotEmpty(t, obj) {
  assert.Equal(t, "two", obj[1])
}

func NotEqual

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

NotEqual asserts that the specified values are NOT equal.

assert.NotEqual(t, obj1, obj2)

Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses).

func NotNil

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

NotNil asserts that the specified object is not nil.

assert.NotNil(t, err)

func True

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

True asserts that the specified value is true.

assert.True(t, myBool)

Types

type TestingT

type TestingT interface {
	Errorf(format string, args ...interface{})
	FailNow()
}

TestingT is an interface wrapper around *testing.T

Jump to

Keyboard shortcuts

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