Documentation ¶
Overview ¶
Package th provides basic test helpers.
Index ¶
- func DoConcurrently(ff ...func())
- func DoConcurrentlyN(n int, f func(i int))
- func ExpectDrainedChan[A any](t *testing.T, ch <-chan A)
- func ExpectError(t *testing.T, err error, message string)
- func ExpectHang(t *testing.T, waitFor time.Duration, f func())
- func ExpectMap[K, V comparable](t *testing.T, actual map[K]V, expected map[K]V)
- func ExpectNeverClosedChan[A any](t *testing.T, ch <-chan A, waitFor time.Duration)
- func ExpectNoError(t *testing.T, err error)
- func ExpectNotHang(t *testing.T, waitFor time.Duration, f func())
- func ExpectNotPanic(t *testing.T, f func())
- func ExpectSlice[A comparable](t *testing.T, actual []A, expected []A)
- func ExpectSorted[T ordered](t *testing.T, arr []T)
- func ExpectUnsorted[T ordered](t *testing.T, arr []T)
- func ExpectValue[A comparable](t *testing.T, actual A, expected A)
- func ExpectValueGTE[A number](t *testing.T, actual A, expected A)
- func ExpectValueInDelta[A number](t *testing.T, actual A, expected A, delta A)
- func ExpectValueLTE[A number](t *testing.T, actual A, expected A)
- func FromRange(start, end int) <-chan int
- func FromSlice[A any](slice []A) <-chan A
- func Name(args ...any) string
- func Send[T any](ch chan<- T, items ...T)
- func Sort[A ordered](s []A)
- func TestBothOrderings(t *testing.T, f func(t *testing.T, ord bool))
- func ToSlice[A any](in <-chan A) []A
- type ConcurrencyMonitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoConcurrently ¶
func DoConcurrently(ff ...func())
func DoConcurrentlyN ¶
func ExpectDrainedChan ¶
func ExpectMap ¶ added in v0.2.0
func ExpectMap[K, V comparable](t *testing.T, actual map[K]V, expected map[K]V)
func ExpectNeverClosedChan ¶
func ExpectNoError ¶
func ExpectNotPanic ¶
func ExpectSlice ¶
func ExpectSlice[A comparable](t *testing.T, actual []A, expected []A)
func ExpectSorted ¶
func ExpectUnsorted ¶
func ExpectValue ¶
func ExpectValue[A comparable](t *testing.T, actual A, expected A)
func ExpectValueGTE ¶
func ExpectValueInDelta ¶
func ExpectValueLTE ¶
Types ¶
type ConcurrencyMonitor ¶ added in v0.2.0
type ConcurrencyMonitor struct {
// contains filtered or unexported fields
}
ConcurrencyMonitor measures the maximum concurrency level reached by goroutines. It enforces maximum possible concurrency by requiring each goroutine to call Inc() at the start and Dec() at the end of its execution. Goroutines calling Inc() are blocked until the concurrency level remains stable for a specified time window, ensuring that concurrency peaks are accurately captured. The highest level of concurrency observed can be retrieved using the Max() method.
func NewConcurrencyMonitor ¶ added in v0.2.0
func NewConcurrencyMonitor(window time.Duration) *ConcurrencyMonitor
func (*ConcurrencyMonitor) Dec ¶ added in v0.2.0
func (c *ConcurrencyMonitor) Dec()
func (*ConcurrencyMonitor) Inc ¶ added in v0.2.0
func (c *ConcurrencyMonitor) Inc()
func (*ConcurrencyMonitor) Max ¶ added in v0.2.0
func (c *ConcurrencyMonitor) Max() int
func (*ConcurrencyMonitor) Reset ¶ added in v0.2.0
func (c *ConcurrencyMonitor) Reset() int
Click to show internal directories.
Click to hide internal directories.