compare

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: MIT, MIT Imports: 9 Imported by: 0

README

GoDoc

Documentation

Overview

Package compare facilitates comparisons of any two values according to a set of specifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparer

type Comparer interface {
	Compare(a, b interface{}) (result Comparison)
}

func ForTesting

func ForTesting(t *testing.T, options ...Option) Comparer

func New

func New(options ...Option) Comparer

type Comparison

type Comparison struct {
	// contains filtered or unexported fields
}

func (Comparison) OK

func (this Comparison) OK() bool

func (Comparison) Report

func (this Comparison) Report() string

type DeepEquality

type DeepEquality struct{}

DeepEquality compares any two values using reflect.DeepEqual. https://golang.org/pkg/reflect/#DeepEqual

func (DeepEquality) Compare

func (this DeepEquality) Compare(a, b interface{}) bool

func (DeepEquality) IsSatisfiedBy

func (this DeepEquality) IsSatisfiedBy(a, b interface{}) bool

type Formatter

type Formatter func(interface{}) string

type LengthEquality

type LengthEquality struct{}

LengthEquality compares values that can serve as valid arguments to the built-in len function (with the exception of pointers to arrays, which are not yet supported herein). https://golang.org/pkg/builtin/#len

func (LengthEquality) Compare

func (this LengthEquality) Compare(a, b interface{}) bool

func (LengthEquality) IsSatisfiedBy

func (this LengthEquality) IsSatisfiedBy(a, b interface{}) bool

type NumericEquality

type NumericEquality struct{}

NumericEquality compares numeric values using the built-in equality operator (`==`). Values of differing numeric reflect.Kind are each converted to the type of the other and are compared with `==` in both directions. https://golang.org/pkg/reflect/#Kind

func (NumericEquality) Compare

func (this NumericEquality) Compare(a, b interface{}) bool

func (NumericEquality) IsSatisfiedBy

func (this NumericEquality) IsSatisfiedBy(a, b interface{}) bool

type Option

type Option func(*config)

func Format

func Format(formatter Formatter) Option

func FormatJSON

func FormatJSON(indent string) Option

func FormatLength

func FormatLength() Option

func FormatVerb

func FormatVerb(verb string) Option

func With

func With(specs ...Specification) Option

type SimpleEquality

type SimpleEquality struct{}

SimpleEquality compares any two values using the built-in equality operator (`==`). https://golang.org/ref/spec#Comparison_operators

func (SimpleEquality) Compare

func (this SimpleEquality) Compare(a, b interface{}) bool

func (SimpleEquality) IsSatisfiedBy

func (this SimpleEquality) IsSatisfiedBy(a, b interface{}) bool

type Specification

type Specification interface {
	IsSatisfiedBy(a, b interface{}) bool
	Compare(a, b interface{}) bool
}

type TimeEquality

type TimeEquality struct{}

TimeEquality compares values both of type time.Time using their Equal method. https://golang.org/pkg/time/#Time.Equal

func (TimeEquality) Compare

func (this TimeEquality) Compare(a, b interface{}) bool

func (TimeEquality) IsSatisfiedBy

func (this TimeEquality) IsSatisfiedBy(a, b interface{}) bool

Jump to

Keyboard shortcuts

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