Documentation
¶
Index ¶
- type Matcher
- func Any[T comparable]() Matcher[T]
- func Eq[T comparable](expected T) Matcher[T]
- func Eventually[T any](expectation Matcher[T]) Matcher[T]
- func NewMatcher[T any](opts ...MatcherOption[T]) Matcher[T]
- func Produces[T any, C <-chan T](expectation Matcher[T]) Matcher[C]
- func Returns[T any, F func() T](expectation Matcher[T]) Matcher[F]
- type MatcherOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matcher ¶
func Any ¶
func Any[T comparable]() Matcher[T]
func Eq ¶
func Eq[T comparable](expected T) Matcher[T]
Example ¶
c := NewMockContext() // Would normally be NewContext(t)
Assert(c, 10, Eq(10))
Assert(c, "hello", Eq("hello"))
func Eventually ¶
Example (Chan) ¶
c := NewMockContext() // Would normally be NewContext(t)
ch := make(chan string)
go func() {
time.Sleep(500 * time.Millisecond)
ch <- "hello"
}()
Assert(c, ch, Eventually(Produces(Eq("hello"))))
Example (Func) ¶
c := NewMockContext() // Would normally be NewContext(t)
var value int64
go func() {
for i := 0; i < 5; i++ {
time.Sleep(200 * time.Millisecond)
atomic.AddInt64(&value, 1)
}
}()
Assert(c, func() int64 {
return atomic.LoadInt64(&value)
}, Eventually(Returns(Eq(int64(5)))))
func NewMatcher ¶
func NewMatcher[T any](opts ...MatcherOption[T]) Matcher[T]
type MatcherOption ¶
type MatcherOption[T any] func(m *matcher[T])
func WithExplanation ¶
func WithExplanation[T any](explanation string) MatcherOption[T]
func WithMatchFunc ¶
func WithMatchFunc[T any](fn func(actual T) error) MatcherOption[T]
Click to show internal directories.
Click to hide internal directories.