Documentation ¶
Overview ¶
Package geomtest provides helpers for testing the geom packages.
Index ¶
- Constants
- func AssertEqual(expected, actual interface{}, delta cmpr.Tolerance) error
- func Equal(t assert.TestingT, expected, actual interface{}, msg ...interface{}) bool
- func EqualInDelta(t assert.TestingT, expected, actual interface{}, delta cmpr.Tolerance, ...) bool
- func Message(msg ...interface{}) string
- type AssertEqualizer
- type GeomAssert
Constants ¶
const ( // Small is the value that will be passed into AssertEqualizer Small cmpr.Tolerance = 1e-10 )
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
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 ¶
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.
Types ¶
type AssertEqualizer ¶
AssertEqualizer allows a type to define an equality test.
Note that when fulfilling an interface Go will coerce a pointer type to it's base type, but not the other way. So if AssertEqual is on the base type is on the base type and a pointer to that type is passed into geomtest.Equal it will be cast to the base type.
type GeomAssert ¶
type GeomAssert struct { *assert.Assertions assert.TestingT }
GeomAssert wraps an instance of assert.Assertions but will replace calls to Equal with geomtest when the type is float64 or fulfills AssertEqual. This allows calls to be made without passing in testing.T each time.
func (*GeomAssert) Equal ¶
func (g *GeomAssert) Equal(expected, actual interface{}, msg ...interface{}) bool
Equal will call geomtest.EqualInDelta if expected is a float64 or if it fulfills AssertEqualizer.