https://github.com/atomicgo/assert
✅ Go package with tons of assertions!
https://github.com/atomicgo/assert
assert assertion atomicgo go golang golang-library testing testing-library
Last synced: 8 months ago
JSON representation
✅ Go package with tons of assertions!
- Host: GitHub
- URL: https://github.com/atomicgo/assert
- Owner: atomicgo
- License: mit
- Created: 2022-10-09T02:20:36.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-08T17:04:00.000Z (over 1 year ago)
- Last Synced: 2025-04-15T13:56:26.934Z (8 months ago)
- Topics: assert, assertion, atomicgo, go, golang, golang-library, testing, testing-library
- Language: Go
- Homepage: https://atomicgo.dev
- Size: 42 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
AtomicGo | assert

---
Documentation
|
Contributing
|
Code of Conduct
---
go get atomicgo.dev/assert
# assert
```go
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\)
## Index
- [func Contains\(a any, b any\) bool](<#Contains>)
- [func ContainsAll\[T any\]\(a T, v \[\]T\) bool](<#ContainsAll>)
- [func ContainsAny\[T any\]\(a T, v \[\]T\) bool](<#ContainsAny>)
- [func ContainsNone\[T any\]\(a T, v \[\]T\) bool](<#ContainsNone>)
- [func Equal\[T any\]\(a, b T\) bool](<#Equal>)
- [func Implements\(a, iface any\) bool](<#Implements>)
- [func Kind\(a any, kind reflect.Kind\) bool](<#Kind>)
- [func Len\(a any, length int\) \(b bool\)](<#Len>)
- [func Lowercase\(s string\) bool](<#Lowercase>)
- [func Nil\(a any\) bool](<#Nil>)
- [func Number\(a any\) bool](<#Number>)
- [func Panic\(f func\(\)\) \(panicked bool\)](<#Panic>)
- [func Range\[T constraints.Number\]\(a, min, max T\) bool](<#Range>)
- [func Regex\(regex, s string\) bool](<#Regex>)
- [func Unique\[T any\]\(s \[\]T\) bool](<#Unique>)
- [func Uppercase\(s string\) bool](<#Uppercase>)
- [func Zero\(a any\) bool](<#Zero>)
```go
func Contains(a any, b any) bool
```
Contains returns true if obj contains expectedLen.
```go
func ContainsAll[T any](a T, v []T) bool
```
ContainsAll returns true if all values are contained in obj.
```go
func ContainsAny[T any](a T, v []T) bool
```
ContainsAny returns true if any of the values are contained in obj.
```go
func ContainsNone[T any](a T, v []T) bool
```
ContainsNone returns true if none of the values are contained in obj.
```go
func Equal[T any](a, b T) bool
```
Equal compares two values and returns true if they are equal.
```go
func Implements(a, iface any) bool
```
Implements returns true if the value implements the interface.
```go
func Kind(a any, kind reflect.Kind) bool
```
Kind returns true if the value is of the given kind.
```go
func Len(a any, length int) (b bool)
```
Len returns true if the length of the value is equal to the given length.
```go
func Lowercase(s string) bool
```
Lowercase returns true if the string is lowercase.
```go
func Nil(a any) bool
```
Nil returns true if the value is nil.
```go
func Number(a any) bool
```
Number returns true if the value is obj number.
```go
func Panic(f func()) (panicked bool)
```
Panic returns true if the function panics.
```go
func Range[T constraints.Number](a, min, max T) bool
```
Range returns true if the value is within the range.
```go
func Regex(regex, s string) bool
```
Regex returns true if the string matches the regex.
```go
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.
```go
func Uppercase(s string) bool
```
Uppercase returns true if the string is uppercase.
```go
func Zero(a any) bool
```
Zero returns true if the value is the zero value.
Generated by [gomarkdoc]()
---
> [AtomicGo.dev](https://atomicgo.dev) ·
> with ❤️ by [@MarvinJWendt](https://github.com/MarvinJWendt) |
> [MarvinJWendt.com](https://marvinjwendt.com)