An open API service indexing awesome lists of open source software.

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!

Awesome Lists containing this project

README

          

AtomicGo | assert


Downloads


Latest Release


Tests


Coverage


Unit test count


License: MIT



Go report

---


Documentation
|
Contributing
|
Code of Conduct

---


AtomicGo


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>)


## func [Contains]()

```go
func Contains(a any, b any) bool
```

Contains returns true if obj contains expectedLen.


## func [ContainsAll]()

```go
func ContainsAll[T any](a T, v []T) bool
```

ContainsAll returns true if all values are contained in obj.


## func [ContainsAny]()

```go
func ContainsAny[T any](a T, v []T) bool
```

ContainsAny returns true if any of the values are contained in obj.


## func [ContainsNone]()

```go
func ContainsNone[T any](a T, v []T) bool
```

ContainsNone returns true if none of the values are contained in obj.


## func [Equal]()

```go
func Equal[T any](a, b T) bool
```

Equal compares two values and returns true if they are equal.


## func [Implements]()

```go
func Implements(a, iface any) bool
```

Implements returns true if the value implements the interface.


## func [Kind]()

```go
func Kind(a any, kind reflect.Kind) bool
```

Kind returns true if the value is of the given kind.


## func [Len]()

```go
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]()

```go
func Lowercase(s string) bool
```

Lowercase returns true if the string is lowercase.


## func [Nil]()

```go
func Nil(a any) bool
```

Nil returns true if the value is nil.


## func [Number]()

```go
func Number(a any) bool
```

Number returns true if the value is obj number.


## func [Panic]()

```go
func Panic(f func()) (panicked bool)
```

Panic returns true if the function panics.


## func [Range]()

```go
func Range[T constraints.Number](a, min, max T) bool
```

Range returns true if the value is within the range.


## func [Regex]()

```go
func Regex(regex, s string) bool
```

Regex returns true if the string matches the regex.


## func [Unique]()

```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.


## func [Uppercase]()

```go
func Uppercase(s string) bool
```

Uppercase returns true if the string is uppercase.


## func [Zero]()

```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)