assert

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package assert provides type-safe assertion functions for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal[T comparable](t TestingT, expected, actual T, messageAndArgs ...interface{})

Equal asserts that two values are equal using the == operator.

func EqualFunc

func EqualFunc[T any](t TestingT, expected, actual T, equalFunc func(a, b T) bool, messageAndArgs ...interface{})

EqualFunc asserts that two values are equal using the provided equality function.

func Greater

func Greater[T cmp.Ordered](t TestingT, actual, minValue T, messageAndArgs ...interface{})

Greater asserts that the actual value is greater than the expected value.

func GreaterOrEqual

func GreaterOrEqual[T cmp.Ordered](t TestingT, actual, minValue T, messageAndArgs ...interface{})

GreaterOrEqual asserts that the actual value is greater than or equal to the expected value.

func IsNil

func IsNil(t TestingT, value any, messageAndArgs ...interface{})

IsNil asserts that the value is nil.

func IsNotNil

func IsNotNil(t TestingT, value any, messageAndArgs ...interface{})

IsNotNil asserts that the value is not nil.

func Less

func Less[T cmp.Ordered](t TestingT, actual, maxValue T, messageAndArgs ...interface{})

Less asserts that the actual value is less than the expected value.

func LessOrEqual

func LessOrEqual[T cmp.Ordered](t TestingT, actual, maxValue T, messageAndArgs ...interface{})

LessOrEqual asserts that the actual value is less than or equal to the expected value.

func NotEqual

func NotEqual[T comparable](t TestingT, expected, actual T, messageAndArgs ...interface{})

NotEqual asserts that two values are not equal using the != operator.

func NotEqualFunc

func NotEqualFunc[T any](t TestingT, expected, actual T, equalFunc func(a, b T) bool, messageAndArgs ...interface{})

NotEqualFunc asserts that two values are not equal using the provided equality function.

Types

type TestingT

type TestingT = interface {
	Fail()
	Helper()
	Logf(format string, args ...interface{})
}

TestingT is an interface that defines a minimal set of methods for logging, marking failures, and helper annotations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL