assert

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package assert (trial/assert) is a simple and lightweight assertion library.

Example:

 import "github.com/jgroeneveld/trial/assert"

 assert.Equal(t, 1, 2)

 Output:
 unit_test.go:42: Not equal:
		Expected: 1
		  Actual: 2

Additional arguments to overwrite the message

 assert.Equal(t, 1, 2, "numbers dont match for %q", "my param")

 Output:
 unit_test.go:42: numbers dont match for "my param":
		Expected: 1
		  Actual: 2

See https://github.com/jgroeneveld/trial for more examples.

Also see https://github.com/jgroeneveld/schema for easier JSON Schema testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepEqual

func DeepEqual(t testingT, expected interface{}, actual interface{}, msgf ...interface{})

DeepEqual test if two values are deeply equal.

func Equal

func Equal(t testingT, expected interface{}, actual interface{}, msgf ...interface{})

Equal checks if two values are equal. Reports if types are different, even though values "look" the same.

func False

func False(t testingT, expression bool, msgf ...interface{})

False tests if a value is False

func JSONSchema

func JSONSchema(t testingT, r io.Reader, matcher schema.Matcher, msgf ...interface{})

JSONSchema uses schema to assert that json matches a given structure

func MustBeDeepEqual

func MustBeDeepEqual(t testingT, expected interface{}, actual interface{}, msgf ...interface{})

MustBeDeepEqual test if two values are deeply equal. Will FailNow if expectation is not met.

func MustBeEqual

func MustBeEqual(t testingT, expected interface{}, actual interface{}, msgf ...interface{})

MustBeEqual checks if two values are equal. Reports if types are different, even though values "look" the same. Will FailNow if expectation is not met.

func MustBeFalse

func MustBeFalse(t testingT, expression bool, msgf ...interface{})

MustBeFalse tests if a value is False Will FailNow if expectation is not met.

func MustBeNil

func MustBeNil(t testingT, expression interface{}, msgf ...interface{})

MustBeNil tests if a value is Nil Will FailNow if expectation is not met.

func MustBeTrue

func MustBeTrue(t testingT, expression bool, msgf ...interface{})

MustBeTrue tests if a value is true Will FailNow if expectation is not met.

func MustMatchJSONSchema

func MustMatchJSONSchema(t testingT, r io.Reader, matcher schema.Matcher, msgf ...interface{})

MustMatchJSONSchema uses schema to assert that json matches a given structure Will FailNow if expectation is not met.

func MustNotBeEqual

func MustNotBeEqual(t testingT, expected interface{}, actual interface{}, msgf ...interface{})

MustNotBeEqual checks if two values are equal. Will FailNow if expectation is not met.

func MustNotBeNil

func MustNotBeNil(t testingT, expression interface{}, msgf ...interface{})

MustNotBeNil tests if a value is Not Nil Will FailNow if expectation is not met.

func Nil

func Nil(t testingT, expression interface{}, msgf ...interface{})

Nil tests if a value is Nil

func NotEqual

func NotEqual(t testingT, expected interface{}, actual interface{}, msgf ...interface{})

NotEqual checks if two values are not equal.

func NotNil

func NotNil(t testingT, expression interface{}, msgf ...interface{})

NotNil tests if a value is Not Nil

func True

func True(t testingT, expression bool, msgf ...interface{})

True tests if a value is true

Types

This section is empty.