assert

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 10 Imported by: 0

README

A Go package providing a set of assertion functions.

Documentation

Overview

Package assert provides a set of assertion functions.

Index

Constants

View Source
const (
	// Print a Go-syntax representation of the value.
	GoSyntax uint = 1 << iota

	// Pretty-printing of the value.
	Pretty
)

Formatting can be controlled with these flags.

Variables

This section is empty.

Functions

func Equal

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

Equal asserts that two objects are equal.

assert.Equal(t, 123, 123)

Function equality cannot be determined and will always fail.

func Fail

func Fail(
	t testing.TB,
	failureMessage string,
	callback func(formatter *tablewriter.Table),
	msgAndArgs ...interface{},
) bool

Fail reports a failure

func False

func False(t *testing.T, value bool, msgAndArgs ...interface{}) bool

False asserts that the specified value is false.

assert.False(t, myBool)

func Implements

func Implements(t *testing.T, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool

Implements asserts that an object is implemented by the specified interface.

assert.Implements(t, (*MyInterface)(nil), new(MyObject))

func Nil

func Nil(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool

Nil asserts that the specified object is nil.

assert.Nil(t, err)

func NotEqual

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

NotEqual asserts that the specified values are NOT equal.

assert.NotEqual(t, obj1, obj2)

Function equality cannot be determined and will always fail.

func NotNil

func NotNil(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool

NotNil asserts that the specified object is not nil.

assert.NotNil(t, err)

func ParseMsgAndArgs

func ParseMsgAndArgs(args ...interface{}) (msgAndArgs []interface{}, format uint)

func StackTrace

func StackTrace(skip int) []string

StackTrace

func True

func True(t *testing.T, value bool, msgAndArgs ...interface{}) bool

True asserts that the specified value is true.

assert.True(t, myBool)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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