assert

package
v2.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: CC0-1.0 Imports: 4 Imported by: 0

Documentation

Overview

Package assert offers some very simple helper methods for testing. Not meant for external use per se, though there's nothing tying this to our codebase / project.

Assertion methods (Equal, True, False, etc) expect a `message` string to be passed in, which should be a simple explanation that will help you understand what went wrong, such as "foo.Bar is 25". Wordy messages won't necessarily help debugging as assert functions should report as much information as they can about where an assertion went wrong.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(expected, actual interface{}, message string, t *testing.T)

Equal verifies that `expected` and `actual` are the same as per "!=" rules. This makes it work well for simple types, but more complex types will still need specialized checks.

func False

func False(exp bool, m string, t *testing.T)

False is a convenience method wrapping True and negating the expression

func IncludesString

func IncludesString(expected string, list []string, message string, t *testing.T)

IncludesString checks `list` for inclusion of `string`, reporting failure if it is not present.

func True

func True(expression bool, message string, t *testing.T)

True fails the tests if `expression` isn't the boolean value `true`

Types

type Caller

type Caller struct {
	Func     *runtime.Func
	Name     string
	Filename string
	Line     int
}

Caller represents data used by an assertion to show the file/function/line of where an assertion went wrong, rather than using the built-in system which would report the "failure" function every time, since all asserts that fail eventually find their way in there.

Jump to

Keyboard shortcuts

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