assert

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProtoJSONMarshaler = &jsonpb.Marshaler{
	EnumsAsInts:  false,
	EmitDefaults: false,
	Indent:       "\t",
	OrigName:     false,
}
View Source
var SpewConfig = spew.ConfigState{
	Indent:                  "\t",
	DisableMethods:          true,
	DisablePointerAddresses: true,
	ContinueOnMethod:        true,
}

Functions

func Equal

func Equal(
	t *testing.T,
	handleType HandleType,
	expected interface{},
	actual interface{},
	messages ...interface{},
)

If not equal then handle.

func EqualError

func EqualError(
	t *testing.T,
	handleType HandleType,
	expected error,
	actual error,
	messages ...interface{},
)

If equal then handle.

func Nil

func Nil(
	t *testing.T,
	handleType HandleType,
	actual interface{},
	messages ...interface{},
)

If not nil then handle.

func NoError

func NoError(
	t *testing.T,
	handleType HandleType,
	err error,
	messages ...interface{},
)

If has error then handle.

func NotEqual

func NotEqual(
	t *testing.T,
	handleType HandleType,
	expected interface{},
	actual interface{},
	messages ...interface{},
)

If equal then handle.

func NotNil

func NotNil(
	t *testing.T,
	handleType HandleType,
	actual interface{},
	messages ...interface{},
)

If nil then handle.

func ProtoEqual

func ProtoEqual(
	t *testing.T,
	handleType HandleType,
	expected proto.Message,
	actual proto.Message,
	messages ...interface{},
)

If not equal then handle.

func ProtoNotEqual

func ProtoNotEqual(
	t *testing.T,
	handleType HandleType,
	expected proto.Message,
	actual proto.Message,
	messages ...interface{},
)

If equal then handle.

func SprintMessages

func SprintMessages(text string, messages []interface{}) string

func UnorderedListEqual

func UnorderedListEqual(
	t *testing.T,
	handleType HandleType,
	expectedList interface{},
	actualList interface{},
	messages ...interface{},
)

If not equal then handle.

expectedList and actualList can be slice, array or nil. Compare type and elements with ignoring the order. For example,

  • [1]int{} is not equal to []int{}
  • []int{1, 1, 2} is equal to []int{2, 1, 1}

The time complexity is O(n^2).

Types

type HandleType

type HandleType int
const (
	ErrorHandle HandleType = iota
	FatalHandle
)

func (HandleType) String

func (i HandleType) String() string

Jump to

Keyboard shortcuts

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