assert

package module
v0.0.0-...-ba7e68a Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2015 License: BSD-3-Clause Imports: 8 Imported by: 0

README

go-test GoSearch

Assert utils for GO testing.

  • LinesEqual and TextEquals Other than showing the assertion failure message, they also shows the line-to-line diff result for your information:

Example code

func TestForExample(t *testing.T) {
	TextEquals(t, "info",
`Hello world,
Pleae help me,
doing this`,
`Hello world,
please help me`)
}

Results

--- FAIL: TestForExample (0.00 seconds)
	assert.go:123: assert.go:172: Unexpected info: exp 2, act 3 lines
	assert.go:124: Difference(exp ===  act ### change --- +++)
	assert.go:147: ---   2: please help me.
	assert.go:148: +++   2: Pleae help me,.
	assert.go:143: ###   3: doing this.

License

BSD license.

Documentation

Overview

Package assert provides some convinient asserting functions on strings, lines, and string sets for testings.

Return values: true if the assert holds, false otherwise.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equals

func Equals(t *testing.T, name string, act, exp interface{}) bool

Equals fails the test and shows error message when act and exp are not equal

func IsFalse

func IsFalse(t *testing.T, name string, exp bool) bool

IsFalse fails the test and shows error message when exp are not false

func IsTrue

func IsTrue(t *testing.T, name string, exp bool) bool

IsTrue fails the test and shows error message when exp are not true

func LinesEqual

func LinesEqual(t *testing.T, name string, act, exp []string) bool

LinesEqual fails the test and shows the error message and line-to-line differences of the lines when two slices of strings are not equal

func Maps

func Maps(t *testing.T, name string, src []interface{}, dst []interface{}, f func(src interface{}) interface{}) bool

Maps asserts whether a mapping function works as expected.

func NoError

func NoError(t *testing.T, err error) bool

NoError fails the test if err is not nil

func NoErrorf

func NoErrorf(t *testing.T, fmtStr string, err error) bool

NoErrorf is similar to NoError with an extra format string. The first and only variable in the format string should be %v for error.

func NotEquals

func NotEquals(t *testing.T, name string, act, exp interface{}) bool

NotEquals fails the test and shows error message when act and exp are equal

func StrSetEquals

func StrSetEquals(t *testing.T, name string, act, exp villa.StrSet) bool

StrSetEquals fails the test and shows error message when act and exp are not equal string sets.

func StringEquals

func StringEquals(t *testing.T, name string, act, exp interface{}) bool

StringEquals fails the test and shows error message when string forms of act and exp are not equal

func TextEquals

func TextEquals(t *testing.T, name string, act, exp string) bool

TextEquals splits input strings into lines and calls LinesEqual

Types

This section is empty.

Jump to

Keyboard shortcuts

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