assert

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

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

Go to latest
Published: Sep 17, 2018 License: BSD-2-Clause Imports: 3 Imported by: 0

README

Assert

GoDoc

Assertion library for Golang

License

This software is distributed under the BSD 2-Clause License, see LICENSE for more information.

Documentation

Overview

Package assert contains an assertion library, providing methods to e.g. assert equality of expected and actual values. This makes your unit tests much more readable.

To use it, create an Assert object and call its methods for assertion:

asrt := NewAssert(t)
actual := myTestCall()
asrt.Equal(actual, "expected", "Got unexpected value from myTestCall()")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assert

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

Assert wraps a testing.T pointer for storing failures.

func NewAssert

func NewAssert(t *testing.T) *Assert

NewAssert returns an Assert type that wraps t.

func NewStrict

func NewStrict(t *testing.T) *Assert

func (*Assert) Equal

func (a *Assert) Equal(actual interface{}, expected interface{}, msg string)

Equal asserts that actual and expected are identical. It does not assert deep equality.

func (*Assert) EqualSlice

func (a *Assert) EqualSlice(actual []interface{}, expected []interface{}, msg string)

EqualSlice asserts that the two given slices are equal, i.e. they have the same size and contain the same elements, doing a shallow compare of the elements.

func (*Assert) False

func (a *Assert) False(val interface{}, msg string)

func (*Assert) Match

func (a *Assert) Match(pattern string, target string, msg string)

Match asserts that target matches pattern using a regular expression.

func (*Assert) Nil

func (a *Assert) Nil(actual interface{}, msg string)

Nil asserts that actual is nil.

func (*Assert) NotNil

func (a *Assert) NotNil(actual interface{}, msg string)

NotNil asserts that actual is not nil.

func (*Assert) True

func (a *Assert) True(val interface{}, msg string)

Jump to

Keyboard shortcuts

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