assert

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareMsg

func CompareMsg(exp, act interface{}) string

func CompareMsgf

func CompareMsgf(exp, act interface{}, msg string, args ...interface{}) string

func IsFloatNear

func IsFloatNear(epsilon, expected, actual float64) bool

Types

type T

type T struct{ testing.TB }

T wraps a testing.T or a testing.B with a simple set of custom assertions.

Assertions prefixed with 'Must' will terminate the execution of the test case immediately.

Assertions that are not prefixed with 'Must' will fail the test but allow the test to continue.

func WrapTB

func WrapTB(tb testing.TB) T

func (T) Assert

func (tb T) Assert(condition bool, v ...interface{}) bool

Assert fails the test if the condition is false.

func (T) Equals

func (tb T) Equals(exp, act interface{}, v ...interface{}) bool

Equals fails the test but continues executing if exp is not equal to act using reflect.DeepEqual() and returns whether the assertion succeded. See Exact for equality comparisons using '=='.

func (T) Exact

func (tb T) Exact(exp, act interface{}, v ...interface{}) bool

Exact fails the test but continues executing if the Go language equality rules for '==' do not apply to the arguments. This is distinct from MustEqual, which performs a reflect.DeepEqual().

func (T) FloatNear

func (tb T) FloatNear(epsilon float64, expected float64, actual float64, v ...interface{}) bool

func (T) MustAssert

func (tb T) MustAssert(condition bool, v ...interface{})

MustAssert immediately fails the test if the condition is false.

func (T) MustEqual

func (tb T) MustEqual(exp, act interface{}, v ...interface{})

MustEqual immediately fails the test if exp is not equal to act based on reflect.DeepEqual(). See Exact for equality comparisons using '=='.

func (T) MustExact

func (tb T) MustExact(exp, act interface{}, v ...interface{})

MustExact immediately fails the test if the Go language equality rules for '==' do not apply to the arguments. This is distinct from MustEqual, which performs a reflect.DeepEqual().

func (T) MustFloatNear

func (tb T) MustFloatNear(epsilon float64, expected float64, actual float64, v ...interface{})

func (T) MustFloatsNear

func (tb T) MustFloatsNear(epsilon float64, expected []float64, actual []float64, v ...interface{})

func (T) MustOK

func (tb T) MustOK(err error)

func (T) MustOKAll

func (tb T) MustOKAll(errs ...interface{})

MustOKAll errors and terminates the test at the first error found in the arguments. It allows multiple return value functions to be passed in directly.

func (T) OK

func (tb T) OK(err error) bool

func (T) OKAll

func (tb T) OKAll(errs ...interface{}) bool

OKAll errors the test at the first error found in the arguments, but continues running the test. It allows multiple return value functions to be passed in directly.

Jump to

Keyboard shortcuts

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