expectation

package
v0.0.0-...-37536b8 Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: BSD-2-Clause Imports: 7 Imported by: 2

Documentation

Overview

Package expectation provides expectation (assertion) helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(actual, expected interface{}, name string, skip int) error

Contains checks if the actual value contains expected value.

func Equal

func Equal(actual, expected interface{}, name string, skip int) error

Equal checks for the equality of contents and is tolerant of type differences.

func HasPrefix

func HasPrefix(actual, expected interface{}, name string, skip int) error

HasPrefix checks if the actual value has a prefix of expected value.

func HasSuffix

func HasSuffix(actual, expected interface{}, name string, skip int) error

HasSuffix checks if the actual value has a suffix of expected value.

func IsType

func IsType(actual, expected interface{}, name string, skip int) error

IsType checks if the actual value is of the same type as the expected value.

func NotEqual

func NotEqual(actual, expected interface{}, name string, skip int) error

NotEqual is the reverse of Equal.

func Panic

func Panic(actual, expected interface{}, name string, skip int) (ret error)

Panic checks if a function panics.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the output destination for the standard logger, which is used by gotest utilities.

Types

type Actual

type Actual struct {
	// contains filtered or unexported fields
}

Actual provides checking methods for an actual value in an expectation.

func (*Actual) Contains

func (a *Actual) Contains(expected interface{})

Contains is the fluent method for checker Contains.

func (*Actual) Equal

func (a *Actual) Equal(expected interface{})

Equal is the fluent method for checker Equal.

func (*Actual) HasPrefix

func (a *Actual) HasPrefix(expected interface{})

HasPrefix is the fluent method for checker HasPrefix.

func (*Actual) HasSuffix

func (a *Actual) HasSuffix(expected interface{})

HasSuffix is the fluent method for checker HasSuffix.

func (*Actual) IsType

func (a *Actual) IsType(expected interface{})

IsType is the fluent method for checker IsType.

func (*Actual) NotEqual

func (a *Actual) NotEqual(expected interface{})

NotEqual is the fluent method for checker NotEqual.

func (*Actual) Panic

func (a *Actual) Panic()

Panic is the fluent method for checker Panic.

func (*Actual) To

func (a *Actual) To(check Checker, expected interface{})

To is a general method for checking an expectation.

type Checker

type Checker func(actual, expected interface{}, name string, skip int) error

Checker is the type of function that checks between actual and expected value then returns an Error if the expectation fails.

type ExpectFunc

type ExpectFunc func(actual ...interface{}) *Actual

ExpectFunc is the type of function that returns an Actual object given an actual value or a name and an actual value.

func Alias

func Alias(fail FailFunc, skip ...int) ExpectFunc

Alias registers a fail function and returns an ExpectFunc. The optional skip parameter is used to skip extra function calls in the stack trace in case the ExpectFunc is further wrapped by another function.

type FailFunc

type FailFunc func(error)

FailFunc is the function type that is used to notify expectation failures.

func TFail

func TFail(fail func()) FailFunc

TFail return the FailFunc for testing.T.Fail

type T

type T interface {
	Fail()
	FailNow()
}

T is a subset of testing.T used in this package.

Jump to

Keyboard shortcuts

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