deepequal

package module
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 12 Imported by: 0

README

Deepequal

Package with protobuf-friendly deepequal functionality.

As you probably know, reflect.DeepEqual should not work for structures generated with protoc-gen-go because of their hidden service fields. This modified version of reflect.DeepEqual takes care of this and call proto.Equal for values of these types.

Also, there's a deepequal.SideBySide function that can be used in tests to show a difference between expected and actual values side by side.

sidebyside

Installation

go get github.com/sirkon/deepequal

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(x, y any) bool

Equal makes x deep equality comparison of given entities with x special care of types generated by protoc-gen-go. This is not a drop-in replacement for reflect.DeepEqual as some functionality is missing. Should be enough in most cases though.

func SideBySide added in v0.5.0

func SideBySide[T any](p TestPrinter, what string, want, got T)

SideBySide outputs a and b side by side with a difference highlight.

Types

type EqMatcher

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

EqMatcher equality matcher for gomock. Implements gomock.Matcher.

func NewEqMatcher

func NewEqMatcher(v any) EqMatcher

NewEqMatcher creates equality matcher.

func (EqMatcher) Matches added in v0.4.2

func (e EqMatcher) Matches(x any) bool

Matches to satisfy gomock.Matcher

func (EqMatcher) String

func (e EqMatcher) String() string

String to satisfy gomock.Matcher

type TestPrinter added in v0.5.0

type TestPrinter interface {
	Helper()
	Log(a ...any)
	Error(a ...any)
}

TestPrinter basically a masque for testing.XXX.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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