单元测试类

package
v0.0.0-...-fcd50c7 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

包gtest提供了方便的单元测试工具。 md5:b9acf1a8bbc8ea0c

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(value, expect interface{})

Assert 检查 `value` 和 `expect` 是否相等。 md5:eaeea7c4fe0d764e

func AssertEQ

func AssertEQ(value, expect interface{})

AssertEQ 检查 `value` 和 `expect` 是否相等,包括它们的类型。 md5:31097fa6b823a25a

func AssertGE

func AssertGE(value, expect interface{})

AssertGE 检查 `value` 是否大于或等于 `expect`。 请注意,只有字符串、整数和浮点数类型可以使用 AssertGE 进行比较,其他类型是无效的。 md5:3227e007891ed72e

func AssertGT

func AssertGT(value, expect interface{})

AssertGT 检查 `value` 是否大于 `expect`。 注意,只有字符串、整数和浮点数类型能使用 AssertGT 进行比较, 其他类型是无效的。 md5:647270894818c6c7

func AssertIN

func AssertIN(value, expect interface{})

AssertIN 检查 `value` 是否在 `expect` 中。 `expect` 应该是一个切片, 但是 `value` 可以是切片或基本类型变量。 TODO: 添加对 map 的支持。 TODO: gconv.Strings(0) 不应该转换为 `[0]`。 md5:d8391e0c6cba6480

func AssertLE

func AssertLE(value, expect interface{})

AssertLE 检查 `value` 是否小于或等于 `expect`。 请注意,只有字符串、整数和浮点类型可以通过 AssertLTE 进行比较,其他类型的值是无效的。 md5:bca4df91bef4e152

func AssertLT

func AssertLT(value, expect interface{})

AssertLT 检查 `value` 是否小于等于 `expect`。 注意,只有字符串、整数和浮点类型可以通过 AssertLT 进行比较,其他类型无效。 md5:784a9db44c03122b

func AssertNE

func AssertNE(value, expect interface{})

AssertNE 检查 `value` 和 `expect` 是否不相等。 md5:418e91b330bc944f

func AssertNI

func AssertNI(value, expect interface{})

AssertNI 检查 `value` 不在 `expect` 中。 `expect` 应该是一个切片, 但是 `value` 可以是切片或基本类型变量。 TODO 增加对 map 的支持。 md5:483febd56930eb64

func AssertNQ

func AssertNQ(value, expect interface{})

AssertNQ 检查 `value` 和 `expect` 是否不相等,包括它们的类型。 md5:bb13af00897290db

func AssertNil

func AssertNil(value interface{})

AssertNil 断言 `value` 为 nil。 md5:94a00206ff503e10

func C

func C(t *testing.T, f func(t *T))

C 创建一个单元测试用例。 参数 `t` 是标准库 (*testing.T) 的 testing.T 指针。 参数 `f` 是用于单元测试的闭包函数。 md5:0a3ae380343ea962

func DataContent

func DataContent(names ...string) string

DataContent 从当前包的特定测试数据路径中检索并返回文件内容. md5:26224495ddbd389e

func DataPath

func DataPath(names ...string) string

DataPath获取并返回当前包的测试数据路径,仅用于单元测试。 可选参数`names`指定了子文件夹/子文件,将与当前系统的分隔符连接,并与路径一起返回。 md5:55efb430c9f8a73f

func Error

func Error(message ...interface{})

使用给定的`message`引发错误恐慌。 md5:6ddb84d91c681d1f

func Fatal

func Fatal(message ...interface{})

Fatal 将 `message` 打印到 stderr 并退出进程。 md5:15e177961f66ebe7

Types

type T

type T struct {
	*testing.T
}

T 是测试用例管理对象。 md5:48ef1adf72668d4b

func (*T) Assert

func (t *T) Assert(value, expect interface{})

Assert 检查 `value` 和 `expect` 是否相等。 md5:eaeea7c4fe0d764e

func (*T) AssertEQ

func (t *T) AssertEQ(value, expect interface{})

AssertEQ 检查 `value` 和 `expect` 是否相等,包括它们的类型。 md5:31097fa6b823a25a

func (*T) AssertGE

func (t *T) AssertGE(value, expect interface{})

AssertGE 检查 `value` 是否大于或等于 `expect`。 请注意,只有字符串、整数和浮点数类型可以使用 AssertGE 进行比较,其他类型是无效的。 md5:3227e007891ed72e

func (*T) AssertGT

func (t *T) AssertGT(value, expect interface{})

AssertGT 检查 `value` 是否大于 `expect`。 注意,只有字符串、整数和浮点数类型能使用 AssertGT 进行比较, 其他类型是无效的。 md5:647270894818c6c7

func (*T) AssertIN

func (t *T) AssertIN(value, expect interface{})

AssertIN 检查 `value` 是否在 `expect` 中。 `expect` 应该是一个切片, 但 `value` 可以是一个切片或一个基本类型变量。 md5:596913e44fc64a93

func (*T) AssertLE

func (t *T) AssertLE(value, expect interface{})

AssertLE 检查 `value` 是否小于或等于 `expect`。 请注意,只有字符串、整数和浮点类型可以通过 AssertLTE 进行比较,其他类型的值是无效的。 md5:bca4df91bef4e152

func (*T) AssertLT

func (t *T) AssertLT(value, expect interface{})

AssertLT 检查 `value` 是否小于等于 `expect`。 注意,只有字符串、整数和浮点类型可以通过 AssertLT 进行比较,其他类型无效。 md5:784a9db44c03122b

func (*T) AssertNE

func (t *T) AssertNE(value, expect interface{})

AssertNE 检查 `value` 和 `expect` 是否不相等。 md5:418e91b330bc944f

func (*T) AssertNI

func (t *T) AssertNI(value, expect interface{})

AssertNI 检查 `value` 不在 `expect` 列表中。 `expect` 应该是一个切片, 而 `value` 可以是一个切片或基本类型变量。 md5:8657bc61646e08fc

func (*T) AssertNQ

func (t *T) AssertNQ(value, expect interface{})

AssertNQ 检查 `value` 和 `expect` 是否不相等,包括它们的类型。 md5:bb13af00897290db

func (*T) AssertNil

func (t *T) AssertNil(value interface{})

AssertNil 断言 `value` 为 nil。 md5:94a00206ff503e10

func (*T) Error

func (t *T) Error(message ...interface{})

使用给定的`message`引发错误恐慌。 md5:6ddb84d91c681d1f

func (*T) Fatal

func (t *T) Fatal(message ...interface{})

Fatal 将 `message` 打印到 stderr 并退出进程。 md5:15e177961f66ebe7

Jump to

Keyboard shortcuts

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