Documentation ¶
Overview ¶
Package test contains functions to support advanced testing.
Index ¶
- Constants
- func MarshalBinary[T any](t TestingT, cases []CaseBinary[T])
- func MarshalJSON[T any](t TestingT, cases []CaseJSON[T])
- func MarshalText[T any](t TestingT, cases []CaseText[T])
- func UnmarshalBinary[T any](t TestingT, cases []CaseBinary[T], helper TypeHelper[T])
- func UnmarshalJSON[T any](t TestingT, cases []CaseJSON[T], helper TypeHelper[T])
- func UnmarshalText[T any](t TestingT, cases []CaseText[T], helper TypeHelper[T])
- type AssertErrorFunc
- type CaseBinary
- type CaseJSON
- type CaseText
- type Constraint
- type TestingT
- type TypeHelper
Constants ¶
const ( // OnlyMarshal limits test case only for marshal functions. OnlyMarshal = Constraint(iota + 1) // OnlyUnmarshal limits test case only for unmarshal functions. OnlyUnmarshal )
Variables ¶
This section is empty.
Functions ¶
func MarshalBinary ¶
func MarshalBinary[T any](t TestingT, cases []CaseBinary[T])
MarshalBinary runs all passed test cases of method with same name.
func MarshalJSON ¶
MarshalJSON runs all passed test cases of method with same name.
func MarshalText ¶
MarshalText runs all passed test cases of method with same name.
func UnmarshalBinary ¶
func UnmarshalBinary[T any](t TestingT, cases []CaseBinary[T], helper TypeHelper[T])
UnmarshalBinary runs all passed test cases of method with same name.
func UnmarshalJSON ¶
func UnmarshalJSON[T any](t TestingT, cases []CaseJSON[T], helper TypeHelper[T])
UnmarshalJSON runs all passed test cases of method with same name.
func UnmarshalText ¶
func UnmarshalText[T any](t TestingT, cases []CaseText[T], helper TypeHelper[T])
UnmarshalText runs all passed test cases of method with same name.
Types ¶
type AssertErrorFunc ¶
AssertErrorFunc represents function to assert error.
var AnyError AssertErrorFunc = func(t TestingT, err error, failInfo string) bool { return assert.Error(t, err, failInfo) }
AnyError is AssertErrorFunc to check if any error was passed.
func Error ¶
func Error(text string) AssertErrorFunc
Error creates AssertErrorFunc to check if error has passed text.
func ErrorHasPrefix ¶ added in v0.8.0
func ErrorHasPrefix(prefix string) AssertErrorFunc
ErrorHasPrefix creates AssertErrorFunc to check if error has passed text prefix.
func ErrorHasSuffix ¶ added in v0.8.0
func ErrorHasSuffix(suffix string) AssertErrorFunc
ErrorHasSuffix creates AssertErrorFunc to check if error has passed text suffix.
func ErrorMatch ¶ added in v0.8.0
func ErrorMatch(regexpPattern string) AssertErrorFunc
ErrorMatch creates AssertErrorFunc to check if error text match passed regexp.
type CaseBinary ¶
type CaseBinary[T any] struct { Constraint Constraint Before func(index int, c *CaseBinary[T]) error After func(index int, c *CaseBinary[T]) error Error AssertErrorFunc Data []byte Value T Custom any // user-defined custom value for Before and/or After function }
CaseBinary represents one specific test case for MarshalBinary and/or UnmarshalBinary method.
type CaseJSON ¶
type CaseJSON[T any] struct { Constraint Constraint Before func(index int, c *CaseJSON[T]) error After func(index int, c *CaseJSON[T]) error Error AssertErrorFunc Data string Value T Custom any // user-defined custom value for Before and/or After function }
CaseJSON represents one specific test case for MarshalJSON and/or UnmarshalJSON method.
type CaseText ¶
type CaseText[T any] struct { Constraint Constraint Before func(index int, c *CaseText[T]) error After func(index int, c *CaseText[T]) error Error AssertErrorFunc Data string Value T Custom any // user-defined custom value for Before and/or After function }
CaseText represents one specific test case for MarshalText and/or UnmarshalText method.