assert

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

assert

import "github.com/fufuok/utils/assert"

Index

func Equal

func Equal(tb testing.TB, expected, actual interface{}, msgAndArgs ...interface{})

Equal checks if values are equal Ref: gofiber/utils

func IsNil

func IsNil(o interface{}) bool

IsNil 判断对象(pointer, channel, func, interface, map, slice)是否为 nil nil 是一个 Type 类型的变量, Type 类型是基于 int 的类型 var 若变量本身是指针, 占用 8 字节, 指向类型内部结构体并置 0, 仅定义了变量本身, 此时为 nil

指针是非复合类型, 赋值 nil 时, 将 8 字节置 0, 即没有指向任何值的指针 0x0
map, channel: var 时仅定义了指针, 需要 make 初始化内部结构后才能使用, make 后非 nil

var 若变量非指针, 如 struct, int, 非 nil slice:

type slice struct, 占用 24 字节, 1 指针(array unsafe.Pointer) 2 个整型字段(len, cap int)
var 定义后即可使用, 置 0 并分配, 此时 array 指针为 0 即没有实际数据时为 nil

interface:

type iface struct(interface 类型), type eface struct(空接口), 占用 16 字节
判断 data 指针为 0 即为 nil, 初始化后即非 0

Ref: stretchr/testify

func Nil

func Nil(tb testing.TB, right interface{}, msgAndArgs ...interface{})

func NotEqual

func NotEqual(tb testing.TB, left, right interface{}, msgAndArgs ...interface{})

func NotNil

func NotNil(tb testing.TB, right interface{}, msgAndArgs ...interface{})

func Panics

func Panics(t *testing.T, title string, f func())

Panics 断言 panic

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(tb testing.TB, expected, actual interface{}, msgAndArgs ...interface{})

Equal checks if values are equal Ref: gofiber/utils

func False added in v0.9.9

func False(tb testing.TB, actual bool, msgAndArgs ...interface{})

func IsNil

func IsNil(o interface{}) bool

IsNil 判断对象(pointer, channel, func, interface, map, slice)是否为 nil nil 是一个 Type 类型的变量, Type 类型是基于 int 的类型 var 若变量本身是指针, 占用 8 字节, 指向类型内部结构体并置 0, 仅定义了变量本身, 此时为 nil

指针是非复合类型, 赋值 nil 时, 将 8 字节置 0, 即没有指向任何值的指针 0x0
map, channel: var 时仅定义了指针, 需要 make 初始化内部结构后才能使用, make 后非 nil

var 若变量非指针, 如 struct, int, 非 nil slice:

type slice struct, 占用 24 字节, 1 指针(array unsafe.Pointer) 2 个整型字段(len, cap int)
var 定义后即可使用, 置 0 并分配, 此时 array 指针为 0 即没有实际数据时为 nil

interface:

type iface struct(interface 类型), type eface struct(空接口), 占用 16 字节
判断 data 指针为 0 即为 nil, 初始化后即非 0

Ref: stretchr/testify

func Nil

func Nil(tb testing.TB, actual interface{}, msgAndArgs ...interface{})

func NotEqual

func NotEqual(tb testing.TB, left, right interface{}, msgAndArgs ...interface{})

func NotNil

func NotNil(tb testing.TB, right interface{}, msgAndArgs ...interface{})

func Panics

func Panics(t *testing.T, title string, f func())

Panics 断言 panic

func True added in v0.9.9

func True(tb testing.TB, actual bool, msgAndArgs ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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