Documentation ¶
Overview ¶
Package gtest 提供了方便的测试工具集,用于进行单元测试。
Index ¶
- func Assert(value, expect interface{})
- func AssertEQ(value, expect interface{})
- func AssertGE(value, expect interface{})
- func AssertGT(value, expect interface{})
- func AssertIN(value, expect interface{})
- func AssertLE(value, expect interface{})
- func AssertLT(value, expect interface{})
- func AssertNE(value, expect interface{})
- func AssertNI(value, expect interface{})
- func AssertNQ(value, expect interface{})
- func AssertNil(value interface{})
- func C(t *testing.T, f func(t *T))
- func DataContent(names ...string) string
- func DataPath(names ...string) string
- func Error(message ...interface{})
- func Fatal(message ...interface{})
- type T
- func (t *T) Assert(value, expect interface{})
- func (t *T) AssertEQ(value, expect interface{})
- func (t *T) AssertGE(value, expect interface{})
- func (t *T) AssertGT(value, expect interface{})
- func (t *T) AssertIN(value, expect interface{})
- func (t *T) AssertLE(value, expect interface{})
- func (t *T) AssertLT(value, expect interface{})
- func (t *T) AssertNE(value, expect interface{})
- func (t *T) AssertNI(value, expect interface{})
- func (t *T) AssertNQ(value, expect interface{})
- func (t *T) AssertNil(value interface{})
- func (t *T) Error(message ...interface{})
- func (t *T) Fatal(message ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEQ ¶
func AssertEQ(value, expect interface{})
AssertEQ 检查 `value` 和 `expect` 是否相等,包括它们的 TYPE(类型)。
func AssertGE ¶
func AssertGE(value, expect interface{})
AssertGE 检查 `value` 是否大于或等于 `expect`。 注意,只有字符串、整数和浮点类型可以使用 AssertGTE 进行比较,其他类型无效。
func AssertGT ¶
func AssertGT(value, expect interface{})
AssertGT 检查 `value` 是否大于 `expect`。 注意,只有字符串、整数和浮点类型可以通过 AssertGT 进行比较, 其他类型是无效的。
func AssertIN ¶
func AssertIN(value, expect interface{})
AssertIN 检查 `value` 是否在 `expect` 中。 `expect` 应该是一个切片类型, 但 `value` 可以是切片类型或基本类型变量。 TODO: 添加对 map 类型的支持。 TODO: gconv.Strings(0) 的结果不是 [0]
func AssertLE ¶
func AssertLE(value, expect interface{})
AssertLE 检查 `value` 是否小于等于 `expect`。 注意,只有字符串、整数和浮点类型可以通过 AssertLTE 进行比较, 其他类型是无效的。
func AssertLT ¶
func AssertLT(value, expect interface{})
AssertLT 检查 `value` 是否小于等于 `expect`。 注意,只有字符串、整数和浮点类型可以使用 AssertLT 进行比较, 其他类型无效。
func AssertNI ¶
func AssertNI(value, expect interface{})
AssertNI 检查 `value` 是否不在 `expect` 中。 `expect` 应该是一个切片, 但 `value` 可以是切片或基本类型变量。 TODO: 添加对 map 的支持。
func AssertNQ ¶
func AssertNQ(value, expect interface{})
AssertNQ 检查 `value` 和 `expect` 是否不相等,包括它们的类型。
func DataContent ¶
DataContent 函数用于获取并返回当前包中指定testdata路径下的文件内容
Types ¶
type T ¶
T 是测试用例管理对象。
func (*T) AssertEQ ¶
func (t *T) AssertEQ(value, expect interface{})
AssertEQ 检查 `value` 和 `expect` 是否相等,包括它们的 TYPE(类型)。
func (*T) AssertGE ¶
func (t *T) AssertGE(value, expect interface{})
AssertGE 检查 `value` 是否大于或等于 `expect`。 注意,只有字符串、整数和浮点类型可以使用 AssertGTE 进行比较,其他类型无效。
func (*T) AssertGT ¶
func (t *T) AssertGT(value, expect interface{})
AssertGT 检查 `value` 是否大于 `expect`。 注意,只有字符串、整数和浮点类型可以通过 AssertGT 进行比较, 其他类型是无效的。
func (*T) AssertIN ¶
func (t *T) AssertIN(value, expect interface{})
AssertIN 检查 `value` 是否在 `expect` 内。 其中 `expect` 应为一个切片, 但 `value` 可以是切片或基本类型变量。
func (*T) AssertLE ¶
func (t *T) AssertLE(value, expect interface{})
AssertLE 检查 `value` 是否小于等于 `expect`。 注意,只有字符串、整数和浮点类型可以通过 AssertLTE 进行比较, 其他类型是无效的。
func (*T) AssertLT ¶
func (t *T) AssertLT(value, expect interface{})
AssertLT 检查 `value` 是否小于等于 `expect`。 注意,只有字符串、整数和浮点类型可以使用 AssertLT 进行比较, 其他类型无效。
func (*T) AssertNE ¶
func (t *T) AssertNE(value, expect interface{})
AssertNE 检查 `value` 和 `expect` 是否不相等。
func (*T) AssertNI ¶
func (t *T) AssertNI(value, expect interface{})
AssertNI 检查 `value` 是否不在 `expect` 中。 `expect` 应该是一个切片, 但 `value` 可以是切片或基本类型变量。