📖 4 min read (~ 900 words).

Number

Asserting Numbers

Assertions

GoDoc

All links point to https://pkg.go.dev/github.com/go-openapi/testify/v2

This domain exposes 5 functionalities.

InDelta

InDelta asserts that the two numerals are within delta of each other.

Examples
assertions.InDelta(t, math.Pi, 22/7.0, 0.01)
	success: 1.0, 1.01, 0.02
	failure: 1.0, 1.1, 0.05

InDeltaMapValues

InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.

Examples
	assertions.InDeltaMapValues(t, map[string]float64{"a": 1.0}, map[string]float64{"a": 1.01}, 0.02)
	success: map[string]float64{"a": 1.0}, map[string]float64{"a": 1.01}, 0.02
	failure: map[string]float64{"a": 1.0}, map[string]float64{"a": 1.1}, 0.05

InDeltaSlice

InDeltaSlice is the same as InDelta, except it compares two slices.

Examples
	assertions.InDeltaSlice(t, []float64{1.0, 2.0}, []float64{1.01, 2.01}, 0.02)
	success: []float64{1.0, 2.0}, []float64{1.01, 2.01}, 0.02
	failure: []float64{1.0, 2.0}, []float64{1.1, 2.1}, 0.05

InEpsilon

InEpsilon asserts that expected and actual have a relative error less than epsilon.

Examples
	assertions.InEpsilon(t, 100.0, 101.0, 0.02)
	success: 100.0, 101.0, 0.02
	failure: 100.0, 110.0, 0.05

InEpsilonSlice

InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.

Examples
	assertions.InEpsilonSlice(t, []float64{100.0, 200.0}, []float64{101.0, 202.0}, 0.02)
	success: []float64{100.0, 200.0}, []float64{101.0, 202.0}, 0.02
	failure: []float64{100.0, 200.0}, []float64{110.0, 220.0}, 0.05


Generated with github.com/go-openapi/testify/v2/codegen