assert

package
v0.0.0-...-bd77e7c Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package assert provides some useful assertion methods.

Package assert is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(t T, got interface{}, expect interface{}, msg ...string)

Equal assertion failed when got and expect are not `deeply equal`.

func Error

func Error(t T, got error, expr string, msg ...string)

Error assertion failed when got `error` doesn't match expr expression.

func False

func False(t T, got bool, msg ...string)

False assertion failed when got is true.

func Implements

func Implements(t T, got interface{}, expect interface{}, msg ...string)

Implements assertion failed when got doesn't implement expect.

func InMapKeys

func InMapKeys(t T, got interface{}, expect interface{}, msg ...string)

InMapKeys assertion failed when got is not in keys of expect map.

func InMapValues

func InMapValues(t T, got interface{}, expect interface{}, msg ...string)

InMapValues assertion failed when got is not in values of expect map.

func InSlice

func InSlice(t T, got interface{}, expect interface{}, msg ...string)

InSlice assertion failed when got is not in expect array & slice.

func JsonEqual

func JsonEqual(t T, got string, expect string, msg ...string)

JsonEqual assertion failed when got and expect are not `json equal`.

func Matches

func Matches(t T, got string, expr string, msg ...string)

Matches assertion failed when got doesn't match expr expression.

func Nil

func Nil(t T, got interface{}, msg ...string)

Nil assertion failed when got is not nil.

func NotEqual

func NotEqual(t T, got interface{}, expect interface{}, msg ...string)

NotEqual assertion failed when got and expect are `deeply equal`.

func NotInSlice

func NotInSlice(t T, got interface{}, expect interface{}, msg ...string)

NotInSlice assertion failed when got is in expect array & slice.

func NotNil

func NotNil(t T, got interface{}, msg ...string)

NotNil assertion failed when got is nil.

func NotSame

func NotSame(t T, got interface{}, expect interface{}, msg ...string)

NotSame assertion failed when got and expect are same.

func Panic

func Panic(t T, fn func(), expr string, msg ...string)

Panic assertion failed when fn doesn't panic or not match expr expression.

func Same

func Same(t T, got interface{}, expect interface{}, msg ...string)

Same assertion failed when got and expect are not same.

func SubInSlice

func SubInSlice(t T, got interface{}, expect interface{}, msg ...string)

SubInSlice assertion failed when got is not sub in expect array & slice.

func True

func True(t T, got bool, msg ...string)

True assertion failed when got is false.

func TypeOf

func TypeOf(t T, got interface{}, expect interface{}, msg ...string)

TypeOf assertion failed when got and expect are not same type.

Types

type MockT

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

MockT is a mock of T interface.

func NewMockT

func NewMockT(ctrl *gomock.Controller) *MockT

NewMockT creates a new mock instance.

func (*MockT) EXPECT

func (m *MockT) EXPECT() *MockTMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockT) Error

func (m *MockT) Error(args ...interface{})

Error mocks base method.

func (*MockT) Helper

func (m *MockT) Helper()

Helper mocks base method.

type MockTMockRecorder

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

MockTMockRecorder is the mock recorder for MockT.

func (*MockTMockRecorder) Error

func (mr *MockTMockRecorder) Error(args ...interface{}) *gomock.Call

Error indicates an expected call of Error.

func (*MockTMockRecorder) Helper

func (mr *MockTMockRecorder) Helper() *gomock.Call

Helper indicates an expected call of Helper.

type StringAssertion

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

StringAssertion assertion for type string.

func String

func String(t T, v string) *StringAssertion

String returns an assertion for type string.

func (*StringAssertion) Contains

func (a *StringAssertion) Contains(substr string, msg ...string) *StringAssertion

Contains assertion failed when v doesn't contain substring `substr`.

func (*StringAssertion) EqualFold

func (a *StringAssertion) EqualFold(s string, msg ...string)

EqualFold assertion failed when v doesn't equal to `s` under Unicode case-folding.

func (*StringAssertion) HasPrefix

func (a *StringAssertion) HasPrefix(prefix string, msg ...string) *StringAssertion

HasPrefix assertion failed when v doesn't have prefix `prefix`.

func (*StringAssertion) HasSuffix

func (a *StringAssertion) HasSuffix(suffix string, msg ...string) *StringAssertion

HasSuffix assertion failed when v doesn't have suffix `suffix`.

type T

type T interface {
	Helper()
	Error(args ...interface{})
}

T is the minimum interface of *testing.T.

Jump to

Keyboard shortcuts

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