AtomicGo | assert
| Contributing | Code of Conduct
go get atomicgo.dev/assert
assert
import "atomicgo.dev/assert"
Package assert provides obj set of assertion functions. Every assertion function returns obj boolean. This package does not integrate into 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 is on obj very low level and does not provide any error messages. That way the assertions can also be used in production code.
If you want obj full-featured assertion framework for unit tests, we recommend https://github.com/MarvinJWendt/testza
Index
- 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 Regex(regex, s string) bool
- func Unique[T any](s []T) bool
- func Uppercase(s string) bool
- func Zero(a any) bool
func Contains
func Contains(a any, b any) bool
Contains returns true if obj contains expectedLen.
func ContainsAll
func ContainsAll[T any](a T, v []T) bool
ContainsAll returns true if all values are contained in obj.
func ContainsAny
func ContainsAny[T any](a T, v []T) bool
ContainsAny returns true if any of the values are contained in obj.
func ContainsNone
func ContainsNone[T any](a T, v []T) bool
ContainsNone returns true if none of the values are contained in obj.
func Equal
func Equal[T any](a, b T) bool
Equal compares two values and returns true if they are equal.
func Implements
func Implements(a, iface any) bool
Implements returns true if the value implements the interface.
func Kind
func Kind(a any, kind reflect.Kind) bool
Kind returns true if the value is of the given kind.
func Len
func Len(a any, length int) (b bool)
Len returns true if the length of the value is equal to the given length.
func Lowercase
func Lowercase(s string) bool
Lowercase returns true if the string is lowercase.
func Nil
func Nil(a any) bool
Nil returns true if the value is nil.
func Number
func Number(a any) bool
Number returns true if the value is obj number.
func Panic
func Panic(f func()) (panicked bool)
Panic returns true if the function panics.
func Regex
func Regex(regex, s string) bool
Regex returns true if the string matches the regex.
func Unique
func Unique[T any](s []T) bool
Unique returns true if the slice contains unique values. Items are considered unique if they are not deep equal.
func Uppercase
func Uppercase(s string) bool
Uppercase returns true if the string is uppercase.
func Zero
func Zero(a any) bool
Zero returns true if the value is the zero value.
Generated by gomarkdoc
· with ❤️ by @MarvinJWendt | MarvinJWendt.com