assertion

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(t reporter, actual []string, expected ...Substring)

Contains verifies that the actual output contains all expected strings.

func Count

func Count(t reporter, actual []string, expected LineCount)

Count verifies that the output has exactly the expected number of lines.

func Empty

func Empty(t reporter, actual []string)

Empty verifies that the output is empty.

func Equal

func Equal[T comparable](t reporter, actual, expected T, label Label)

Equal compares two values and reports if they differ.

func Error

func Error(t reporter, err error)

Error verifies that an error occurred (err != nil).

func ErrorContains

func ErrorContains(t reporter, err error, expected Substring)

ErrorContains verifies that an error contains the expected substring.

func False

func False(t reporter, isCondition Condition, message Message)

False verifies that isCondition does not hold.

func Format

func Format(format Template, args ...any) string

Format is a helper for creating formatted error messages.

func Lines

func Lines(t reporter, actual, expected []string)

Lines verifies that actual output matches expected lines. Reports detailed differences using Errorf if they don't match.

func NoError

func NoError(t reporter, err error)

NoError verifies that no error occurred.

func NotContains

func NotContains(t reporter, actual []string, unexpected ...Substring)

NotContains verifies that the actual output does not contain any of the given strings.

func Prefix

func Prefix(t reporter, actual []string, prefix LinePrefix)

Prefix verifies that each line starts with the expected prefix.

func Suffix

func Suffix(t reporter, actual []string, suffix LineSuffix)

Suffix verifies that each line ends with the expected suffix.

func True

func True(t reporter, isCondition Condition, message Message)

True verifies that isCondition holds.

Types

type Condition added in v0.1.0

type Condition bool

Condition is a boolean expectation checked by True and False.

type Label added in v0.1.0

type Label string

Label names the value under comparison in a failure message.

type LineCount added in v0.1.0

type LineCount int

LineCount is a number of output lines.

type LinePrefix added in v0.1.0

type LinePrefix string

LinePrefix is text every output line must start with.

type LineSuffix added in v0.1.0

type LineSuffix string

LineSuffix is text every output line must end with.

type Message added in v0.1.0

type Message string

Message describes an assertion in its failure report.

type Substring added in v0.1.0

type Substring string

Substring is a fragment of text expected (or forbidden) within output.

type Template added in v0.1.0

type Template string

Template is a printf-style format template.

Jump to

Keyboard shortcuts

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