testutil

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err

func Err(actual interface{}, extras ...interface{}) interface{}

Err returns only the last actual result of a multi-result function call, which typically is an error result. Err is most useful in writing simple PASS/FAIL test cases for multi-result function calls.

func PassFail

func PassFail(tests PASSFAILS)

PassFail runs a series of PASS and/or FAIL tests, checking for either success or the absence of success (failure might be to harsh a word).

Types

type FAIL

type FAIL struct {
	D string // test case description
	A interface{}
}

FAIL expects a function under test to return an error.

func (FAIL) Actual

func (f FAIL) Actual() interface{}

Actual returns the actual error return value for a function under test.

func (FAIL) Description

func (f FAIL) Description() string

Description returns the description for a function under test.

type PASS

type PASS FAIL

PASS is just another type of FAIL, after all. (No, this hasn't been ripped off straight from one of Nico Semsrott's satirical revues.)

func (PASS) Actual

func (p PASS) Actual() interface{}

Actual returns the actual error return value for a function under test.

func (PASS) Description

func (p PASS) Description() string

Description returns the description for a function under test.

type PASSFAIL

type PASSFAIL interface {
	Description() string
	Actual() interface{}
}

PASSFAIL is an expectation for a function to either return no error and thus PASS or to return an error and thus FAIL.

type PASSFAILS

type PASSFAILS []PASSFAIL

PASSFAILS is a list of PASS and FAIL expectations for function calls returning errors.

type TestWriter

type TestWriter struct {
	// contains filtered or unexported fields
}

TestWriter chains to another io.Writer and replaces certain characters as they pass through it for writing.

func NewTestWriter

func NewTestWriter(w io.Writer) *TestWriter

NewTestWriter returns a new io.Writer which translates spaces into underscores and adornes new lines with a down-leftwards pointing arrow, and finally writing the result to a chained io.Writer.

func (*TestWriter) Write

func (nl *TestWriter) Write(p []byte) (n int, err error)

Write replaces all spaces (0x20) with underscores and adorns all new lines \n with a "downwards arrow with corner leftwards" before writing the outcome to the chained writer.

Jump to

Keyboard shortcuts

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