Documentation ¶
Index ¶
- func Convey(description string, t *testing.T, f func())
- func Eval(f assert.EvalFunc, msgAndArgs ...interface{}) bool
- func Fail(failureMessage string, msgAndArgs ...interface{}) bool
- func FailNow(failureMessage string, msgAndArgs ...interface{}) bool
- func InDelta(expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool
- func IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool
- func JsonShouldEq(expected string, actual string, msgAndArgs ...interface{}) bool
- func Log() log.ILogger
- func MarshalJSON(obj interface{}) string
- func MarshalJSONIndent(obj interface{}) string
- func MarshalYAML(obj interface{}) string
- func OnFailure(handler func())
- func PrintObj(msg string, obj interface{}, writer ...io.Writer)
- func ShouldBeEmpty(object interface{}, msgAndArgs ...interface{}) bool
- func ShouldBeFalse(value bool, msgAndArgs ...interface{}) bool
- func ShouldBeNil(object interface{}, msgAndArgs ...interface{}) bool
- func ShouldBeTrue(value bool, msgAndArgs ...interface{}) bool
- func ShouldContain(s, contains interface{}, msgAndArgs ...interface{}) bool
- func ShouldEqual(expected, actual interface{}, msgAndArgs ...interface{}) bool
- func ShouldEqualError(err error, errString string, msgAndArgs ...interface{}) bool
- func ShouldEqualValues(expected, actual interface{}, msgAndArgs ...interface{}) bool
- func ShouldError(err error, msgAndArgs ...interface{}) bool
- func ShouldHaveSubset(list, subset interface{}, msgAndArgs ...interface{}) (ok bool)
- func ShouldImplement(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool
- func ShouldLen(object interface{}, length int, msgAndArgs ...interface{}) bool
- func ShouldMatchElements(listA, listB interface{}, msgAndArgs ...interface{}) bool
- func ShouldMatchExactly(expected, actual interface{}, msgAndArgs ...interface{}) bool
- func ShouldMatchRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
- func ShouldNotBeEmpty(object interface{}, msgAndArgs ...interface{}) bool
- func ShouldNotBeEqual(expected, actual interface{}, msgAndArgs ...interface{}) bool
- func ShouldNotBeNil(object interface{}, msgAndArgs ...interface{}) bool
- func ShouldNotContain(s, contains interface{}, msgAndArgs ...interface{}) bool
- func ShouldNotError(err error, msgAndArgs ...interface{}) bool
- func ShouldNotHaveSubset(list, subset interface{}, msgAndArgs ...interface{}) (ok bool)
- func ShouldNotMatchRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
- func ShouldNotPanic(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func ShouldNotZero(i interface{}, msgAndArgs ...interface{}) bool
- func ShouldPanic(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func ShouldPanicWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- func ShouldZero(i interface{}, msgAndArgs ...interface{}) bool
- func WithinDuration(expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InDelta ¶
InDelta asserts that the two numerals are within delta of each other.
InDelta(math.Pi, (22 / 7.0), 0.01)
func IsType ¶
func IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool
IsType asserts that the specified objects are of the same type.
func JsonShouldEq ¶
JSONEq asserts that two JSON strings are equivalent.
JsonShouldEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
func MarshalJSON ¶ added in v1.0.8
func MarshalJSON(obj interface{}) string
func MarshalJSONIndent ¶ added in v1.0.8
func MarshalJSONIndent(obj interface{}) string
func MarshalYAML ¶ added in v1.0.8
func MarshalYAML(obj interface{}) string
func OnFailure ¶ added in v1.0.5
func OnFailure(handler func())
OnFailure registers a callback that will be executed if a test fails
func ShouldBeEmpty ¶
func ShouldBeEmpty(object interface{}, msgAndArgs ...interface{}) bool
ShouldBeEmpty asserts that the specified object is empty. I.e. nil, "", false, 0 or either a slice or a channel with len == 0.
ShouldBeEmpty(obj)
func ShouldBeNil ¶
func ShouldBeNil(object interface{}, msgAndArgs ...interface{}) bool
ShouldBeNil asserts that the specified object is nil.
ShouldBeNil(err)
func ShouldContain ¶
func ShouldContain(s, contains interface{}, msgAndArgs ...interface{}) bool
ShouldContain asserts that the specified string, list(array, slice...) or map contains the specified substring or element.
ShouldContain("Hello World", "World") ShouldContain(["Hello", "World"], "World") ShouldContain({"Hello": "World"}, "Hello")
func ShouldEqual ¶
func ShouldEqual(expected, actual interface{}, msgAndArgs ...interface{}) bool
ShouldEqual asserts that two objects are equal.
ShouldEqual(123, 123)
Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses). Function equality cannot be determined and will always fail.
func ShouldEqualError ¶
ShouldEqualError asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error.
actualObj, err := SomeFunction() ShouldEqualError(err, expectedErrorString)
func ShouldEqualValues ¶
func ShouldEqualValues(expected, actual interface{}, msgAndArgs ...interface{}) bool
EqualValues asserts that two objects are equal or convertable to the same types and equal.
EqualValues(uint32(123), int32(123))
func ShouldError ¶
ShouldError asserts that a function returned an error (i.e. not `nil`).
actualObj, err := SomeFunction() if ShouldError(err) { ShouldEqual(expectedError, err) }
func ShouldHaveSubset ¶
func ShouldHaveSubset(list, subset interface{}, msgAndArgs ...interface{}) (ok bool)
ShouldHaveSubset asserts that the specified list(array, slice...) contains all elements given in the specified subset(array, slice...).
ShouldHaveSubset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
func ShouldImplement ¶
func ShouldImplement(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool
ShouldImplement asserts that an object is implemented by the specified interface.
ShouldImplement((*MyInterface)(nil), new(MyObject))
func ShouldLen ¶
ShouldLen asserts that the specified object has specific length. ShouldLen also fails if the object has a type that len() not accept.
ShouldLen(mySlice, 3)
func ShouldMatchElements ¶
func ShouldMatchElements(listA, listB interface{}, msgAndArgs ...interface{}) bool
ShouldMatchElements asserts that the specified listA(array, slice...) is equal to specified listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, the number of appearances of each of them in both lists should match.
ShouldMatchElements([1, 3, 2, 3], [1, 3, 3, 2])
func ShouldMatchExactly ¶
func ShouldMatchExactly(expected, actual interface{}, msgAndArgs ...interface{}) bool
ShouldMatchExactly asserts that two objects are equal in value and type.
ShouldMatchExactly(int32(123), int64(123))
func ShouldMatchRegexp ¶
func ShouldMatchRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
ShouldMatchRegexp asserts that a specified regexp matches a string.
ShouldMatchRegexp(regexp.MustCompile("start"), "it's starting") ShouldMatchRegexp("start...$", "it's not starting")
func ShouldNotBeEmpty ¶
func ShouldNotBeEmpty(object interface{}, msgAndArgs ...interface{}) bool
ShouldNotBeEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either a slice or a channel with len == 0.
if ShouldNotBeEmpty(obj) { ShouldBeEqual("two", obj[1]) }
func ShouldNotBeEqual ¶
func ShouldNotBeEqual(expected, actual interface{}, msgAndArgs ...interface{}) bool
ShouldNotBeEqual asserts that the specified values are NOT equal.
ShouldNotBeEqual(obj1, obj2)
Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses).
func ShouldNotBeNil ¶
func ShouldNotBeNil(object interface{}, msgAndArgs ...interface{}) bool
ShouldNotBeNil asserts that the specified object is not nil.
ShouldNotBeNil(err)
func ShouldNotContain ¶
func ShouldNotContain(s, contains interface{}, msgAndArgs ...interface{}) bool
ShouldNotContain asserts that the specified string, list(array, slice...) or map does NOT contain the specified substring or element.
ShouldNotContain("Hello World", "Earth") ShouldNotContain(["Hello", "World"], "Earth") ShouldNotContain({"Hello": "World"}, "Earth")
func ShouldNotError ¶
ShouldNotError asserts that a function returned no error (i.e. `nil`).
actualObj, err := SomeFunction() if ShouldNotError(err) { ShouldEqual(expectedObj, actualObj) }
func ShouldNotHaveSubset ¶
func ShouldNotHaveSubset(list, subset interface{}, msgAndArgs ...interface{}) (ok bool)
ShouldNotHaveSubset asserts that the specified list(array, slice...) contains not all elements given in the specified subset(array, slice...).
ShouldNotHaveSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
func ShouldNotMatchRegexp ¶
func ShouldNotMatchRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool
ShouldNotMatchRegexp asserts that a specified regexp does not match a string.
ShouldNotMatchRegexp(regexp.MustCompile("starts"), "it's starting") ShouldNotMatchRegexp("^start", "it's not starting")
func ShouldNotPanic ¶
func ShouldNotPanic(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
ShouldNotPanic asserts that the code inside the specified PanicTestFunc does NOT panic.
ShouldNotPanic(func(){ RemainCalm() })
func ShouldNotZero ¶
func ShouldNotZero(i interface{}, msgAndArgs ...interface{}) bool
NotZero asserts that i is not the zero value for its type.
func ShouldPanic ¶
func ShouldPanic(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
ShouldPanic asserts that the code inside the specified PanicTestFunc panics.
ShouldPanic(func(){ GoCrazy() })
func ShouldPanicWithValue ¶
func ShouldPanicWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
ShouldPanicWithValue asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value equals the expected panic value.
ShouldPanicWithValue("crazy error", func(){ GoCrazy() })
func ShouldZero ¶
func ShouldZero(i interface{}, msgAndArgs ...interface{}) bool
ShouldZero asserts that i is the zero value for its type.
Types ¶
This section is empty.