test

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: GPL-3.0, GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertMainThread

func AssertMainThread()

AssertMainThread is a stub for when "assertions" build tag is missing

func AssertNonMainThread

func AssertNonMainThread()

AssertNonMainThread is a stub for when "assertions" build tag is missing

func Equate

func Equate(t *testing.T, value, expectedValue interface{})

Equate is used to test equality between one value and another. Generally, both values must be of the same type but if a is of type uint16, b can be uint16 or int. The reason for this is that a literal number value is of type int. It is very convenient to write something like this, without having to cast the expected number value:

var r uint16
r = someFunction()
test.Equate(t, r, 10)

This is by no means a comprehensive comparison function. With a bit more work with the reflect package we could generalise the testing a lot more. At is is however, it's good enough.

func ExpectedFailure

func ExpectedFailure(t *testing.T, v interface{}) bool

ExpectedFailure tests argument v for a failure condition suitable for it's type. Currentlly support types:

bool -> bool == false
error -> error != nil

If type is nil then the test will fail.

func ExpectedSuccess

func ExpectedSuccess(t *testing.T, v interface{}) bool

ExpectedSuccess tests argument v for a success condition suitable for it's type. Currentlly support types:

bool -> bool == true
error -> error == nil

If type is nil then the test will succeed.

Types

type Writer

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

Writer is an implementation of the io.Writer interface. It should be used to capture output and to compare with predefined strings.

func (*Writer) Compare

func (tw *Writer) Compare(s string) bool

Compare buffered output with predefined/example string

func (*Writer) Write

func (tw *Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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