Documentation
¶
Index ¶
- type Annotated
- type Ascending
- type Assertion
- type DeepEqual
- type Descending
- type Empty
- type Equal
- type ErrorIs
- type Eventually
- type Failed
- type False
- type Greater
- type GreaterOrEq
- type Implemented
- type InDelta
- type InList
- type InMap
- type Len
- type Less
- type LessOrEq
- type Negative
- type Nil
- type NilPtr
- type NoError
- type NoPanic
- type NonEmpty
- type NonNil
- type NonNilPtr
- type Not
- type NotDeepEqual
- type NotEqual
- type NotZero
- type OfType
- type Panic
- type Passed
- type Positive
- type Prefix
- type Same
- type Substring
- type Suffix
- type True
- type Zero
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ascending ¶
Ascending asserts that the given list is sorted in ascending order (each item is less or equal to the next item).
type Assertion ¶
type Assertion interface {
// String presents a readable version of the condition.
String() string
// Check runs the assertion.
// This returns an error if the context is canceled or the assertion fails.
Check(ctx context.Context) error
}
Assertion assertions are deferred as objects, to allow for Go-generics type-safe assertions, and to make user-provided assertions fit in easily.
type DeepEqual ¶
type DeepEqual[V any] struct { Expected V Got V }
DeepEqual runs a deep-equal assertion
type Descending ¶
Descending asserts that the given list is sorted in descending order (each item is greater or equal to the next item).
func (Descending[V]) String ¶
func (d Descending[V]) String() string
type Equal ¶
type Equal[V comparable] struct { Expected V Got V }
Equal runs a shallow-equal assertion
type Eventually ¶
Eventually runs a function repeatedly until it succeeds or the context is done.
func (Eventually) String ¶
func (e Eventually) String() string
type Failed ¶
type Failed struct{}
Failed is a pseudo-assertion that always fails, for placeholder usage.
type GreaterOrEq ¶
func (GreaterOrEq[V]) String ¶
func (g GreaterOrEq[V]) String() string
type Implemented ¶
Implemented asserts that the given value implements the given interface.
func (Implemented[T]) String ¶
func (s Implemented[T]) String() string
type InDelta ¶
type InDelta[V constraints.Number] struct { A V B V Delta V }
InDelta asserts that the given values are within the given delta. The delta bound is inclusive. The delta must be positive. If the delta is zero, the values must be equal.
type InList ¶
type InList[V comparable] struct { List []V Item V }
InList asserts that V is contained in the list
type InMap ¶
type InMap[K comparable, V any] struct { Key K Map map[K]V }
InMap asserts that the Key is present in Map
type Nil ¶
type Nil struct {
V any
}
Nil asserts that the given value is nil, including interface values that contain nil pointers.
type NoPanic ¶
type NoPanic struct {
Fn func()
}
NoPanic asserts that the given function does not panic.
type NonEmpty ¶
type NonEmpty[V any] struct { List []V }
NonEmpty asserts that the given list is not empty.
type NonNil ¶
type NonNil struct {
V any
}
NonNil asserts that the given value is not nil, including interface values that contain nil pointers.
type NonNilPtr ¶
type NonNilPtr[V any] struct { P *V }
NonNilPtr asserts that the given pointer is not nil.
type Not ¶
type Not struct {
Inner Assertion
}
Not asserts that the given assertion fails. For better readability and error reporting, use the assertion-specific inverse assertions instead.
type NotDeepEqual ¶
type NotDeepEqual[V any] struct { Unexpected V Got V }
NotDeepEqual runs a deep-not-equal assertion
func (NotDeepEqual[V]) String ¶
func (s NotDeepEqual[V]) String() string
type NotEqual ¶
type NotEqual[V comparable] struct { Unexpected V Got V }
NotEqual runs a shallow-not-equal assertion
type NotZero ¶
type NotZero[V comparable] struct { V V }
type OfType ¶
OfType asserts that the given value is of the given type. The reflect type of T is compared to the reflect type of the given value.
type Passed ¶
type Passed struct{}
Passed is a pseudo-assertion that always passes, for placeholder usage.
type Same ¶
type Same[V any] struct { Expected *V Got *V }
Same asserts that the pointers are pointing to the same thing.