2017-04-26 23:02:00 +00:00
|
|
|
/*
|
|
|
|
* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
|
|
|
|
* THIS FILE MUST NOT BE EDITED BY HAND
|
2018-02-07 22:30:05 +00:00
|
|
|
*/
|
2017-04-26 23:02:00 +00:00
|
|
|
|
|
|
|
package require
|
|
|
|
|
|
|
|
import (
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
assert "github.com/stretchr/testify/assert"
|
|
|
|
http "net/http"
|
|
|
|
url "net/url"
|
|
|
|
time "time"
|
|
|
|
)
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Condition uses a Comparison to assert a complex condition.
|
|
|
|
func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Condition(t, comp, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
|
|
|
// specified substring or element.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'")
|
|
|
|
// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
|
|
|
|
// assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Contains(t, s, contains, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
|
|
|
// a slice or a channel with len == 0.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.Empty(t, obj)
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Empty(t, object, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Equal asserts that two objects are equal.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.Equal(t, 123, 123, "123 and 123 should be equal")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Equal(t, expected, actual, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// EqualError asserts that a function returned an error (i.e. not `nil`)
|
|
|
|
// and that it is equal to the provided error.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// actualObj, err := SomeFunction()
|
2018-02-07 22:30:05 +00:00
|
|
|
// if assert.Error(t, err, "An error was expected") {
|
|
|
|
// assert.Equal(t, err, expectedError)
|
|
|
|
// }
|
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.EqualError(t, theError, errString, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
|
|
|
// and equal.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.EqualValues(t, expected, actual, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Error asserts that a function returned an error (i.e. not `nil`).
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// actualObj, err := SomeFunction()
|
|
|
|
// if assert.Error(t, err, "An error was expected") {
|
|
|
|
// assert.Equal(t, err, expectedError)
|
|
|
|
// }
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func Error(t TestingT, err error, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Error(t, err, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Exactly asserts that two objects are equal is value and type.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Exactly(t, expected, actual, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Fail reports a failure through
|
|
|
|
func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Fail(t, failureMessage, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// FailNow fails test
|
|
|
|
func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.FailNow(t, failureMessage, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// False asserts that the specified value is false.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.False(t, myBool, "myBool should be false")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func False(t TestingT, value bool, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.False(t, value, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// HTTPBodyContains asserts that a specified handler returns a
|
|
|
|
// body that contains a string.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.HTTPBodyContains(t, handler, method, url, values, str) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// HTTPBodyNotContains asserts that a specified handler returns a
|
|
|
|
// body that does not contain a string.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.HTTPBodyNotContains(t, handler, method, url, values, str) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// HTTPError asserts that a specified handler returns an error status code.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.HTTPError(t, handler, method, url, values) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.HTTPRedirect(t, handler, method, url, values) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// HTTPSuccess asserts that a specified handler returns a success status code.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.HTTPSuccess(t, handler, method, url, values) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Implements asserts that an object is implemented by the specified interface.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject")
|
|
|
|
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Implements(t, interfaceObject, object, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// InDelta asserts that the two numerals are within delta of each other.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// InDeltaSlice is the same as InDelta, except it compares two slices.
|
|
|
|
func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
|
|
|
// InEpsilonSlice is the same as InEpsilon, except it compares two slices.
|
|
|
|
func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
|
|
|
if !assert.InEpsilonSlice(t, expected, actual, delta, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// IsType asserts that the specified objects are of the same type.
|
|
|
|
func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.IsType(t, expectedType, object, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// JSONEq asserts that two JSON strings are equivalent.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.JSONEq(t, expected, actual, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Len asserts that the specified object has specific length.
|
|
|
|
// Len also fails if the object has a type that len() not accept.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.Len(t, mySlice, 3, "The size of slice is not 3")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Len(t, object, length, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Nil asserts that the specified object is nil.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.Nil(t, err, "err should be nothing")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Nil(t, object, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// NoError asserts that a function returned no error (i.e. `nil`).
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// actualObj, err := SomeFunction()
|
|
|
|
// if assert.NoError(t, err) {
|
|
|
|
// assert.Equal(t, actualObj, expectedObj)
|
|
|
|
// }
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.NoError(t, err, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
|
|
|
// specified substring or element.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
|
|
|
|
// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
|
|
|
|
// assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.NotContains(t, s, contains, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
|
|
|
// a slice or a channel with len == 0.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// if assert.NotEmpty(t, obj) {
|
|
|
|
// assert.Equal(t, "two", obj[1])
|
|
|
|
// }
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.NotEmpty(t, object, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// NotEqual asserts that the specified values are NOT equal.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.NotEqual(t, expected, actual, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// NotNil asserts that the specified object is not nil.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.NotNil(t, err, "err should be something")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.NotNil(t, object, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.NotPanics(t, func(){
|
|
|
|
// RemainCalm()
|
|
|
|
// }, "Calling RemainCalm() should NOT panic")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.NotPanics(t, f, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// NotRegexp asserts that a specified regexp does not match a string.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
|
|
|
|
// assert.NotRegexp(t, "^start", "it's not starting")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.NotRegexp(t, rx, str, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
|
|
|
func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.NotZero(t, i, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.Panics(t, func(){
|
|
|
|
// GoCrazy()
|
|
|
|
// }, "Calling GoCrazy() should panic")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Panics(t, f, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Regexp asserts that a specified regexp matches a string.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
|
|
|
|
// assert.Regexp(t, "start...$", "it's not starting")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Regexp(t, rx, str, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// True asserts that the specified value is true.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.True(t, myBool, "myBool should be true")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func True(t TestingT, value bool, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.True(t, value, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// WithinDuration asserts that the two times are within duration delta of each other.
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
|
2018-02-07 22:30:05 +00:00
|
|
|
//
|
2017-04-26 23:02:00 +00:00
|
|
|
// Returns whether the assertion was successful (true) or not (false).
|
|
|
|
func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 22:30:05 +00:00
|
|
|
|
2017-04-26 23:02:00 +00:00
|
|
|
// Zero asserts that i is the zero value for its type and returns the truth.
|
|
|
|
func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
2018-02-07 22:30:05 +00:00
|
|
|
if !assert.Zero(t, i, msgAndArgs...) {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2017-04-26 23:02:00 +00:00
|
|
|
}
|