...

Source file src/github.com/stretchr/testify/assert/assertion_format.go

Documentation: github.com/stretchr/testify/assert

     1  // Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
     2  
     3  package assert
     4  
     5  import (
     6  	http "net/http"
     7  	url "net/url"
     8  	time "time"
     9  )
    10  
    11  // Conditionf uses a Comparison to assert a complex condition.
    12  func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
    13  	if h, ok := t.(tHelper); ok {
    14  		h.Helper()
    15  	}
    16  	return Condition(t, comp, append([]interface{}{msg}, args...)...)
    17  }
    18  
    19  // Containsf asserts that the specified string, list(array, slice...) or map contains the
    20  // specified substring or element.
    21  //
    22  //	assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
    23  //	assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
    24  //	assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
    25  func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
    26  	if h, ok := t.(tHelper); ok {
    27  		h.Helper()
    28  	}
    29  	return Contains(t, s, contains, append([]interface{}{msg}, args...)...)
    30  }
    31  
    32  // DirExistsf checks whether a directory exists in the given path. It also fails
    33  // if the path is a file rather a directory or there is an error checking whether it exists.
    34  func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
    35  	if h, ok := t.(tHelper); ok {
    36  		h.Helper()
    37  	}
    38  	return DirExists(t, path, append([]interface{}{msg}, args...)...)
    39  }
    40  
    41  // ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
    42  // listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
    43  // the number of appearances of each of them in both lists should match.
    44  //
    45  // assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
    46  func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
    47  	if h, ok := t.(tHelper); ok {
    48  		h.Helper()
    49  	}
    50  	return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
    51  }
    52  
    53  // Emptyf asserts that the specified object is empty.  I.e. nil, "", false, 0 or either
    54  // a slice or a channel with len == 0.
    55  //
    56  //	assert.Emptyf(t, obj, "error message %s", "formatted")
    57  func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
    58  	if h, ok := t.(tHelper); ok {
    59  		h.Helper()
    60  	}
    61  	return Empty(t, object, append([]interface{}{msg}, args...)...)
    62  }
    63  
    64  // Equalf asserts that two objects are equal.
    65  //
    66  //	assert.Equalf(t, 123, 123, "error message %s", "formatted")
    67  //
    68  // Pointer variable equality is determined based on the equality of the
    69  // referenced values (as opposed to the memory addresses). Function equality
    70  // cannot be determined and will always fail.
    71  func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
    72  	if h, ok := t.(tHelper); ok {
    73  		h.Helper()
    74  	}
    75  	return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
    76  }
    77  
    78  // EqualErrorf asserts that a function returned an error (i.e. not `nil`)
    79  // and that it is equal to the provided error.
    80  //
    81  //	actualObj, err := SomeFunction()
    82  //	assert.EqualErrorf(t, err,  expectedErrorString, "error message %s", "formatted")
    83  func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool {
    84  	if h, ok := t.(tHelper); ok {
    85  		h.Helper()
    86  	}
    87  	return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
    88  }
    89  
    90  // EqualExportedValuesf asserts that the types of two objects are equal and their public
    91  // fields are also equal. This is useful for comparing structs that have private fields
    92  // that could potentially differ.
    93  //
    94  //	 type S struct {
    95  //		Exported     	int
    96  //		notExported   	int
    97  //	 }
    98  //	 assert.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
    99  //	 assert.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
   100  func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
   101  	if h, ok := t.(tHelper); ok {
   102  		h.Helper()
   103  	}
   104  	return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
   105  }
   106  
   107  // EqualValuesf asserts that two objects are equal or convertible to the same types
   108  // and equal.
   109  //
   110  //	assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
   111  func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
   112  	if h, ok := t.(tHelper); ok {
   113  		h.Helper()
   114  	}
   115  	return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
   116  }
   117  
   118  // Errorf asserts that a function returned an error (i.e. not `nil`).
   119  //
   120  //	  actualObj, err := SomeFunction()
   121  //	  if assert.Errorf(t, err, "error message %s", "formatted") {
   122  //		   assert.Equal(t, expectedErrorf, err)
   123  //	  }
   124  func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
   125  	if h, ok := t.(tHelper); ok {
   126  		h.Helper()
   127  	}
   128  	return Error(t, err, append([]interface{}{msg}, args...)...)
   129  }
   130  
   131  // ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
   132  // This is a wrapper for errors.As.
   133  func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
   134  	if h, ok := t.(tHelper); ok {
   135  		h.Helper()
   136  	}
   137  	return ErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
   138  }
   139  
   140  // ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
   141  // and that the error contains the specified substring.
   142  //
   143  //	actualObj, err := SomeFunction()
   144  //	assert.ErrorContainsf(t, err,  expectedErrorSubString, "error message %s", "formatted")
   145  func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) bool {
   146  	if h, ok := t.(tHelper); ok {
   147  		h.Helper()
   148  	}
   149  	return ErrorContains(t, theError, contains, append([]interface{}{msg}, args...)...)
   150  }
   151  
   152  // ErrorIsf asserts that at least one of the errors in err's chain matches target.
   153  // This is a wrapper for errors.Is.
   154  func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
   155  	if h, ok := t.(tHelper); ok {
   156  		h.Helper()
   157  	}
   158  	return ErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
   159  }
   160  
   161  // Eventuallyf asserts that given condition will be met in waitFor time,
   162  // periodically checking target function each tick.
   163  //
   164  //	assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
   165  func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
   166  	if h, ok := t.(tHelper); ok {
   167  		h.Helper()
   168  	}
   169  	return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
   170  }
   171  
   172  // EventuallyWithTf asserts that given condition will be met in waitFor time,
   173  // periodically checking target function each tick. In contrast to Eventually,
   174  // it supplies a CollectT to the condition function, so that the condition
   175  // function can use the CollectT to call other assertions.
   176  // The condition is considered "met" if no errors are raised in a tick.
   177  // The supplied CollectT collects all errors from one tick (if there are any).
   178  // If the condition is not met before waitFor, the collected errors of
   179  // the last tick are copied to t.
   180  //
   181  //	externalValue := false
   182  //	go func() {
   183  //		time.Sleep(8*time.Second)
   184  //		externalValue = true
   185  //	}()
   186  //	assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
   187  //		// add assertions as needed; any assertion failure will fail the current tick
   188  //		assert.True(c, externalValue, "expected 'externalValue' to be true")
   189  //	}, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
   190  func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
   191  	if h, ok := t.(tHelper); ok {
   192  		h.Helper()
   193  	}
   194  	return EventuallyWithT(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
   195  }
   196  
   197  // Exactlyf asserts that two objects are equal in value and type.
   198  //
   199  //	assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
   200  func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
   201  	if h, ok := t.(tHelper); ok {
   202  		h.Helper()
   203  	}
   204  	return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...)
   205  }
   206  
   207  // Failf reports a failure through
   208  func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
   209  	if h, ok := t.(tHelper); ok {
   210  		h.Helper()
   211  	}
   212  	return Fail(t, failureMessage, append([]interface{}{msg}, args...)...)
   213  }
   214  
   215  // FailNowf fails test
   216  func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
   217  	if h, ok := t.(tHelper); ok {
   218  		h.Helper()
   219  	}
   220  	return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...)
   221  }
   222  
   223  // Falsef asserts that the specified value is false.
   224  //
   225  //	assert.Falsef(t, myBool, "error message %s", "formatted")
   226  func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
   227  	if h, ok := t.(tHelper); ok {
   228  		h.Helper()
   229  	}
   230  	return False(t, value, append([]interface{}{msg}, args...)...)
   231  }
   232  
   233  // FileExistsf checks whether a file exists in the given path. It also fails if
   234  // the path points to a directory or there is an error when trying to check the file.
   235  func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
   236  	if h, ok := t.(tHelper); ok {
   237  		h.Helper()
   238  	}
   239  	return FileExists(t, path, append([]interface{}{msg}, args...)...)
   240  }
   241  
   242  // Greaterf asserts that the first element is greater than the second
   243  //
   244  //	assert.Greaterf(t, 2, 1, "error message %s", "formatted")
   245  //	assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")
   246  //	assert.Greaterf(t, "b", "a", "error message %s", "formatted")
   247  func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
   248  	if h, ok := t.(tHelper); ok {
   249  		h.Helper()
   250  	}
   251  	return Greater(t, e1, e2, append([]interface{}{msg}, args...)...)
   252  }
   253  
   254  // GreaterOrEqualf asserts that the first element is greater than or equal to the second
   255  //
   256  //	assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")
   257  //	assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")
   258  //	assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")
   259  //	assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
   260  func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
   261  	if h, ok := t.(tHelper); ok {
   262  		h.Helper()
   263  	}
   264  	return GreaterOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
   265  }
   266  
   267  // HTTPBodyContainsf asserts that a specified handler returns a
   268  // body that contains a string.
   269  //
   270  //	assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
   271  //
   272  // Returns whether the assertion was successful (true) or not (false).
   273  func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
   274  	if h, ok := t.(tHelper); ok {
   275  		h.Helper()
   276  	}
   277  	return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
   278  }
   279  
   280  // HTTPBodyNotContainsf asserts that a specified handler returns a
   281  // body that does not contain a string.
   282  //
   283  //	assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
   284  //
   285  // Returns whether the assertion was successful (true) or not (false).
   286  func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
   287  	if h, ok := t.(tHelper); ok {
   288  		h.Helper()
   289  	}
   290  	return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
   291  }
   292  
   293  // HTTPErrorf asserts that a specified handler returns an error status code.
   294  //
   295  //	assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
   296  //
   297  // Returns whether the assertion was successful (true) or not (false).
   298  func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
   299  	if h, ok := t.(tHelper); ok {
   300  		h.Helper()
   301  	}
   302  	return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
   303  }
   304  
   305  // HTTPRedirectf asserts that a specified handler returns a redirect status code.
   306  //
   307  //	assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
   308  //
   309  // Returns whether the assertion was successful (true) or not (false).
   310  func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
   311  	if h, ok := t.(tHelper); ok {
   312  		h.Helper()
   313  	}
   314  	return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
   315  }
   316  
   317  // HTTPStatusCodef asserts that a specified handler returns a specified status code.
   318  //
   319  //	assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
   320  //
   321  // Returns whether the assertion was successful (true) or not (false).
   322  func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
   323  	if h, ok := t.(tHelper); ok {
   324  		h.Helper()
   325  	}
   326  	return HTTPStatusCode(t, handler, method, url, values, statuscode, append([]interface{}{msg}, args...)...)
   327  }
   328  
   329  // HTTPSuccessf asserts that a specified handler returns a success status code.
   330  //
   331  //	assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
   332  //
   333  // Returns whether the assertion was successful (true) or not (false).
   334  func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
   335  	if h, ok := t.(tHelper); ok {
   336  		h.Helper()
   337  	}
   338  	return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
   339  }
   340  
   341  // Implementsf asserts that an object is implemented by the specified interface.
   342  //
   343  //	assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
   344  func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
   345  	if h, ok := t.(tHelper); ok {
   346  		h.Helper()
   347  	}
   348  	return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
   349  }
   350  
   351  // InDeltaf asserts that the two numerals are within delta of each other.
   352  //
   353  //	assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
   354  func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
   355  	if h, ok := t.(tHelper); ok {
   356  		h.Helper()
   357  	}
   358  	return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
   359  }
   360  
   361  // InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
   362  func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
   363  	if h, ok := t.(tHelper); ok {
   364  		h.Helper()
   365  	}
   366  	return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
   367  }
   368  
   369  // InDeltaSlicef is the same as InDelta, except it compares two slices.
   370  func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
   371  	if h, ok := t.(tHelper); ok {
   372  		h.Helper()
   373  	}
   374  	return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
   375  }
   376  
   377  // InEpsilonf asserts that expected and actual have a relative error less than epsilon
   378  func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
   379  	if h, ok := t.(tHelper); ok {
   380  		h.Helper()
   381  	}
   382  	return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
   383  }
   384  
   385  // InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
   386  func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
   387  	if h, ok := t.(tHelper); ok {
   388  		h.Helper()
   389  	}
   390  	return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
   391  }
   392  
   393  // IsDecreasingf asserts that the collection is decreasing
   394  //
   395  //	assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")
   396  //	assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")
   397  //	assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
   398  func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
   399  	if h, ok := t.(tHelper); ok {
   400  		h.Helper()
   401  	}
   402  	return IsDecreasing(t, object, append([]interface{}{msg}, args...)...)
   403  }
   404  
   405  // IsIncreasingf asserts that the collection is increasing
   406  //
   407  //	assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")
   408  //	assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")
   409  //	assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
   410  func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
   411  	if h, ok := t.(tHelper); ok {
   412  		h.Helper()
   413  	}
   414  	return IsIncreasing(t, object, append([]interface{}{msg}, args...)...)
   415  }
   416  
   417  // IsNonDecreasingf asserts that the collection is not decreasing
   418  //
   419  //	assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")
   420  //	assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")
   421  //	assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
   422  func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
   423  	if h, ok := t.(tHelper); ok {
   424  		h.Helper()
   425  	}
   426  	return IsNonDecreasing(t, object, append([]interface{}{msg}, args...)...)
   427  }
   428  
   429  // IsNonIncreasingf asserts that the collection is not increasing
   430  //
   431  //	assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")
   432  //	assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")
   433  //	assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
   434  func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
   435  	if h, ok := t.(tHelper); ok {
   436  		h.Helper()
   437  	}
   438  	return IsNonIncreasing(t, object, append([]interface{}{msg}, args...)...)
   439  }
   440  
   441  // IsTypef asserts that the specified objects are of the same type.
   442  func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
   443  	if h, ok := t.(tHelper); ok {
   444  		h.Helper()
   445  	}
   446  	return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...)
   447  }
   448  
   449  // JSONEqf asserts that two JSON strings are equivalent.
   450  //
   451  //	assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
   452  func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
   453  	if h, ok := t.(tHelper); ok {
   454  		h.Helper()
   455  	}
   456  	return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...)
   457  }
   458  
   459  // Lenf asserts that the specified object has specific length.
   460  // Lenf also fails if the object has a type that len() not accept.
   461  //
   462  //	assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
   463  func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool {
   464  	if h, ok := t.(tHelper); ok {
   465  		h.Helper()
   466  	}
   467  	return Len(t, object, length, append([]interface{}{msg}, args...)...)
   468  }
   469  
   470  // Lessf asserts that the first element is less than the second
   471  //
   472  //	assert.Lessf(t, 1, 2, "error message %s", "formatted")
   473  //	assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted")
   474  //	assert.Lessf(t, "a", "b", "error message %s", "formatted")
   475  func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
   476  	if h, ok := t.(tHelper); ok {
   477  		h.Helper()
   478  	}
   479  	return Less(t, e1, e2, append([]interface{}{msg}, args...)...)
   480  }
   481  
   482  // LessOrEqualf asserts that the first element is less than or equal to the second
   483  //
   484  //	assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted")
   485  //	assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted")
   486  //	assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted")
   487  //	assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
   488  func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
   489  	if h, ok := t.(tHelper); ok {
   490  		h.Helper()
   491  	}
   492  	return LessOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
   493  }
   494  
   495  // Negativef asserts that the specified element is negative
   496  //
   497  //	assert.Negativef(t, -1, "error message %s", "formatted")
   498  //	assert.Negativef(t, -1.23, "error message %s", "formatted")
   499  func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
   500  	if h, ok := t.(tHelper); ok {
   501  		h.Helper()
   502  	}
   503  	return Negative(t, e, append([]interface{}{msg}, args...)...)
   504  }
   505  
   506  // Neverf asserts that the given condition doesn't satisfy in waitFor time,
   507  // periodically checking the target function each tick.
   508  //
   509  //	assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
   510  func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
   511  	if h, ok := t.(tHelper); ok {
   512  		h.Helper()
   513  	}
   514  	return Never(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
   515  }
   516  
   517  // Nilf asserts that the specified object is nil.
   518  //
   519  //	assert.Nilf(t, err, "error message %s", "formatted")
   520  func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
   521  	if h, ok := t.(tHelper); ok {
   522  		h.Helper()
   523  	}
   524  	return Nil(t, object, append([]interface{}{msg}, args...)...)
   525  }
   526  
   527  // NoDirExistsf checks whether a directory does not exist in the given path.
   528  // It fails if the path points to an existing _directory_ only.
   529  func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
   530  	if h, ok := t.(tHelper); ok {
   531  		h.Helper()
   532  	}
   533  	return NoDirExists(t, path, append([]interface{}{msg}, args...)...)
   534  }
   535  
   536  // NoErrorf asserts that a function returned no error (i.e. `nil`).
   537  //
   538  //	  actualObj, err := SomeFunction()
   539  //	  if assert.NoErrorf(t, err, "error message %s", "formatted") {
   540  //		   assert.Equal(t, expectedObj, actualObj)
   541  //	  }
   542  func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool {
   543  	if h, ok := t.(tHelper); ok {
   544  		h.Helper()
   545  	}
   546  	return NoError(t, err, append([]interface{}{msg}, args...)...)
   547  }
   548  
   549  // NoFileExistsf checks whether a file does not exist in a given path. It fails
   550  // if the path points to an existing _file_ only.
   551  func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
   552  	if h, ok := t.(tHelper); ok {
   553  		h.Helper()
   554  	}
   555  	return NoFileExists(t, path, append([]interface{}{msg}, args...)...)
   556  }
   557  
   558  // NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
   559  // specified substring or element.
   560  //
   561  //	assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
   562  //	assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
   563  //	assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
   564  func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
   565  	if h, ok := t.(tHelper); ok {
   566  		h.Helper()
   567  	}
   568  	return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
   569  }
   570  
   571  // NotEmptyf asserts that the specified object is NOT empty.  I.e. not nil, "", false, 0 or either
   572  // a slice or a channel with len == 0.
   573  //
   574  //	if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
   575  //	  assert.Equal(t, "two", obj[1])
   576  //	}
   577  func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
   578  	if h, ok := t.(tHelper); ok {
   579  		h.Helper()
   580  	}
   581  	return NotEmpty(t, object, append([]interface{}{msg}, args...)...)
   582  }
   583  
   584  // NotEqualf asserts that the specified values are NOT equal.
   585  //
   586  //	assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
   587  //
   588  // Pointer variable equality is determined based on the equality of the
   589  // referenced values (as opposed to the memory addresses).
   590  func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
   591  	if h, ok := t.(tHelper); ok {
   592  		h.Helper()
   593  	}
   594  	return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...)
   595  }
   596  
   597  // NotEqualValuesf asserts that two objects are not equal even when converted to the same type
   598  //
   599  //	assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
   600  func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
   601  	if h, ok := t.(tHelper); ok {
   602  		h.Helper()
   603  	}
   604  	return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
   605  }
   606  
   607  // NotErrorIsf asserts that at none of the errors in err's chain matches target.
   608  // This is a wrapper for errors.Is.
   609  func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
   610  	if h, ok := t.(tHelper); ok {
   611  		h.Helper()
   612  	}
   613  	return NotErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
   614  }
   615  
   616  // NotImplementsf asserts that an object does not implement the specified interface.
   617  //
   618  //	assert.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
   619  func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
   620  	if h, ok := t.(tHelper); ok {
   621  		h.Helper()
   622  	}
   623  	return NotImplements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
   624  }
   625  
   626  // NotNilf asserts that the specified object is not nil.
   627  //
   628  //	assert.NotNilf(t, err, "error message %s", "formatted")
   629  func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
   630  	if h, ok := t.(tHelper); ok {
   631  		h.Helper()
   632  	}
   633  	return NotNil(t, object, append([]interface{}{msg}, args...)...)
   634  }
   635  
   636  // NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
   637  //
   638  //	assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
   639  func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
   640  	if h, ok := t.(tHelper); ok {
   641  		h.Helper()
   642  	}
   643  	return NotPanics(t, f, append([]interface{}{msg}, args...)...)
   644  }
   645  
   646  // NotRegexpf asserts that a specified regexp does not match a string.
   647  //
   648  //	assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
   649  //	assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
   650  func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
   651  	if h, ok := t.(tHelper); ok {
   652  		h.Helper()
   653  	}
   654  	return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...)
   655  }
   656  
   657  // NotSamef asserts that two pointers do not reference the same object.
   658  //
   659  //	assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")
   660  //
   661  // Both arguments must be pointer variables. Pointer variable sameness is
   662  // determined based on the equality of both type and value.
   663  func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
   664  	if h, ok := t.(tHelper); ok {
   665  		h.Helper()
   666  	}
   667  	return NotSame(t, expected, actual, append([]interface{}{msg}, args...)...)
   668  }
   669  
   670  // NotSubsetf asserts that the specified list(array, slice...) or map does NOT
   671  // contain all elements given in the specified subset list(array, slice...) or
   672  // map.
   673  //
   674  //	assert.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted")
   675  //	assert.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
   676  func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
   677  	if h, ok := t.(tHelper); ok {
   678  		h.Helper()
   679  	}
   680  	return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...)
   681  }
   682  
   683  // NotZerof asserts that i is not the zero value for its type.
   684  func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
   685  	if h, ok := t.(tHelper); ok {
   686  		h.Helper()
   687  	}
   688  	return NotZero(t, i, append([]interface{}{msg}, args...)...)
   689  }
   690  
   691  // Panicsf asserts that the code inside the specified PanicTestFunc panics.
   692  //
   693  //	assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
   694  func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
   695  	if h, ok := t.(tHelper); ok {
   696  		h.Helper()
   697  	}
   698  	return Panics(t, f, append([]interface{}{msg}, args...)...)
   699  }
   700  
   701  // PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
   702  // panics, and that the recovered panic value is an error that satisfies the
   703  // EqualError comparison.
   704  //
   705  //	assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
   706  func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
   707  	if h, ok := t.(tHelper); ok {
   708  		h.Helper()
   709  	}
   710  	return PanicsWithError(t, errString, f, append([]interface{}{msg}, args...)...)
   711  }
   712  
   713  // PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
   714  // the recovered panic value equals the expected panic value.
   715  //
   716  //	assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
   717  func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
   718  	if h, ok := t.(tHelper); ok {
   719  		h.Helper()
   720  	}
   721  	return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...)
   722  }
   723  
   724  // Positivef asserts that the specified element is positive
   725  //
   726  //	assert.Positivef(t, 1, "error message %s", "formatted")
   727  //	assert.Positivef(t, 1.23, "error message %s", "formatted")
   728  func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
   729  	if h, ok := t.(tHelper); ok {
   730  		h.Helper()
   731  	}
   732  	return Positive(t, e, append([]interface{}{msg}, args...)...)
   733  }
   734  
   735  // Regexpf asserts that a specified regexp matches a string.
   736  //
   737  //	assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
   738  //	assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
   739  func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
   740  	if h, ok := t.(tHelper); ok {
   741  		h.Helper()
   742  	}
   743  	return Regexp(t, rx, str, append([]interface{}{msg}, args...)...)
   744  }
   745  
   746  // Samef asserts that two pointers reference the same object.
   747  //
   748  //	assert.Samef(t, ptr1, ptr2, "error message %s", "formatted")
   749  //
   750  // Both arguments must be pointer variables. Pointer variable sameness is
   751  // determined based on the equality of both type and value.
   752  func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
   753  	if h, ok := t.(tHelper); ok {
   754  		h.Helper()
   755  	}
   756  	return Same(t, expected, actual, append([]interface{}{msg}, args...)...)
   757  }
   758  
   759  // Subsetf asserts that the specified list(array, slice...) or map contains all
   760  // elements given in the specified subset list(array, slice...) or map.
   761  //
   762  //	assert.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted")
   763  //	assert.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
   764  func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
   765  	if h, ok := t.(tHelper); ok {
   766  		h.Helper()
   767  	}
   768  	return Subset(t, list, subset, append([]interface{}{msg}, args...)...)
   769  }
   770  
   771  // Truef asserts that the specified value is true.
   772  //
   773  //	assert.Truef(t, myBool, "error message %s", "formatted")
   774  func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
   775  	if h, ok := t.(tHelper); ok {
   776  		h.Helper()
   777  	}
   778  	return True(t, value, append([]interface{}{msg}, args...)...)
   779  }
   780  
   781  // WithinDurationf asserts that the two times are within duration delta of each other.
   782  //
   783  //	assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
   784  func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
   785  	if h, ok := t.(tHelper); ok {
   786  		h.Helper()
   787  	}
   788  	return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
   789  }
   790  
   791  // WithinRangef asserts that a time is within a time range (inclusive).
   792  //
   793  //	assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
   794  func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
   795  	if h, ok := t.(tHelper); ok {
   796  		h.Helper()
   797  	}
   798  	return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...)
   799  }
   800  
   801  // YAMLEqf asserts that two YAML strings are equivalent.
   802  func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
   803  	if h, ok := t.(tHelper); ok {
   804  		h.Helper()
   805  	}
   806  	return YAMLEq(t, expected, actual, append([]interface{}{msg}, args...)...)
   807  }
   808  
   809  // Zerof asserts that i is the zero value for its type.
   810  func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
   811  	if h, ok := t.(tHelper); ok {
   812  		h.Helper()
   813  	}
   814  	return Zero(t, i, append([]interface{}{msg}, args...)...)
   815  }
   816  

View as plain text