test

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GopPackage = true
)
View Source
const (
	Gopo_Gopt_Case_Match = "" /* 145-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func Fatal

func Fatal(v ...any)

func Fatalf

func Fatalf(format string, v ...any)

func Gopt_Case_MatchAny

func Gopt_Case_MatchAny(t CaseT, expected, got any, name ...string)

func Gopt_Case_MatchAnySet added in v0.7.5

func Gopt_Case_MatchAnySet(t CaseT, expected TyAnySet, got any, name ...string)

func Gopt_Case_MatchBaseSlice

func Gopt_Case_MatchBaseSlice[T baseelem](t CaseT, expected, got []T, name ...string)

func Gopt_Case_MatchMap

func Gopt_Case_MatchMap(t CaseT, expected, got map[string]any, name ...string)

func Gopt_Case_MatchSet

func Gopt_Case_MatchSet[T baseelem](t CaseT, expected TySet[T], got []T, name ...string)

func Gopt_Case_MatchSlice

func Gopt_Case_MatchSlice(t CaseT, expected, got []any, name ...string)

func Gopt_Case_MatchTBase

func Gopt_Case_MatchTBase[T basetype](t CaseT, expected, got T, name ...string)

Types

type Case

type Case struct {
	CaseT
}

type CaseT

type CaseT interface {
	// Name returns the name of the running (sub-) test or benchmark.
	//
	// The name will include the name of the test along with the names of
	// any nested sub-tests. If two sibling sub-tests have the same name,
	// Name will append a suffix to guarantee the returned name is unique.
	Name() string

	// Fail marks the function as having failed but continues execution.
	Fail()

	// Failed reports whether the function has failed.
	Failed() bool

	// FailNow marks the function as having failed and stops its execution
	// by calling runtime.Goexit (which then runs all deferred calls in the
	// current goroutine).
	// Execution will continue at the next test or benchmark.
	// FailNow must be called from the goroutine running the
	// test or benchmark function, not from other goroutines
	// created during the test. Calling FailNow does not stop
	// those other goroutines.
	FailNow()

	// Log formats its arguments using default formatting, analogous to Println,
	// and records the text in the error log. For tests, the text will be printed only if
	// the test fails or the -test.v flag is set. For benchmarks, the text is always
	// printed to avoid having performance depend on the value of the -test.v flag.
	Log(args ...any)

	// Logf formats its arguments according to the format, analogous to Printf, and
	// records the text in the error log. A final newline is added if not provided. For
	// tests, the text will be printed only if the test fails or the -test.v flag is
	// set. For benchmarks, the text is always printed to avoid having performance
	// depend on the value of the -test.v flag.
	Logf(format string, args ...any)

	// Errorln is equivalent to Log followed by Fail.
	Errorln(args ...any)

	// Errorf is equivalent to Logf followed by Fail.
	Errorf(format string, args ...any)

	// Fatal is equivalent to Log followed by FailNow.
	Fatal(args ...any)

	// Fatalf is equivalent to Logf followed by FailNow.
	Fatalf(format string, args ...any)

	// Skip is equivalent to Log followed by SkipNow.
	Skip(args ...any)

	// Skipf is equivalent to Logf followed by SkipNow.
	Skipf(format string, args ...any)

	// SkipNow marks the test as having been skipped and stops its execution
	// by calling runtime.Goexit.
	// If a test fails (see Error, Errorf, Fail) and is then skipped,
	// it is still considered to have failed.
	// Execution will continue at the next test or benchmark. See also FailNow.
	// SkipNow must be called from the goroutine running the test, not from
	// other goroutines created during the test. Calling SkipNow does not stop
	// those other goroutines.
	SkipNow()

	// Skipped reports whether the test was skipped.
	Skipped() bool

	// Helper marks the calling function as a test helper function.
	// When printing file and line information, that function will be skipped.
	// Helper may be called simultaneously from multiple goroutines.
	Helper()

	// Cleanup registers a function to be called when the test (or subtest) and all its
	// subtests complete. Cleanup functions will be called in last added,
	// first called order.
	Cleanup(f func())

	// TempDir returns a temporary directory for the test to use.
	// The directory is automatically removed by Cleanup when the test and
	// all its subtests complete.
	// Each subsequent call to t.TempDir returns a unique directory;
	// if the directory creation fails, TempDir terminates the test by calling Fatal.
	TempDir() string

	// Run runs f as a subtest of t called name.
	//
	// Run may be called simultaneously from multiple goroutines, but all such calls
	// must return before the outer test function for t returns.
	Run(name string, f func()) bool

	// Deadline reports the time at which the test binary will have
	// exceeded the timeout specified by the -timeout flag.
	//
	// The ok result is false if the -timeout flag indicates “no timeout” (0).
	Deadline() (deadline time.Time, ok bool)
}

type TestingT

type TestingT struct {
	*testing.T
}

func NewT

func NewT(t *testing.T) TestingT

NewT creates a testing object.

func (TestingT) Errorln

func (p TestingT) Errorln(args ...any)

Errorln is equivalent to Log followed by Fail.

func (TestingT) Run

func (p TestingT) Run(name string, doSth func()) bool

Run runs f as a subtest of t called name.

Run may be called simultaneously from multiple goroutines, but all such calls must return before the outer test function for t returns.

type TyAnySet added in v0.7.5

type TyAnySet []any

func Set__2 added in v0.7.5

func Set__2(vals ...any) TyAnySet

type TySet

type TySet[T baseelem] []T

func Set__0

func Set__0[T baseelem](vals ...T) TySet[T]

func Set__1

func Set__1[T []string](v *Var__3[T]) TySet[string]

type Var__0

type Var__0[T basetype] struct {
	// contains filtered or unexported fields
}

func Gopx_Var_Cast__0

func Gopx_Var_Cast__0[T basetype]() *Var__0[T]

func (*Var__0[T]) Equal

func (p *Var__0[T]) Equal(t CaseT, v T) bool

func (*Var__0[T]) MarshalJSON

func (p *Var__0[T]) MarshalJSON() ([]byte, error)

func (*Var__0[T]) Match

func (p *Var__0[T]) Match(t CaseT, v T, name ...string)

func (*Var__0[T]) String

func (p *Var__0[T]) String() string

func (*Var__0[T]) UnmarshalJSON

func (p *Var__0[T]) UnmarshalJSON(data []byte) error

func (*Var__0[T]) Val

func (p *Var__0[T]) Val() T

func (*Var__0[T]) Valid

func (p *Var__0[T]) Valid() bool

type Var__1

type Var__1[T map[string]any] struct {
	// contains filtered or unexported fields
}

func Gopx_Var_Cast__1

func Gopx_Var_Cast__1[T map[string]any]() *Var__1[T]

func (*Var__1[T]) MarshalJSON

func (p *Var__1[T]) MarshalJSON() ([]byte, error)

func (*Var__1[T]) Match

func (p *Var__1[T]) Match(t CaseT, v T, name ...string)

func (*Var__1[T]) UnmarshalJSON

func (p *Var__1[T]) UnmarshalJSON(data []byte) error

func (*Var__1[T]) Val

func (p *Var__1[T]) Val() T

func (*Var__1[T]) Valid

func (p *Var__1[T]) Valid() bool

type Var__2

type Var__2[T []any] struct {
	// contains filtered or unexported fields
}

func Gopx_Var_Cast__2

func Gopx_Var_Cast__2[T []any]() *Var__2[T]

func (*Var__2[T]) MarshalJSON

func (p *Var__2[T]) MarshalJSON() ([]byte, error)

func (*Var__2[T]) Match

func (p *Var__2[T]) Match(t CaseT, v T, name ...string)

func (*Var__2[T]) UnmarshalJSON

func (p *Var__2[T]) UnmarshalJSON(data []byte) error

func (*Var__2[T]) Val

func (p *Var__2[T]) Val() T

func (*Var__2[T]) Valid

func (p *Var__2[T]) Valid() bool

type Var__3

type Var__3[T baseslice] struct {
	// contains filtered or unexported fields
}

func Gopx_Var_Cast__3

func Gopx_Var_Cast__3[T []string]() *Var__3[T]

func (*Var__3[T]) MarshalJSON

func (p *Var__3[T]) MarshalJSON() ([]byte, error)

func (*Var__3[T]) Match

func (p *Var__3[T]) Match(t CaseT, v T, name ...string)

func (*Var__3[T]) UnmarshalJSON

func (p *Var__3[T]) UnmarshalJSON(data []byte) error

func (*Var__3[T]) Val

func (p *Var__3[T]) Val() T

func (*Var__3[T]) Valid

func (p *Var__3[T]) Valid() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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