qaone

package
v0.0.0-...-68847cf Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package qaone ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(stb SubTB, assert Assertion, format string, a ...any) bool

Assert executes the given assertion and fails a test if it returns false.

Types

type Assertion

type Assertion func() (bool, string, error)

Assertion describes a function performing an assertion and returning false if it failed. Additionally it returns a message describing the assertion failure.

func About

func About[T constraints.Integer | constraints.Float](va, vb, delta T) Assertion

About asserts that two numbers are about equal within a delta.

func AnyError

func AnyError(v any) Assertion

AnyError asserts that a value is an error, a function returning an error or a type implementing an Err() error method and the error is not nil.

func ChannelClosed

func ChannelClosed[T any](ch <-chan T, timeout time.Duration) Assertion

ChannelClosed asserts that a channel is closed within a timeout.

func ChannelReceives

func ChannelReceives[T comparable](ch <-chan T, expected T, timeout time.Duration) Assertion

ChannelReceives asserts that a channel receives a wanted value within a timeout.

func Contains

func Contains[S ~[]T, T comparable](vs S, content T) Assertion

Contains asserts that a slice contains a specific value.

func ContainsNot

func ContainsNot[S ~[]T, T comparable](vs S, content T) Assertion

ContainsNot asserts that a slice does not contain a specific value.

func DeepContains

func DeepContains(vs []any, content any) Assertion

DeepContains asserts that a slice of any value contains a specific value.

func DeepEqual

func DeepEqual(va, vb any) Assertion

DeepEqual asserts that two values are deep equal.

func Different

func Different[T comparable](va, vb T) Assertion

Different asserts that two comparable values are different.

func Empty

func Empty(v any) Assertion

Empty asserts that a value is empty.

func Equal

func Equal[T comparable](va, vb T) Assertion

Equal asserts that two comparable values are equal.

func ErrorContains

func ErrorContains(v any, contains string) Assertion

ErrorContains asserts that a value is an error like in AnyError and the error contains the given string.

func ErrorMatches

func ErrorMatches(v any, pattern string) Assertion

ErrorMatches asserts that a value is an error like in AnyError and the error matches the given regular expression.

func Fail

func Fail(info any) Assertion

Fail always fails.

func False

func False(v any) Assertion

False asserts that a value is false.

func GroupWaits

func GroupWaits(wg *sync.WaitGroup, timeout time.Duration) Assertion

GroupWaits asserts that a wait group is done within a timeout.

func Length

func Length(v any, l int) Assertion

Length asserts that a value has a specific size.

func Matches

func Matches(v, re string) Assertion

Matches asserts that a string matches a regular expression.

func Nil

func Nil(v any) Assertion

Nil asserts that a value is nil.

func NoError

func NoError(v any) Assertion

NoError asserts that a value is an error like in AnyError and the error is nil.

func NotEmpty

func NotEmpty(v any) Assertion

NotEmpty asserts that a value is not empty.

func NotNil

func NotNil(v any) Assertion

NotNil asserts that a value is not nil.

func NotOK

func NotOK(v any) Assertion

NotOK asserts that a value is false, not nil, not 0, not "", an error or a function returning false or a non-nil error.

func OK

func OK(v any) Assertion

OK asserts that a value is true, nil, 0, "", no error or a function returning true or a nil error.

func OneCase

func OneCase(v string) Assertion

OneCase asserts that a string is in one case.

func Panics

func Panics(pf func()) Assertion

Panics asserts that a function panics.

func PanicsNot

func PanicsNot(pf func()) Assertion

PanicsNot asserts that a function does not panic.

func PanicsWith

func PanicsWith(pf func(), v any) Assertion

PanicsWith asserts that a function panics with a given value.

func PathExists

func PathExists(v string) Assertion

PathExists asserts that a path exists.

func Range

func Range[T constraints.Integer | constraints.Float](v, min, max T) Assertion

Range asserts that a number is in a range.

func Retries

func Retries(f func() (bool, error), timeout time.Duration) Assertion

Retries asserts that a function returns true within a timeout.

func True

func True(v any) Assertion

True asserts that a value is true.

func Zero

func Zero(v any) Assertion

Zero asserts that a value has its zero value.

type SubTB

type SubTB interface {
	Helper()

	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
}

SubTB is a sub interface of testung.TB.

Jump to

Keyboard shortcuts

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