assert

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package assert is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(cases Cases) error

Check 用于检查参数有效性。

func Equal

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

Equal asserts that got and expect are equal.

func Error

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

Error asserts that a got error string matches a given regular expression.

func False

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

False asserts that got is false.

func Implements

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

Implements asserts that got implements expect.

func IsNil

func IsNil(v reflect.Value) bool

IsNil 返回 v 的值是否为 nil,但是不会 panic 。

func JsonEqual

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

JsonEqual asserts that got and expect are equal.

func Matches

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

Matches asserts that a got value matches a given regular expression.

func Nil

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

Nil asserts that got is nil.

func NotEqual

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

NotEqual asserts that got and expect are not equal.

func NotNil

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

NotNil asserts that got is not nil.

func NotSame

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

NotSame asserts that got and expect are not same.

func Panic

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

Panic asserts that function fn() would panic. It fails if the panic message does not match the regular expression.

func Same

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

Same asserts that got and expect are same.

func True

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

True asserts that got is true.

func TypeOf

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

TypeOf asserts that got and expect are same type.

Types

type Assertion

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

func That

func That(t T, v interface{}) *Assertion

func (*Assertion) HasPrefix

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

func (*Assertion) IsEqualTo

func (a *Assertion) IsEqualTo(expect interface{}, msg ...string) *Assertion

func (*Assertion) IsFalse

func (a *Assertion) IsFalse(msg ...string) *Assertion

func (*Assertion) IsNil

func (a *Assertion) IsNil(msg ...string) *Assertion

func (*Assertion) IsNotEqualTo

func (a *Assertion) IsNotEqualTo(expect interface{}, msg ...string) *Assertion

func (*Assertion) IsNotNil

func (a *Assertion) IsNotNil(msg ...string) *Assertion

func (*Assertion) IsNotSame

func (a *Assertion) IsNotSame(expect interface{}, msg ...string) *Assertion

func (*Assertion) IsSame

func (a *Assertion) IsSame(expect interface{}, msg ...string) *Assertion

func (*Assertion) IsTrue

func (a *Assertion) IsTrue(msg ...string) *Assertion

type BoolAssertion

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

func ThatBool

func ThatBool(t T, v bool) *BoolAssertion

func (*BoolAssertion) IsFalse

func (a *BoolAssertion) IsFalse(msg ...string) *BoolAssertion

func (*BoolAssertion) IsTrue

func (a *BoolAssertion) IsTrue(msg ...string) *BoolAssertion

type Cases

type Cases = []struct {
	Condition bool
	Message   string
}

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) Fail

func (m *MockT) Fail()

Fail mocks base method.

func (*MockT) Helper

func (m *MockT) Helper()

Helper mocks base method.

func (*MockT) Log

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

Log mocks base method.

type MockTMockRecorder

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

MockTMockRecorder is the mock recorder for MockT.

func (*MockTMockRecorder) Fail

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

Fail indicates an expected call of Fail.

func (*MockTMockRecorder) Helper

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

Helper indicates an expected call of Helper.

func (*MockTMockRecorder) Log

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

Log indicates an expected call of Log.

type StringAssertion

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

func ThatString

func ThatString(t T, v string) *StringAssertion

func (*StringAssertion) HasPrefix

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

func (*StringAssertion) HasSubString

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

func (*StringAssertion) HasSuffix

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

func (*StringAssertion) IsEqualFold

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

type T

type T interface {
	Helper()
	Fail()
	Log(args ...interface{})
}

T testing.T 的简化接口。

Jump to

Keyboard shortcuts

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