compare

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: MIT, MIT Imports: 8 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 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 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 FormatVerb

func FormatVerb(verb string) Option

func With

func With(specs ...Specification) Option

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