cmprtest

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Small is the value that will be passed into AssertEqualizer
	Small cmpr.Tolerance = 1e-10
)

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual(expected, actual interface{}, delta cmpr.Tolerance) error

AssertEqual can compare anything that implements geomtest.AssertEqualizer. There is also logic to handle comparing float64 values Any two slices whose elements can be compared with Equal can be compared. The provided delta value will be passed to anything that implements AssertEqualizer. If the equality check fails, an error is returned.

func Equal

func Equal(t TestingT, expected, actual interface{}, msg ...interface{}) bool

Equal calls AssertEqual with the default value of Small. If there is an error it is passed into t.Error. The return bool will be true if the values were equal.

func EqualInDelta

func EqualInDelta(t TestingT, expected, actual interface{}, delta cmpr.Tolerance, msg ...interface{}) bool

EqualInDelta calls AssertEqual. If there is an error it is passed into t.Error. The return bool will be true if the values were equal.

func Message

func Message(msg ...interface{}) string

Message takes in args to form a message. If there are more than 1 arg and the first is a string, it will use that as a format string.

Types

type Assert

type Assert struct {
	*assert.Assertions
	assert.TestingT
}

Assert wraps an instance of assert.Assertions but will replace calls to Equal with cmprtest when the type is float64 or fulfills AssertEqual. This allows calls to be made without passing in testing.T each time.

func New

func New(t assert.TestingT) *Assert

New creates an instance of Assert.

func (*Assert) Equal

func (g *Assert) Equal(expected, actual interface{}, msg ...interface{}) bool

Equal will call cmprtest.EqualInDelta if expected is a float64 or if it fulfills AssertEqualizer.

type TestingT

type TestingT interface {
	Errorf(format string, args ...interface{})
}

Jump to

Keyboard shortcuts

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