Documentation ¶
Index ¶
- Constants
- func Count() int
- type Assertions
- func (a *Assertions) All(target interface{}, predicate Predicate, userMessageComponents ...interface{})
- func (a *Assertions) AllOfFloat(target []float64, predicate PredicateOfFloat, ...)
- func (a *Assertions) AllOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{})
- func (a *Assertions) AllOfString(target []string, predicate PredicateOfString, ...)
- func (a *Assertions) Any(target interface{}, predicate Predicate, userMessageComponents ...interface{})
- func (a *Assertions) AnyOfFloat(target []float64, predicate PredicateOfFloat, ...)
- func (a *Assertions) AnyOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{})
- func (a *Assertions) AnyOfString(target []string, predicate PredicateOfString, ...)
- func (a *Assertions) Contains(substring, corpus string, userMessageComponents ...interface{})
- func (a *Assertions) Empty(collection interface{}, userMessageComponents ...interface{})
- func (a *Assertions) EndTimeout()
- func (a *Assertions) Equal(expected interface{}, actual interface{}, userMessageComponents ...interface{})
- func (a *Assertions) FailNow(userMessageComponents ...interface{})
- func (a *Assertions) False(object bool, userMessageComponents ...interface{})
- func (a *Assertions) FileExists(filepath string, userMessageComponents ...interface{})
- func (a *Assertions) InDelta(f1, f2, delta float64, userMessageComponents ...interface{})
- func (a *Assertions) InTimeDelta(t1, t2 time.Time, delta time.Duration, userMessageComponents ...interface{})
- func (a *Assertions) Len(collection interface{}, length int, userMessageComponents ...interface{})
- func (a *Assertions) Nil(object interface{}, userMessageComponents ...interface{})
- func (a *Assertions) NonFatal() *Optional
- func (a *Assertions) None(target interface{}, predicate Predicate, userMessageComponents ...interface{})
- func (a *Assertions) NoneOfFloat(target []float64, predicate PredicateOfFloat, ...)
- func (a *Assertions) NoneOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{})
- func (a *Assertions) NoneOfString(target []string, predicate PredicateOfString, ...)
- func (a *Assertions) NotEmpty(collection interface{}, userMessageComponents ...interface{})
- func (a *Assertions) NotEqual(expected interface{}, actual interface{}, userMessageComponents ...interface{})
- func (a *Assertions) NotNil(object interface{}, userMessageComponents ...interface{})
- func (a *Assertions) NotZero(value interface{}, userMessageComponents ...interface{})
- func (a *Assertions) StartTimeout(timeout time.Duration, userMessageComponents ...interface{})
- func (a *Assertions) True(object bool, userMessageComponents ...interface{})
- func (a *Assertions) Zero(value interface{}, userMessageComponents ...interface{})
- type Optional
- func (o *Optional) All(target interface{}, predicate Predicate, userMessageComponents ...interface{}) bool
- func (o *Optional) AllOfFloat(target []float64, predicate PredicateOfFloat, ...) bool
- func (o *Optional) AllOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{}) bool
- func (o *Optional) AllOfString(target []string, predicate PredicateOfString, ...) bool
- func (o *Optional) Any(target interface{}, predicate Predicate, userMessageComponents ...interface{}) bool
- func (o *Optional) AnyOfFloat(target []float64, predicate PredicateOfFloat, ...) bool
- func (o *Optional) AnyOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{}) bool
- func (o *Optional) AnyOfString(target []string, predicate PredicateOfString, ...) bool
- func (o *Optional) Contains(substring, corpus string, userMessageComponents ...interface{}) bool
- func (o *Optional) Empty(collection interface{}, userMessageComponents ...interface{}) bool
- func (o *Optional) Equal(expected interface{}, actual interface{}, userMessageComponents ...interface{}) bool
- func (o *Optional) Fail(userMessageComponents ...interface{})
- func (o *Optional) False(object bool, userMessageComponents ...interface{}) bool
- func (o *Optional) FileExists(filepath string, userMessageComponents ...interface{}) bool
- func (o *Optional) InDelta(a, b, delta float64, userMessageComponents ...interface{}) bool
- func (o *Optional) InTimeDelta(a, b time.Time, delta time.Duration, userMessageComponents ...interface{}) bool
- func (o *Optional) Len(collection interface{}, length int, userMessageComponents ...interface{}) bool
- func (o *Optional) Nil(object interface{}, userMessageComponents ...interface{}) bool
- func (o *Optional) None(target interface{}, predicate Predicate, userMessageComponents ...interface{}) bool
- func (o *Optional) NoneOfFloat(target []float64, predicate PredicateOfFloat, ...) bool
- func (o *Optional) NoneOfInt(target []int, predicate PredicateOfInt, userMessageComponents ...interface{}) bool
- func (o *Optional) NoneOfString(target []string, predicate PredicateOfString, ...) bool
- func (o *Optional) NotEmpty(collection interface{}, userMessageComponents ...interface{}) bool
- func (o *Optional) NotEqual(expected interface{}, actual interface{}, userMessageComponents ...interface{}) bool
- func (o *Optional) NotNil(object interface{}, userMessageComponents ...interface{}) bool
- func (o *Optional) NotZero(value interface{}, userMessageComponents ...interface{}) bool
- func (o *Optional) True(object bool, userMessageComponents ...interface{}) bool
- func (o *Optional) Zero(value interface{}, userMessageComponents ...interface{}) bool
- type Predicate
- type PredicateOfFloat
- type PredicateOfInt
- type PredicateOfString
- type PredicateOfTime
Constants ¶
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 ¶
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 (*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) 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) FileExists ¶
FileExists asserts that a file exists on disk at a given filepath.
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) 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) NotEqual ¶
func (o *Optional) NotEqual(expected interface{}, actual interface{}, userMessageComponents ...interface{}) bool
NotEqual asserts that two objects are not equal.
type Predicate ¶
type Predicate func(item interface{}) bool
Predicate is a func that returns a bool.
type PredicateOfFloat ¶
PredicateOfFloat is a func that takes a float64 and returns a bool.
type PredicateOfInt ¶
PredicateOfInt is a func that takes an int and returns a bool.
type PredicateOfString ¶
PredicateOfString is a func that takes a string and returns a bool.
type PredicateOfTime ¶
PredicateOfTime is a func that takes a time.Time and returns a bool.