Documentation
¶
Index ¶
- func Equal[T any](t testing.TB, expected, actual T)
- func False(t testing.TB, value bool)
- func IsError(t testing.TB, err error, message string, args ...any)
- func Nil(t testing.TB, v any)
- func NoError(t testing.TB, err error)
- func NotEqual[T any](t testing.TB, first, second T)
- func NotNil(t testing.TB, v any)
- func True(t testing.TB, value bool)
- type Comparable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
Equal compares two objects of any type for equality. If the objects implement the Comparable interface, it uses the Equal method for comparison. Otherwise, it uses reflect.DeepEqual to compare the objects. If the objects are not equal, it calls the fail function to log a fatal error.
func IsError ¶
IsError checks if the provided error's message matches the expected message. It takes a testing object, an error, and a string message as parameters. If the message is empty, it assumes that there should be no error If the error is nil, it logs a fatal error indicating that an error was expected. Otherwise, the function uses the Equal function to compare the error's message with the expected message. If the messages do not match, it logs a fatal error.
func Nil ¶
Nil checks if the provided value is nil. It takes a testing object and an interface value as parameters. If the value is not nil, it logs a fatal error with a message.
func NoError ¶
NoError checks if the provided error is nil. It takes a testing object and an error as parameters. If the error is not nil, it logs a fatal error with the error message.
func NotEqual ¶
NotEqual is the exact inverse of Equal. It uses the Equal function if the passed values are Comparators, otherwise it uses reflect to assert that the two values are not equal.
Types ¶
type Comparable ¶
Comparable is a generic interface that requires the implementation of the Equal method. The Equal method should compare the current object with another object of the same type and return true if they are equal, otherwise false.