Documentation | Contributing | Code of Conduct
import"atomicgo.dev/assert"Package assert provides a set of assertion functions. Every assertion function returns a boolean. This package does not integrateinto the testing package automatically. If you want to use this package inside unit tests, you have to check the returning boolean value and call `t.Fatal()` if the assertion fails.
This library does not provide any error messages. That way the assertions can also be used in production code.
If you want a full-featured testing framework, we recommend https://github.com/MarvinJWendt/testza (which uses this library for assertions)
- func Contains(a any, b any) bool
- func ContainsAll[T any](a T, v []T) bool
- func ContainsAny[T any](a T, v []T) bool
- func ContainsNone[T any](a T, v []T) bool
- func Equal[T any](a, b T) bool
- func Implements(a, iface any) bool
- func Kind(a any, kind reflect.Kind) bool
- func Len(a any, length int) (b bool)
- func Lowercase(s string) bool
- func Nil(a any) bool
- func Number(a any) bool
- func Panic(f func()) (panicked bool)
- func Range[T constraints.Number](a, minimum, maximum T) bool
- func Regex(regex, s string) bool
- func Unique[T any](s []T) bool
- func Uppercase(s string) bool
- func Zero(a any) bool
func Contains
funcContains(aany, bany) boolContains returns true if obj contains expectedLen.
func ContainsAll
funcContainsAll[Tany](aT, v []T) boolContainsAll returns true if all values are contained in obj.
func ContainsAny
funcContainsAny[Tany](aT, v []T) boolContainsAny returns true if any of the values are contained in obj.
func ContainsNone
funcContainsNone[Tany](aT, v []T) boolContainsNone returns true if none of the values are contained in obj.
func Equal
funcEqual[Tany](a, bT) boolEqual compares two values and returns true if they are equal.
func Implements
funcImplements(a, ifaceany) boolImplements returns true if the value implements the interface.
func Kind
funcKind(aany, kind reflect.Kind) boolKind returns true if the value is of the given kind.
func Len
funcLen(aany, lengthint) (bbool)Len returns true if the length of the value is equal to the given length.
func Lowercase
funcLowercase(sstring) boolLowercase returns true if the string is lowercase.
func Nil
funcNil(aany) boolNil returns true if the value is nil.
func Number
funcNumber(aany) boolNumber returns true if the value is obj number.
func Panic
funcPanic(ffunc()) (panickedbool)Panic returns true if the function panics.
func Range
funcRange[T constraints.Number](a, minimum, maximumT) boolRange returns true if the value is within the range.
func Regex
funcRegex(regex, sstring) boolRegex returns true if the string matches the regex.
func Unique
funcUnique[Tany](s []T) boolUnique returns true if the slice contains unique values. Items are considered unique if they are not deep equal.
func Uppercase
funcUppercase(sstring) boolUppercase returns true if the string is uppercase.
func Zero
funcZero(aany) boolZero returns true if the value is the zero value.
Generated by gomarkdoc
AtomicGo.dev · with ❤️ by @MarvinJWendt | mjw.dev
