assert

package
v0.0.0-...-c18a219 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(tb testing.TB, container interface{}, item interface{}, msgAndArgs ...interface{})

Contains asserts that the specified string, list(array, slice...) or map contains the specified substring or element.

assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'")
assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")

func Empty

func Empty(tb testing.TB, v interface{}, msgAndArgs ...interface{})

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

func Equal

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

Equal asserts that two objects are equal.

func Error

func Error(tb testing.TB, err error, msgAndArgs ...interface{})

Error asserts that the specified error is not nil.

func False

func False(tb testing.TB, v bool, msgAndArgs ...interface{})

False asserts that the specified value is false.

func Implement

func Implement(tb testing.TB, v, iface interface{}, msgAndArgs ...interface{})

Implement asserts that the object implements the interface type u.

Implement(t, &bytes.Buffer{}, (*io.Writer)(nil))

func Nil

func Nil(tb testing.TB, v interface{}, msgAndArgs ...interface{})

Nil asserts that the specified object is nil.

func NoError

func NoError(tb testing.TB, err error, msgAndArgs ...interface{})

NoError asserts that the specified error is nil.

func NotContains

func NotContains(tb testing.TB, container interface{}, item interface{}, msgAndArgs ...interface{})

NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the specified substring or element.

assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")

func NotEmpty

func NotEmpty(tb testing.TB, v interface{}, msgAndArgs ...interface{})

NotEmpty asserts that the specified object is not empty.

func NotEqual

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

NotEqual asserts that two objects are not equal.

func NotNil

func NotNil(tb testing.TB, v interface{}, msgAndArgs ...interface{})

NotNil asserts that the specified object is not nil.

func NotPanic

func NotPanic(tb testing.TB, f func(), msgAndArgs ...interface{})

NotPanic asserts that the code inside the specified PanicTestFunc does NOT panic.

assert.NotPanic(t, func(){
  Safe()
}, "Calling Safe() should not panic")

func Panic

func Panic(tb testing.TB, f func(), msgAndArgs ...interface{})

Panic asserts that the code inside the specified PanicTestFunc panics.

assert.Panic(t, func(){
  Fatal()
}, "Calling Fatal() should panic")

func Range

func Range(tb testing.TB, actual, start, end interface{}, msgAndArgs ...interface{})

Range asserts that the object is in range of two values.

func Same

func Same(tb testing.TB, expected, actual interface{}, msgAndArgs ...interface{})

Same asserts that two objects are same.

func True

func True(tb testing.TB, v bool, msgAndArgs ...interface{})

True asserts that the specified value is true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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