assert

package
v0.0.0-...-7647e70 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

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

Assertion 断言定义

func NewAssertion

func NewAssertion(t *testing.T) *Assertion

NewAssertion 取得一个新的断言

func (*Assertion) Between

func (this *Assertion) Between(value interface{}, min interface{}, max interface{}, msg ...interface{}) *Assertion

Between 检查是否在两个数字之间

func (*Assertion) Contains

func (this *Assertion) Contains(container interface{}, item interface{}, msg ...interface{}) *Assertion

Contains 检查是否包含某个条目,目前只支持slice

func (*Assertion) Cost

func (this *Assertion) Cost() *Assertion

Cost 打印测试花销(ms)

func (*Assertion) Equals

func (this *Assertion) Equals(value1 interface{}, value2 interface{}, msg ...interface{}) *Assertion

Equals 检查是否相等

func (*Assertion) Fail

func (this *Assertion) Fail(msg ...interface{}) *Assertion

Fail 返回失败

func (*Assertion) Fatal

func (this *Assertion) Fatal(msg ...interface{}) *Assertion

Fatal 返回致命错误

func (*Assertion) Gt

func (this *Assertion) Gt(value interface{}, compare interface{}, msg ...interface{}) *Assertion

Gt 检查是否大于某个数字

func (*Assertion) Gte

func (this *Assertion) Gte(value interface{}, compare interface{}, msg ...interface{}) *Assertion

Gte 检查是否大于等于某个数字

func (*Assertion) IsBool

func (this *Assertion) IsBool(value interface{}, msg ...interface{}) *Assertion

IsBool 检查是否为bool类型

func (*Assertion) IsFalse

func (this *Assertion) IsFalse(value bool, msg ...interface{}) *Assertion

IsFalse 检查是否为false

func (*Assertion) IsFloat

func (this *Assertion) IsFloat(value interface{}, msg ...interface{}) *Assertion

IsFloat 检查是否为浮点数类型(float32, float64)

func (*Assertion) IsFloat32

func (this *Assertion) IsFloat32(value interface{}, msg ...interface{}) *Assertion

IsFloat32 检查是否为float32类型

func (*Assertion) IsFloat64

func (this *Assertion) IsFloat64(value interface{}, msg ...interface{}) *Assertion

IsFloat64 检查是否为float64类型

func (*Assertion) IsInt

func (this *Assertion) IsInt(value interface{}, msg ...interface{}) *Assertion

IsInt 检查是否为int类型

func (*Assertion) IsInt16

func (this *Assertion) IsInt16(value interface{}, msg ...interface{}) *Assertion

IsInt16 检查是否为int16类型

func (*Assertion) IsInt32

func (this *Assertion) IsInt32(value interface{}, msg ...interface{}) *Assertion

IsInt32 检查是否为int32类型

func (*Assertion) IsInt64

func (this *Assertion) IsInt64(value interface{}, msg ...interface{}) *Assertion

IsInt64 检查是否为int64类型

func (*Assertion) IsInt8

func (this *Assertion) IsInt8(value interface{}, msg ...interface{}) *Assertion

IsInt8 检查是否为int8类型

func (*Assertion) IsInteger

func (this *Assertion) IsInteger(value interface{}, msg ...interface{}) *Assertion

IsInteger 检查是否为整数类型(int, int8, ...)

func (*Assertion) IsKind

func (this *Assertion) IsKind(value interface{}, kind reflect.Kind, msg ...interface{}) *Assertion

IsKind 检查类型

func (*Assertion) IsMap

func (this *Assertion) IsMap(value interface{}, msg ...interface{}) *Assertion

IsMap 检查是否为map

func (*Assertion) IsNaN

func (this *Assertion) IsNaN(value interface{}, msg ...interface{}) *Assertion

IsNaN 检查是否为非数字

func (*Assertion) IsNil

func (this *Assertion) IsNil(value interface{}, msg ...interface{}) *Assertion

IsNil 检查是否为nil

func (*Assertion) IsNotEmpty

func (this *Assertion) IsNotEmpty(value interface{}, msg ...interface{}) *Assertion

IsNotEmpty 检查是否为非空

func (*Assertion) IsNotError

func (this *Assertion) IsNotError(value interface{}, msg ...interface{}) *Assertion

IsNotError 检查是否为非error

func (*Assertion) IsNotNil

func (this *Assertion) IsNotNil(value interface{}, msg ...interface{}) *Assertion

IsNotNil 检查是否为非nil

func (*Assertion) IsNumber

func (this *Assertion) IsNumber(value interface{}, msg ...interface{}) *Assertion

IsNumber 检查是否为数字

func (*Assertion) IsSlice

func (this *Assertion) IsSlice(value interface{}, msg ...interface{}) *Assertion

IsSlice 检查是否为slice

func (*Assertion) IsString

func (this *Assertion) IsString(value interface{}, msg ...interface{}) *Assertion

IsString 检查是否为字符串

func (*Assertion) IsTrue

func (this *Assertion) IsTrue(value bool, msg ...interface{}) *Assertion

IsTrue 检查是否为true

func (*Assertion) IsUint

func (this *Assertion) IsUint(value interface{}, msg ...interface{}) *Assertion

IsUint 检查是否为uint类型

func (*Assertion) IsUint16

func (this *Assertion) IsUint16(value interface{}, msg ...interface{}) *Assertion

IsUint16 检查是否为uint16类型

func (*Assertion) IsUint32

func (this *Assertion) IsUint32(value interface{}, msg ...interface{}) *Assertion

IsUint32 检查是否为uint32类型

func (*Assertion) IsUint64

func (this *Assertion) IsUint64(value interface{}, msg ...interface{}) *Assertion

IsUint64 检查是否为uint64类型

func (*Assertion) IsUint8

func (this *Assertion) IsUint8(value interface{}, msg ...interface{}) *Assertion

IsUint8 检查是否为uint8类型

func (*Assertion) Log

func (this *Assertion) Log(msg ...interface{}) *Assertion

Log 输出日志

func (*Assertion) LogJSON

func (this *Assertion) LogJSON(msg ...interface{}) *Assertion

LogJSON 输出JSON格式的日志

func (*Assertion) Logf

func (this *Assertion) Logf(format string, args ...interface{}) *Assertion

Logf 格式化输出日志

func (*Assertion) Lt

func (this *Assertion) Lt(value interface{}, compare interface{}, msg ...interface{}) *Assertion

Lt 检查是否小于某个数字

func (*Assertion) Lte

func (this *Assertion) Lte(value interface{}, compare interface{}, msg ...interface{}) *Assertion

Lte 检查是否小于等于某个数字

func (*Assertion) Match

func (this *Assertion) Match(pattern string, value string, msg ...interface{}) *Assertion

Match 执行正则匹配

func (*Assertion) NoPanic

func (this *Assertion) NoPanic(f func(), msg ...interface{}) *Assertion

NoPanic 检查是否没有panic

func (*Assertion) NotEquals

func (this *Assertion) NotEquals(value1 interface{}, value2 interface{}, msg ...interface{}) *Assertion

NotEquals 检查是否不相等

func (*Assertion) NotTimeout

func (this *Assertion) NotTimeout(duration time.Duration, f func(), msg ...interface{}) *Assertion

NotTimeout 检查执行时间是否超时

func (*Assertion) Panic

func (this *Assertion) Panic(f func(), msg ...interface{}) *Assertion

Panic 检查是否有panic

func (*Assertion) Pass

func (this *Assertion) Pass(msg ...interface{}) *Assertion

Pass 返回成功

func (*Assertion) Quiet

func (this *Assertion) Quiet(isQuiet ...bool) *Assertion

Quiet 是否开启静默模式,在此模式下成功的测试不会有提示

func (*Assertion) Then

func (this *Assertion) Then(f func()) *Assertion

Then 成功后执行

Jump to

Keyboard shortcuts

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