Documentation
¶
Index ¶
- func Contains(t TestingT, whole any, sub any, args ...any) bool
- func Equal(t TestingT, expected any, actual any, args ...any) bool
- func Error(t TestingT, err error, args ...any) bool
- func ErrorContains(t TestingT, err error, substr string, args ...any) booldeprecated
- func Expect(t TestingT, actualExpectedPairs ...any) bool
- func FailIf(t TestingT, condition bool, args ...any) bool
- func FailIfError(t TestingT, err error, args ...any) bool
- func False(t TestingT, condition bool, args ...any) bool
- func FatalIf(t TestingT, condition bool, args ...any) bool
- func FatalIfError(t TestingT, err error, args ...any) bool
- func HTMLMatch(t TestingT, htmlBody []byte, cssSelectorQuery string, innerTextRegExp string, ...) bool
- func HTMLNotMatch(t TestingT, htmlBody []byte, cssSelectorQuery string, innerTextRegExp string, ...) bool
- func Len(t TestingT, obj any, length int, args ...any) bool
- func MapLen[K comparable, V any](t TestingT, m map[K]V, length int, args ...any) booldeprecated
- func Match(t TestingT, whole string, regexpStr string, args ...any) bool
- func Nil(t TestingT, obj any, args ...any) bool
- func NoError(t TestingT, err error, args ...any) bool
- func NotContains(t TestingT, whole any, sub any, args ...any) bool
- func NotEqual(t TestingT, unexpected any, actual any, args ...any) bool
- func NotMatch(t TestingT, whole string, regexpStr string, args ...any) bool
- func NotNil(t TestingT, obj any, args ...any) bool
- func NotZero(t TestingT, actual any, args ...any) bool
- func SliceContains[T comparable](t TestingT, slice []T, contains T, args ...any) booldeprecated
- func SliceEqual[T comparable](t TestingT, expected []T, actual []T, args ...any) booldeprecated
- func SliceLen[T any](t TestingT, slice []T, length int, args ...any) booldeprecated
- func SliceNotContains[T comparable](t TestingT, slice []T, contains T, args ...any) booldeprecated
- func SliceNotEqual[T comparable](t TestingT, expected []T, actual []T, args ...any) booldeprecated
- func StrLen(t TestingT, s string, length int, args ...any) booldeprecated
- func True(t TestingT, condition bool, args ...any) bool
- func Zero(t TestingT, actual any, args ...any) bool
- type Asserter
- func (tt *Asserter) Contains(whole any, sub any, args ...any) bool
- func (tt *Asserter) Equal(expected any, actual any, args ...any) bool
- func (tt *Asserter) Error(err error, args ...any) bool
- func (tt *Asserter) Expect(actualExpectedPairs ...any) bool
- func (tt *Asserter) False(condition bool, args ...any) bool
- func (tt *Asserter) HTMLMatch(htmlBody []byte, cssSelectorQuery string, innerTextRegExp string, args ...any) bool
- func (tt *Asserter) HTMLNotMatch(htmlBody []byte, cssSelectorQuery string, innerTextRegExp string, args ...any) bool
- func (tt *Asserter) Len(obj any, length int, args ...any) bool
- func (tt *Asserter) Match(whole string, regexpStr string, args ...any) bool
- func (tt *Asserter) Nil(obj any, args ...any) bool
- func (tt *Asserter) NoError(err error, args ...any) bool
- func (tt *Asserter) NotContains(whole any, sub any, args ...any) bool
- func (tt *Asserter) NotEqual(expected any, actual any, args ...any) bool
- func (tt *Asserter) NotMatch(whole string, regexpStr string, args ...any) bool
- func (tt *Asserter) NotNil(obj any, args ...any) bool
- func (tt *Asserter) NotZero(actual any, args ...any) bool
- func (tt *Asserter) True(condition bool, args ...any) bool
- func (tt *Asserter) Zero(actual any, args ...any) bool
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
Contains fails the test if a string or error don't contain a substring, or if a byte slice doesn't contain a byte subslice, or if a slice doesn't contain an element, or if a map doesn't contain a key.
func Equal ¶
Equal fails the test if the two values are not equal. Note: the expected value comes before the actual value in the argument list.
func Expect ¶ added in v0.6.0
Expect fails the test if any of the paired values are not equal. Note: the expected value comes after the actual value in each pair.
result, err := doSomething(p1, p2) Expect(t, result, 4321, err, nil)
func FailIf ¶
FailIf fails the test if the condition is met. If returns back the result of evaluating the condition.
func FailIfError ¶
FailIfError is a shortcut to FailIf(t, err != nil, append([]any{err}, args...)...) .
func FatalIfError ¶
FatalIfError is a shortcut to FatalIf(t, err != nil, append([]any{err}, args...)...) .
func HTMLMatch ¶ added in v0.7.0
func HTMLMatch(t TestingT, htmlBody []byte, cssSelectorQuery string, innerTextRegExp string, args ...any) bool
HTMLMatch fails the test if no HTML element matching the CSS selector query was found to also match the regular expression against the inner text of any of its descendants.
Examples:
HTMLMatch(t, html, `TR > TD > A.expandable[href]`, "") HTMLMatch(t, html, `DIV#main_panel`, `^Help$``) HTMLMatch(t, html, `TR TD INPUT[name="x"]`, `[0-9]+``)
func HTMLNotMatch ¶ added in v0.7.0
func HTMLNotMatch(t TestingT, htmlBody []byte, cssSelectorQuery string, innerTextRegExp string, args ...any) bool
HTMLNotMatch fails the test if at least one HTML element matching the CSS selector query was found to also match the regular expression against the inner text of one of its descendants.
Examples:
HTMLNotMatch(t, html, `TR > TD > A.expandable[href]`, "") HTMLNotMatch(t, html, `DIV#main_panel`, "^Help$") HTMLNotMatch(t, html, `TR TD INPUT[name="x"]`, `[0-9]+``)
func Len ¶ added in v0.3.3
Len fails the test if the length of the string, slice, array, map or chan does not match the expected len.
func NotContains ¶
NotContains fails the test if a string or error contain a substring, or if a byte slice contains a byte subslice, or if a slice contains an element, or if a map contains a key.
func NotEqual ¶
NotEqual fails the test if the two values are equal. Note: the expected value comes before the actual value in the argument list.
func NotZero ¶
NotZero fails the test if the value is the 0 value of its type. Nils are considered zero.
func SliceContains
deprecated
func SliceContains[T comparable](t TestingT, slice []T, contains T, args ...any) bool
SliceContains fails the test if the slice does not contain the item.
Deprecated: Use Contains
func SliceEqual
deprecated
func SliceEqual[T comparable](t TestingT, expected []T, actual []T, args ...any) bool
SliceEqual fails the test if the two values are not equal.
Deprecated: Use Equal
func SliceNotContains
deprecated
func SliceNotContains[T comparable](t TestingT, slice []T, contains T, args ...any) bool
SliceNotContains fails the test if the slice contains the item.
Deprecated: Use NotContains
func SliceNotEqual
deprecated
func SliceNotEqual[T comparable](t TestingT, expected []T, actual []T, args ...any) bool
SliceNotEqual fails the test if the two values are equal.
Deprecated: Use NotEqual
Types ¶
type Asserter ¶ added in v0.4.0
type Asserter struct {
// contains filtered or unexported fields
}
func (*Asserter) Contains ¶ added in v0.4.0
Contains fails the test if the string does not contain a substring.
func (*Asserter) Equal ¶ added in v0.4.0
Equal fails the test if the two values are not equal. Note: the expected value comes before the actual value in the argument list.
func (*Asserter) Expect ¶ added in v0.6.0
Expect fails the test if any of the paired values are not equal. Note: the expected value comes after the actual value in each pair.
result, err := doSomething(p1, p2) tt.Expect(err, nil, result, 4321)
func (*Asserter) HTMLMatch ¶ added in v0.7.0
func (tt *Asserter) HTMLMatch(htmlBody []byte, cssSelectorQuery string, innerTextRegExp string, args ...any) bool
HTMLMatch fails the test if no HTML element matching the CSS selector query was found to also match the regular expression by the inner text of any of its descendants.
Examples:
tt.HTMLMatch(html, `TR > TD > A.expandable[href]`, "") tt.HTMLMatch(html, `DIV#main_panel`, `^Help$``) tt.HTMLMatch(html, `TR TD INPUT[name="x"]`, `[0-9]+``)
func (*Asserter) HTMLNotMatch ¶ added in v0.7.0
func (tt *Asserter) HTMLNotMatch(htmlBody []byte, cssSelectorQuery string, innerTextRegExp string, args ...any) bool
HTMLNotMatch fails the test if at least one HTML element matching the CSS selector query was found to also match the regular expression by the inner text of any of its descendants.
Examples:
HTMLNotMatch(t, html, `TR > TD > A.expandable[href]`, "") HTMLNotMatch(t, html, `DIV#main_panel`, "^Help$") HTMLNotMatch(t, html, `TR TD INPUT[name="x"]`, `[0-9]+``)
func (*Asserter) Len ¶ added in v0.4.0
Len fails the test if the length of the string, slice, array, map or chan does not match the expected len.
func (*Asserter) Match ¶ added in v0.7.2
Match fails the test if a string doesn't match a regular expression.
func (*Asserter) NotContains ¶ added in v0.4.0
NotContains fails the test if the string contain a substring.
func (*Asserter) NotEqual ¶ added in v0.4.0
NotEqual fails the test if the two values are equal. Note: the expected value comes before the actual value in the argument list.
func (*Asserter) NotMatch ¶ added in v0.7.2
NotMatch fails the test if a string matches a regular expression.
func (*Asserter) NotZero ¶ added in v0.4.0
NotZero fails the test if the value is the 0 value of its type.
