Documentation ¶
Index ¶
- Variables
- func Assert(t TestingT, condition bool, message string, args ...any)
- func DereferenceEqual[T comparable](t TestingT, expected *T, got *T)
- func DereferenceEqualMsg[T comparable](t TestingT, expected *T, got *T, errMessage, mismatchMessage string)
- func Equal[T comparable](t TestingT, expected T, got T)
- func EqualMsg[T comparable](t TestingT, expected T, got T, message string)
- func NilErr(t TestingT, err error)
- func NotNilErr(t TestingT, err error)
- func SliceEqual[T comparable](t TestingT, expected []T, got []T)
- func SliceEqualMsg[T comparable](t TestingT, expected []T, got []T, sizeMessage, mismatchMessage string)
- type TestingT
Constants ¶
This section is empty.
Variables ¶
var ( // The failure format string for values not being equal. Formatted with `expected` then `got`. EqualMessage = "value did not equal expectation.\nexpected: %v\n got: %v" // The error format string for one or both pointers being nil. Formatted with `got` then `expected`. DereferenceEqualErrMsg = "could not dereference nil pointer\ngot %v, expected %v" // The failure format string if the err is not nil. Formatted with `err`. NilErrMessage = "expected no error, got error:\n%v" // The failure format string if the err is nil. NotNilErrMesage = "expected an error, got nil" // The failure format string for slices being different sizes. Formatted with `expected` then `got`. SliceSizeMessage = "slices were different sizes.\nexpected len:%d\n got len:%d\n" // The failure format string for slices not matching at some index. Formatted with the mismatched // index, then `expected`, then `got`. SliceMismatchMessage = "slices differed at index %d.\nexpected: %v\n got: %v" )
Functions ¶
func Assert ¶
Assert that the passed condition is true. If not, fatally fail with `message` and format `args` into it.
func DereferenceEqual ¶
func DereferenceEqual[T comparable](t TestingT, expected *T, got *T)
Assert that the value at `got` equals the value at `expected`. Will error if either pointer is nil. Uses `assert.DereferenceEqualErrMsg` and `assert.EqualMessage`.
func DereferenceEqualMsg ¶
func DereferenceEqualMsg[T comparable]( t TestingT, expected *T, got *T, errMessage, mismatchMessage string, )
Assert that the value at `got` equals the value at `expected`. Will error if either pointer is nil. Uses `errMessage` and `mismatchMessage`.
func Equal ¶
func Equal[T comparable](t TestingT, expected T, got T)
Assert that `got` equals `expected`. The types between compared arguments must be the same. Uses `assert.EqualMessage`.
func EqualMsg ¶
func EqualMsg[T comparable](t TestingT, expected T, got T, message string)
Assert that `got` equals `expected`. The types between compared arguments must be the same. Uses `message`.
func NotNilErr ¶ added in v0.12.0
Assert that that `err` is not nil. Uses `assert.NotNillErrMesage`.
func SliceEqual ¶
func SliceEqual[T comparable](t TestingT, expected []T, got []T)
Assert that slices `got` and `expected` are equal. Will produce a different message if the lengths are different or if any element mismatches. Uses `assert.SliceSizeMessage` and `assert.SliceMismatchMessage`.
func SliceEqualMsg ¶
func SliceEqualMsg[T comparable]( t TestingT, expected []T, got []T, sizeMessage, mismatchMessage string, )
Assert that slices `got` and `expected` are equal. Will produce a different message if the lengths are different or if any element mismatches. Uses `sizeMessage` and `mismatchMessage`.