assert

package module
v0.0.0-...-17f7c07 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: MIT Imports: 11 Imported by: 0

README

go-assert

This project has been deprecated.

Please use go-sdk instead.

Documentation

Index

Constants

View Source
const (
	// RED is the ansi escape code fragment for red.
	RED = "31"
	// BLUE is the ansi escape code fragment for blue.
	BLUE = "94"
	// GREEN is the ansi escape code fragment for green.
	GREEN = "32"
	// YELLOW is the ansi escape code fragment for yellow.
	YELLOW = "33"
	// WHITE is the ansi escape code fragment for white.
	WHITE = "37"
	// GRAY is the ansi escape code fragment for gray.
	GRAY = "90"

	// EMPTY is a constant for the empty (0 length) string.
	EMPTY = ""
)

Variables

This section is empty.

Functions

func Count

func Count() int

Count returns the total number of assertions.

Types

type Assertions

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

Assertions is the main entry point for using the assertions library.

func Empty

func Empty() *Assertions

Empty returns an empty assertions class; useful when you want to apply assertions w/o hooking into the testing framework.

func New

func New(t *testing.T) *Assertions

New returns a new instance of `Assertions`.

func (*Assertions) All

func (a *Assertions) All(target interface{}, predicate Predicate, userMessageComponents ...interface{})

All applies a predicate.

func (*Assertions) AllOfFloat

func (a *Assertions) AllOfFloat(target []float64, predicate PredicateOfFloat, userMessageComponents ...interface{})

AllOfFloat applies a predicate.

func (*Assertions) AllOfInt

func (a *Assertions) AllOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{})

AllOfInt applies a predicate.

func (*Assertions) AllOfString

func (a *Assertions) AllOfString(target []string, predicate PredicateOfString, userMessageComponents ...interface{})

AllOfString applies a predicate.

func (*Assertions) Any

func (a *Assertions) Any(target interface{}, predicate Predicate, userMessageComponents ...interface{})

Any applies a predicate.

func (*Assertions) AnyOfFloat

func (a *Assertions) AnyOfFloat(target []float64, predicate PredicateOfFloat, userMessageComponents ...interface{})

AnyOfFloat applies a predicate.

func (*Assertions) AnyOfInt

func (a *Assertions) AnyOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{})

AnyOfInt applies a predicate.

func (*Assertions) AnyOfString

func (a *Assertions) AnyOfString(target []string, predicate PredicateOfString, userMessageComponents ...interface{})

AnyOfString applies a predicate.

func (*Assertions) Contains

func (a *Assertions) Contains(substring, corpus string, userMessageComponents ...interface{})

Contains asserts that a substring is present in a corpus.

func (*Assertions) Empty

func (a *Assertions) Empty(collection interface{}, userMessageComponents ...interface{})

Empty asserts that a collection is empty.

func (*Assertions) EndTimeout

func (a *Assertions) EndTimeout()

EndTimeout marks a timed block as complete.

func (*Assertions) Equal

func (a *Assertions) Equal(expected interface{}, actual interface{}, userMessageComponents ...interface{})

Equal asserts that two objects are deeply equal.

func (*Assertions) FailNow

func (a *Assertions) FailNow(userMessageComponents ...interface{})

FailNow forces a test failure (useful for debugging).

func (*Assertions) False

func (a *Assertions) False(object bool, userMessageComponents ...interface{})

False asserts a boolean is false.

func (*Assertions) FileExists

func (a *Assertions) FileExists(filepath string, userMessageComponents ...interface{})

FileExists asserts that a file exists at a given filepath on disk.

func (*Assertions) InDelta

func (a *Assertions) InDelta(f1, f2, delta float64, userMessageComponents ...interface{})

InDelta asserts that two floats are within a delta.

func (*Assertions) InTimeDelta

func (a *Assertions) InTimeDelta(t1, t2 time.Time, delta time.Duration, userMessageComponents ...interface{})

InTimeDelta asserts that times t1 and t2 are within a delta.

func (*Assertions) Len

func (a *Assertions) Len(collection interface{}, length int, userMessageComponents ...interface{})

Len asserts that a collection has a given length.

func (*Assertions) Nil

func (a *Assertions) Nil(object interface{}, userMessageComponents ...interface{})

Nil asserts that a reference is nil.

func (*Assertions) NonFatal

func (a *Assertions) NonFatal() *Optional

NonFatal transitions the assertion into a `NonFatal` assertion; that is, one that will not cause the test to abort if it fails. NonFatal assertions are useful when you want to check many properties during a test, but only on an informational basis.

func (*Assertions) None

func (a *Assertions) None(target interface{}, predicate Predicate, userMessageComponents ...interface{})

None applies a predicate.

func (*Assertions) NoneOfFloat

func (a *Assertions) NoneOfFloat(target []float64, predicate PredicateOfFloat, userMessageComponents ...interface{})

NoneOfFloat applies a predicate.

func (*Assertions) NoneOfInt

func (a *Assertions) NoneOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{})

NoneOfInt applies a predicate.

func (*Assertions) NoneOfString

func (a *Assertions) NoneOfString(target []string, predicate PredicateOfString, userMessageComponents ...interface{})

NoneOfString applies a predicate.

func (*Assertions) NotEmpty

func (a *Assertions) NotEmpty(collection interface{}, userMessageComponents ...interface{})

NotEmpty asserts that a collection is not empty.

func (*Assertions) NotEqual

func (a *Assertions) NotEqual(expected interface{}, actual interface{}, userMessageComponents ...interface{})

NotEqual asserts that two objects are not deeply equal.

func (*Assertions) NotNil

func (a *Assertions) NotNil(object interface{}, userMessageComponents ...interface{})

NotNil asserts that a reference is not nil.

func (*Assertions) NotZero

func (a *Assertions) NotZero(value interface{}, userMessageComponents ...interface{})

NotZero asserts that a value is not equal to it's default value.

func (*Assertions) StartTimeout

func (a *Assertions) StartTimeout(timeout time.Duration, userMessageComponents ...interface{})

StartTimeout starts a timed block.

func (*Assertions) True

func (a *Assertions) True(object bool, userMessageComponents ...interface{})

True asserts a boolean is true.

func (*Assertions) Zero

func (a *Assertions) Zero(value interface{}, userMessageComponents ...interface{})

Zero asserts that a value is equal to it's default value.

type Optional

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

Optional is an assertion type that does not stop a test if an assertion fails, simply outputs the error.

func (*Optional) All

func (o *Optional) All(target interface{}, predicate Predicate, userMessageComponents ...interface{}) bool

All applies a predicate.

func (*Optional) AllOfFloat

func (o *Optional) AllOfFloat(target []float64, predicate PredicateOfFloat, userMessageComponents ...interface{}) bool

AllOfFloat applies a predicate.

func (*Optional) AllOfInt

func (o *Optional) AllOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{}) bool

AllOfInt applies a predicate.

func (*Optional) AllOfString

func (o *Optional) AllOfString(target []string, predicate PredicateOfString, userMessageComponents ...interface{}) bool

AllOfString applies a predicate.

func (*Optional) Any

func (o *Optional) Any(target interface{}, predicate Predicate, userMessageComponents ...interface{}) bool

Any applies a predicate.

func (*Optional) AnyOfFloat

func (o *Optional) AnyOfFloat(target []float64, predicate PredicateOfFloat, userMessageComponents ...interface{}) bool

AnyOfFloat applies a predicate.

func (*Optional) AnyOfInt

func (o *Optional) AnyOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{}) bool

AnyOfInt applies a predicate.

func (*Optional) AnyOfString

func (o *Optional) AnyOfString(target []string, predicate PredicateOfString, userMessageComponents ...interface{}) bool

AnyOfString applies a predicate.

func (*Optional) Contains

func (o *Optional) Contains(substring, corpus string, userMessageComponents ...interface{}) bool

Contains checks if a substring is present in a corpus.

func (*Optional) Empty

func (o *Optional) Empty(collection interface{}, userMessageComponents ...interface{}) bool

Empty asserts that a collection is empty.

func (*Optional) Equal

func (o *Optional) Equal(expected interface{}, actual interface{}, userMessageComponents ...interface{}) bool

Equal asserts that two objects are equal.

func (*Optional) Fail

func (o *Optional) Fail(userMessageComponents ...interface{})

Fail manually injects a failure.

func (*Optional) False

func (o *Optional) False(object bool, userMessageComponents ...interface{}) bool

False asserts that a bool is false.

func (*Optional) FileExists

func (o *Optional) FileExists(filepath string, userMessageComponents ...interface{}) bool

FileExists asserts that a file exists on disk at a given filepath.

func (*Optional) InDelta

func (o *Optional) InDelta(a, b, delta float64, userMessageComponents ...interface{}) bool

InDelta returns if two float64s are separated by a given delta.

func (*Optional) InTimeDelta

func (o *Optional) InTimeDelta(a, b time.Time, delta time.Duration, userMessageComponents ...interface{}) bool

InTimeDelta returns if two times are separated by a given delta.

func (*Optional) Len

func (o *Optional) Len(collection interface{}, length int, userMessageComponents ...interface{}) bool

Len asserts that the collection has a specified length.

func (*Optional) Nil

func (o *Optional) Nil(object interface{}, userMessageComponents ...interface{}) bool

Nil asserts the object is nil.

func (*Optional) None

func (o *Optional) None(target interface{}, predicate Predicate, userMessageComponents ...interface{}) bool

None applies a predicate.

func (*Optional) NoneOfFloat

func (o *Optional) NoneOfFloat(target []float64, predicate PredicateOfFloat, userMessageComponents ...interface{}) bool

NoneOfFloat applies a predicate.

func (*Optional) NoneOfInt

func (o *Optional) NoneOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{}) bool

NoneOfInt applies a predicate.

func (*Optional) NoneOfString

func (o *Optional) NoneOfString(target []string, predicate PredicateOfString, userMessageComponents ...interface{}) bool

NoneOfString applies a predicate.

func (*Optional) NotEmpty

func (o *Optional) NotEmpty(collection interface{}, userMessageComponents ...interface{}) bool

NotEmpty asserts that a collection is not empty.

func (*Optional) NotEqual

func (o *Optional) NotEqual(expected interface{}, actual interface{}, userMessageComponents ...interface{}) bool

NotEqual asserts that two objects are not equal.

func (*Optional) NotNil

func (o *Optional) NotNil(object interface{}, userMessageComponents ...interface{}) bool

NotNil asserts the object is not nil.

func (*Optional) NotZero

func (o *Optional) NotZero(value interface{}, userMessageComponents ...interface{}) bool

NotZero asserts that a value is not the default value.

func (*Optional) True

func (o *Optional) True(object bool, userMessageComponents ...interface{}) bool

True asserts that a bool is false.

func (*Optional) Zero

func (o *Optional) Zero(value interface{}, userMessageComponents ...interface{}) bool

Zero asserts that a value is the default value.

type Predicate

type Predicate func(item interface{}) bool

Predicate is a func that returns a bool.

type PredicateOfFloat

type PredicateOfFloat func(item float64) bool

PredicateOfFloat is a func that takes a float64 and returns a bool.

type PredicateOfInt

type PredicateOfInt func(item int) bool

PredicateOfInt is a func that takes an int and returns a bool.

type PredicateOfString

type PredicateOfString func(item string) bool

PredicateOfString is a func that takes a string and returns a bool.

type PredicateOfTime

type PredicateOfTime func(item time.Time) bool

PredicateOfTime is a func that takes a time.Time and returns a bool.

Jump to

Keyboard shortcuts

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