assert

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

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

Go to latest
Published: May 6, 2015 License: MIT Imports: 8 Imported by: 0

README

GoDoc

assert

assert is a simple testing library for Go. It extends the testing package of the Go standard library with some handy functions.

Use go get to install or update the package:

go get -u github.com/tsne/assert

For more information see the Documentation.

Documentation

Overview

Package assert provides utility functions for automated testing of Go packages. It extends the testing package of the Go standard library with some handy functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(f Fataler, actual, expected interface{})

Equal asserts that the actual value equals the expected value. This function also compares the elements of arrays, slices, maps, and struct fields.

func Err

func Err(f Fataler, actual, expected error)

Err asserts that the actual error equals the expected error.

func ErrMsg

func ErrMsg(f Fataler, err error, msg string)

ErrMsg asserts that the message of the given error equals the given message.

func ErrMsgMatch

func ErrMsgMatch(f Fataler, err error, msgRegexp string)

ErrMsgMatch asserts that the message of the given error matches the given regular expression.

func False

func False(f Fataler, condition bool)

False asserts that the given condition is not fulfilled.

func Len

func Len(f Fataler, value interface{}, expectedLen int)

Len asserts that the length of an array, a channel, a map, a slice, or a string equals the expected length. It panics if another type is passed.

func Nil

func Nil(f Fataler, value interface{})

Nil asserts that the given value is nil.

func NotEqual

func NotEqual(f Fataler, actual, expected interface{})

NotEqual asserts that the actual value is not equal to the expected value. This functions also compares the elements of arrays, slices, maps, and struct fields.

func NotNil

func NotNil(f Fataler, value interface{})

NotNil asserts that the given value is not nil.

func Panic

func Panic(f Fataler, fn interface{}, args ...interface{})

Panic asserts that the function fn called with the arguments args panics.

func True

func True(f Fataler, condition bool)

True asserts that the given condition is fulfilled.

Types

type Fataler

type Fataler interface {
	Fatal(args ...interface{})
}

Fataler represents an interface to trigger Fatal if an assertion does not hold.

Jump to

Keyboard shortcuts

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