Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitDefaultTheme ¶ added in v0.0.2
func InitDefaultTheme(t Theme)
InitDefaultTheme sets the default theme, typically during init(). Calls to this function outside of init() are unsupported and may panic or produce unexpected results.
Types ¶
type Comparison ¶ added in v0.0.2
type Comparison struct {
// contains filtered or unexported fields
}
Comparison is a result comparing two values. This is the most common type of result.
func Compare ¶ added in v0.0.2
func Compare(matched bool, actual any, comparison string, expected any) Comparison
Compare returns a Comparison, comparing an actual to an expected.
The comparison param should be a human-readable description of how the values were compared. For example, Compare(true, "foo", "==", "foo") to show that "foo" successfully equaled "foo".
func (Comparison) Describe ¶ added in v0.0.2
func (c Comparison) Describe(ctx context.Context, passed bool) string
Describe returns a description of c. The passed param describes whether or not the top-level assertion passed.
func (Comparison) Matched ¶ added in v0.0.2
func (c Comparison) Matched() bool
Matched returns whether or not c describes a failure.
type CondSprinter ¶ added in v0.0.2
CondSprinter is a type which can conditionally print using either a failed printer or a passed printer. This is useful for outputting results during passing tests, to make it clear that the value did _not_ fail.
type DescribedResult ¶ added in v0.0.2
type DescribedResult struct {
// contains filtered or unexported fields
}
DescribedResult adds extra information to a Result.
func Describe ¶ added in v0.0.2
func Describe(r Result, desc string) DescribedResult
Describe returns a DescribedResult with extra context describing the assertion result.
func (DescribedResult) Describe ¶ added in v0.0.2
func (r DescribedResult) Describe(ctx context.Context, passed bool) string
Describe describes the result, passing the wrapped
func (DescribedResult) Matched ¶ added in v0.0.2
func (r DescribedResult) Matched() bool
Matched returns the original Result's matched status.
type Opt ¶ added in v0.0.2
Opt is an option function which can make adjustments to a Result. Usually this is used to add context to the Describe output.
type PrefixSprinter ¶ added in v0.0.2
PrefixSprinter wraps up a Sprinter with a prefix that needs to be printed first.
type SimpleResult ¶
type SimpleResult struct {
// contains filtered or unexported fields
}
SimpleResult is a simple result, wrapping up a matched boolean, an actual value, and a description.
func Simple ¶
func Simple(matched bool, actual any, desc string) SimpleResult
Simple returns a SimpleResult wrapping matched and desc.
func Simplef ¶
func Simplef(matched bool, actual any, desc string, args ...any) SimpleResult
Simplef returns a SimpleResult wrapping matched and a fmt.Sprintf of the desc and args.
func (SimpleResult) Describe ¶
func (r SimpleResult) Describe(ctx context.Context, passed bool) string
Describe returns a description of this result.
func (SimpleResult) Matched ¶ added in v0.0.2
func (r SimpleResult) Matched() bool
Matched returns whether or not r is marked as matched.
type SimpleSprinter ¶ added in v0.0.2
SimpleSprinter wraps a simple Sprint-style function to use for printing values.
type Sprinter ¶ added in v0.0.2
Sprinter is a type which can take the failure status of a result and a value value and return a string that should be printed.
type Theme ¶ added in v0.0.2
type Theme struct { // Actual will be used to print out the Actual value for results which have // access to the actual. Actual Sprinter // Desc will be used to print out the description of the result. Desc Sprinter // Expected will be used to print out what the value was expected to be for // results which have access to an expected value. Expected Sprinter // Extra will be used to print out any extra information, like additional // context added to the assertion via output options. Extra Sprinter }
Theme is used when describing assertions in output.
type WrapOption ¶
type WrapOption func(WrappedResult) WrappedResult
WrapOption is an option function for wrapping up a child result.
func WrapDescribe ¶
WrapDescribe wraps up a child result with a describe function, to add extra detail to the child result's description.
func WrapMatched ¶ added in v0.0.2
func WrapMatched(f func(bool) bool) WrapOption
WrapMatched wraps up a child result with a matched function, to conditionally change the failure.
type WrappedResult ¶
type WrappedResult struct {
// contains filtered or unexported fields
}
WrappedResult is a complex result that needs to wrap another result with extra context about how an actual value was compared. This is mostly used for wrapped matchers to describe how an actual was retrieved.
func Wrap ¶
func Wrap(r Result, opts ...WrapOption) WrappedResult
Wrap wraps up a result using opts to manipulate the final result.
func (WrappedResult) Describe ¶
func (r WrappedResult) Describe(ctx context.Context, passed bool) string
Describe returns a description of the result by passing the original result's description to the describe wrapper function. If there is no describe wrapper, it returns the original result's Describe().
func (WrappedResult) Matched ¶ added in v0.0.2
func (r WrappedResult) Matched() bool
Matched returns the result of passing the original result's Matched() value to the matched wrapper function. If there is no matched wrapper, it returns the original result's Matched().