assert

package
v1.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

assert

提供了一些常用的断言函数。

方法列表

方法名 功能
True asserts that got is true.
False asserts that got is false.
Nil asserts that got is nil.
NotNil asserts that got is not nil.
Equal asserts that got and expect are equal.
NotEqual asserts that got and expect are not equal.
Panic asserts that function would panic.
Matches asserts that a got value matches a given regular expression.
Error asserts that a got error string matches a given regular expression.

Documentation

Overview

Package assert 提供了一些常用的断言函数。

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 *testing.T, got interface{}, expect interface{})

Equal asserts that got and expect are equal.

func Error

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

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

func False

func False(t *testing.T, got bool)

False asserts that got is false.

func Matches

func Matches(t *testing.T, got string, expr string)

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

func Nil

func Nil(t *testing.T, got interface{})

Nil asserts that got is nil.

func NotEqual

func NotEqual(t *testing.T, got interface{}, expect interface{})

NotEqual asserts that got and expect are not equal.

func NotNil

func NotNil(t *testing.T, got interface{})

NotNil asserts that got is not nil.

func Panic

func Panic(t *testing.T, fn func(), expr string)

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

func True

func True(t *testing.T, got bool)

True asserts that got is true.

Types

type Cases

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

Jump to

Keyboard shortcuts

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