assertions

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldAlmostEqual

func ShouldAlmostEqual(actual interface{}, expected ...interface{}) error

ShouldAlmostEqual makes sure that two parameters are close enough to being equal. The acceptable delta may be specified with a third argument.

func ShouldBeBetween

func ShouldBeBetween(actual interface{}, expected ...interface{}) error

ShouldBeBetween receives exactly two parameters and ensures that the first is less than the second.

func ShouldBeBetweenOrEqual

func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) error

ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. It ensures that the actual value is between both bounds or equal to one of them.

func ShouldBeBlank

func ShouldBeBlank(actual interface{}, expected ...interface{}) error

ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal to "".

func ShouldBeEmpty

func ShouldBeEmpty(actual interface{}, expected ...interface{}) error

ShouldBeEmpty receives a single parameter (actual) and determines whether or not calling len(actual) would return `0`.

func ShouldBeFalse

func ShouldBeFalse(actual interface{}, expected ...interface{}) error

ShouldBeFalse receives a single parameter and ensures that it is false.

func ShouldBeGreaterThan

func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) error

ShouldBeGreaterThan receives exactly two parameters and ensures that the first is greater than the second.

func ShouldBeGreaterThanOrEqualTo

func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) error

ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that the first is greater than or equal to the second.

func ShouldBeIn

func ShouldBeIn(actual interface{}, expected ...interface{}) error

ShouldBeIn receives at least 2 parameters. The first is a proposed member of the collection that is passed in either as the second parameter, or of the collection that is comprised of all the remaining parameters. This assertion ensures that the proposed member is in the collection (using ShouldEqual).

func ShouldBeLessThan

func ShouldBeLessThan(actual interface{}, expected ...interface{}) error

ShouldBeLessThan receives exactly two parameters and ensures that the first is less than the second.

func ShouldBeLessThanOrEqualTo

func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) error

ShouldBeLessThanOrEqualTo receives exactly two parameters and ensures that the first is less than or equal to the second.

func ShouldBeNil

func ShouldBeNil(actual interface{}, expected ...interface{}) error

ShouldBeNil receives a single parameter and ensures that it is nil.

func ShouldBeTrue

func ShouldBeTrue(actual interface{}, expected ...interface{}) error

ShouldBeTrue receives a single parameter and ensures that it is true.

func ShouldBeZeroValue

func ShouldBeZeroValue(actual interface{}, expected ...interface{}) error

ShouldBeZeroValue receives a single parameter and ensures that it is the Go equivalent of the default value, or "zero" value.

func ShouldContain

func ShouldContain(actual interface{}, expected ...interface{}) error

ShouldContain receives exactly two parameters. The first is a slice and the second is a proposed member. Membership is determined using ShouldEqual.

func ShouldContainKey

func ShouldContainKey(actual interface{}, expected ...interface{}) error

ShouldContainKey receives exactly two parameters. The first is a map and the second is a proposed key.

func ShouldContainSubstring

func ShouldContainSubstring(actual interface{}, expected ...interface{}) error

ShouldContainSubstring receives exactly 2 string parameters and ensures that the first contains the second as a substring.

func ShouldEndWith

func ShouldEndWith(actual interface{}, expected ...interface{}) error

ShouldEndWith receives exactly 2 string parameters and ensures that the first ends with the second.

func ShouldEqual

func ShouldEqual(actual interface{}, expected ...interface{}) error

ShouldEqual receives exactly two parameters and does an equality check.

func ShouldEqualTrimSpace

func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) error

ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the first is equal to the second after removing all leading and trailing whitespace using strings.TrimSpace(first).

func ShouldHappenAfter

func ShouldHappenAfter(actual interface{}, expected ...interface{}) error

ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the first happens after the second.

func ShouldHappenBefore

func ShouldHappenBefore(actual interface{}, expected ...interface{}) error

ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the first happens before the second.

func ShouldHappenBetween

func ShouldHappenBetween(actual interface{}, expected ...interface{}) error

ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the first happens between (not on) the second and third.

func ShouldHappenOnOrAfter

func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) error

ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that the first happens on or after the second.

func ShouldHappenOnOrBefore

func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) error

ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that the first happens on or before the second.

func ShouldHaveLength

func ShouldHaveLength(actual interface{}, expected ...interface{}) error

ShouldHaveLength receives 2 parameters. The first is a collection to check the length of, the second being the expected length.

func ShouldNotAlmostEqual

func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) error

ShouldNotAlmostEqual makes sure that two parameters are not close enough to being equal. The unacceptable delta may be specified with a third argument.

func ShouldNotBeBetween

func ShouldNotBeBetween(actual interface{}, expected ...interface{}) error

ShouldNotBeBetween receives exactly three parameters: an actual value, a lower bound, and an upper bound. It ensures that the actual value is NOT between both bounds.

func ShouldNotBeBetweenOrEqual

func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) error

ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. It ensures that the actual value is nopt between the bounds nor equal to either of them.

func ShouldNotBeBlank

func ShouldNotBeBlank(actual interface{}, expected ...interface{}) error

ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is equal to "".

func ShouldNotBeEmpty

func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) error

ShouldNotBeEmpty receives a single parameter (actual) and determines whether or not calling len(actual) would return a value greater than zero.

func ShouldNotBeIn

func ShouldNotBeIn(actual interface{}, expected ...interface{}) error

ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of the collection that is passed in either as the second parameter, or of the collection that is comprised of all the remaining parameters. This assertion ensures that the proposed member is NOT in the collection (using ShouldEqual).

func ShouldNotBeNil

func ShouldNotBeNil(actual interface{}, expected ...interface{}) error

ShouldNotBeNil receives a single parameter and ensures that it is not nil.

func ShouldNotContain

func ShouldNotContain(actual interface{}, expected ...interface{}) error

ShouldNotContain receives exactly two parameters. The first is a slice and the second is a proposed member. Membership is determinied using ShouldEqual.

func ShouldNotContainKey

func ShouldNotContainKey(actual interface{}, expected ...interface{}) error

ShouldNotContainKey receives exactly two parameters. The first is a map and the second is a proposed absent key.

func ShouldNotContainSubstring

func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) error

ShouldNotContainSubstring receives exactly 2 string parameters and ensures that the first does NOT contain the second as a substring.

func ShouldNotEndWith

func ShouldNotEndWith(actual interface{}, expected ...interface{}) error

ShouldNotEndWith receives exactly 2 string parameters and ensures that the first does not end with the second.

func ShouldNotEqual

func ShouldNotEqual(actual interface{}, expected ...interface{}) error

ShouldNotEqual receives exactly two parameters and does an inequality check.

func ShouldNotExist

func ShouldNotExist(actual interface{}, expected ...interface{}) error

ShouldNotExist receives a single parameter and ensures that it is nil, blank or zero value

func ShouldNotStartWith

func ShouldNotStartWith(actual interface{}, expected ...interface{}) error

ShouldNotStartWith receives exactly 2 string parameters and ensures that the first does not start with the second.

func ShouldStartWith

func ShouldStartWith(actual interface{}, expected ...interface{}) error

ShouldStartWith receives exactly 2 string parameters and ensures that the first starts with the second.

Types

type AssertFunc

type AssertFunc func(actual interface{}, expected ...interface{}) error

func Get

func Get(s string) (AssertFunc, bool)

type AssertionError

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

func (*AssertionError) Error

func (e *AssertionError) Error() string

Jump to

Keyboard shortcuts

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