Skip to content

Repository files navigation

AtomicGo



AtomicGo | assert

DownloadsLatest ReleaseTestsCoverageUnit test countLicense: MITGo report


Documentation | Contributing | Code of Conduct


go get atomicgo.dev/assert

assert

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

funcContains(aany, bany) bool

Contains returns true if obj contains expectedLen.

funcContainsAll[Tany](aT, v []T) bool

ContainsAll returns true if all values are contained in obj.

funcContainsAny[Tany](aT, v []T) bool

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

funcContainsNone[Tany](aT, v []T) bool

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

func Equal

funcEqual[Tany](a, bT) bool

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

funcImplements(a, ifaceany) bool

Implements returns true if the value implements the interface.

func Kind

funcKind(aany, kind reflect.Kind) bool

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

funcLowercase(sstring) bool

Lowercase returns true if the string is lowercase.

func Nil

funcNil(aany) bool

Nil returns true if the value is nil.

func Number

funcNumber(aany) bool

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

Range returns true if the value is within the range.

func Regex

funcRegex(regex, sstring) bool

Regex returns true if the string matches the regex.

func Unique

funcUnique[Tany](s []T) bool

Unique returns true if the slice contains unique values. Items are considered unique if they are not deep equal.

funcUppercase(sstring) bool

Uppercase returns true if the string is uppercase.

func Zero

funcZero(aany) bool

Zero returns true if the value is the zero value.

Generated by gomarkdoc


AtomicGo.dev · with ❤️ by @MarvinJWendt | mjw.dev

About

✅ Go package with tons of assertions!

Topics

Resources

Code of conduct

Stars

3 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

Generated from atomicgo/template