Documentation ¶
Index ¶
- Constants
- func RunBoolTests(t *testing.T, fn func(interface{}) (bool, error))
- func RunDurationTests(t *testing.T, fn func(interface{}) (time.Duration, error))
- func RunFloat32Tests(t *testing.T, fn func(interface{}) (float32, error))
- func RunFloat64Tests(t *testing.T, fn func(interface{}) (float64, error))
- func RunInferTests(t *testing.T, fn func(into, from interface{}) error)
- func RunInt16Tests(t *testing.T, fn func(interface{}) (int16, error))
- func RunInt32Tests(t *testing.T, fn func(interface{}) (int32, error))
- func RunInt64Tests(t *testing.T, fn func(interface{}) (int64, error))
- func RunInt8Tests(t *testing.T, fn func(interface{}) (int8, error))
- func RunIntTests(t *testing.T, fn func(interface{}) (int, error))
- func RunReadmeTest(t *testing.T, srcs ...string)
- func RunStringTests(t *testing.T, fn func(interface{}) (string, error))
- func RunTest(t *testing.T, k reflect.Kind, fn func(interface{}) (interface{}, error))
- func RunTimeTests(t *testing.T, fn func(interface{}) (time.Time, error))
- func RunUint16Tests(t *testing.T, fn func(interface{}) (uint16, error))
- func RunUint32Tests(t *testing.T, fn func(interface{}) (uint32, error))
- func RunUint64Tests(t *testing.T, fn func(interface{}) (uint64, error))
- func RunUint8Tests(t *testing.T, fn func(interface{}) (uint8, error))
- func RunUintTests(t *testing.T, fn func(interface{}) (uint, error))
- type Assertion
- type Assertions
- type AssertionsIndex
- type AssertionsLookup
- type DurationExp
- type ErrorExp
- type Exp
- type Expecter
- type Float32Exp
- type Float64Exp
- type ReadmeExample
- type ReadmeExamples
- type SrcGen
- type TimeExp
Constants ¶
const ( TypeKind reflect.Kind = reflect.UnsafePointer + iota DurationKind TimeKind SliceMask reflect.Kind = (1 << 8) MapMask = (1 << 16) ChanMask = (1 << 24) )
const ( IntSize int = 32 << (^uint(0) >> 63) MinUint uint = 0 MaxUint uint = ^MinUint MaxInt int = int(MaxUint >> 1) MinInt int = ^MaxInt )
Numeric constants for testing.
Variables ¶
This section is empty.
Functions ¶
func RunDurationTests ¶
func RunInferTests ¶
func RunReadmeTest ¶
Types ¶
type Assertion ¶
type Assertion struct { // From is the underlying value to be used in conversions. From interface{} // Name of this assertion Name string // Code to construct Interface Code string // Type of Interface field using fmt %#T. Type string // File is the file the assertion is defined in. File string // Line is the line number the assertion is defined in. Line int // Description for this assertion. Desc string // Expects contains a list of values this Assertion expects to see as a result // of calling the conversion function for the associated type. For example // appending a single int64 to this slice would mean it is expected that: // conv.Int64(assertion.From) == Expect[0].(int64) // When appending multiple values of the same type, the last one appended is // used. Exps []Expecter }
Assertion represents a set of expected values from a Converter. It's the general implementation of asserter. It will compare each Expects to the associated Converter.T(). It returns an error for each failed conversion or an empty error slice if no failures occurred.
type AssertionsIndex ¶
type AssertionsIndex map[reflect.Kind][]AssertionsLookup
AssertionsIndex is map of assertions by the Expecter kind.
type AssertionsLookup ¶
type AssertionsLookup struct {
// contains filtered or unexported fields
}
type DurationExp ¶
DurationExp supports fuzzy duration conversions.
func (DurationExp) Expect ¶
func (e DurationExp) Expect(got interface{}, err error) error
func (DurationExp) Kind ¶
func (e DurationExp) Kind() reflect.Kind
func (DurationExp) Value ¶
func (e DurationExp) Value() interface{}
type Expecter ¶
type Expecter interface { // Exp is given the result of conversion and an error if one occurred. The // type of conversion operation should be the type of Kind(). Expect(got interface{}, err error) error // Value is the expected result. Value() interface{} // Kind returns the type of conversion that should be given to Exepct(). Kind() reflect.Kind }
Expecter defines a type of conversion for v and will return an error if the value is unexpected.
type Float32Exp ¶
type Float32Exp struct {
Want float32
}
Float32Exp asserts that (converter.Float32() - Exp) < epsilon64
func (Float32Exp) Expect ¶
func (e Float32Exp) Expect(got interface{}, err error) error
func (Float32Exp) Kind ¶
func (e Float32Exp) Kind() reflect.Kind
func (Float32Exp) Value ¶
func (e Float32Exp) Value() interface{}
type Float64Exp ¶
type Float64Exp struct {
Want float64
}
Float64Exp asserts that (converter.Float64() - Exp) < epsilon64
func (Float64Exp) Expect ¶
func (e Float64Exp) Expect(got interface{}, err error) error
func (Float64Exp) Kind ¶
func (e Float64Exp) Kind() reflect.Kind
func (Float64Exp) Value ¶
func (e Float64Exp) Value() interface{}
type ReadmeExample ¶
type ReadmeExamples ¶
type ReadmeExamples []ReadmeExample
func (ReadmeExamples) Len ¶
func (r ReadmeExamples) Len() int
func (ReadmeExamples) Less ¶
func (r ReadmeExamples) Less(i, j int) bool
func (ReadmeExamples) Swap ¶
func (r ReadmeExamples) Swap(i, j int)
type SrcGen ¶
type TimeExp ¶
type TimeExp struct { Moment time.Time Offset time.Duration Round time.Duration Truncate time.Duration }
TimeExp helps validate time.Time() conversions, specifically because under some conversions time.Now() may be used. It will check that the difference between the Moment is the same as the given value after truncation and rounding (if either is set) is identical.