require

package
v1.0.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package require includes test assertions that fail the test immediately. This is like to testify, but without a dependency.

Note: Assertions here are internal and are free to be customized to only support valid WebAssembly types, or to reduce code in tests that only require certain types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapturePanic

func CapturePanic(panics func()) (err error)

CapturePanic returns an error recovered from a panic. If the panic was not an error, this converts it to one.

func Contains

func Contains(t TestingT, s, substr string, formatWithArgs ...interface{})

Contains fails if `s` does not contain `substr` using strings.Contains.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func Equal

func Equal(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})

Equal fails if the actual value is not equal to the expected.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func EqualError

func EqualError(t TestingT, err error, expected string, formatWithArgs ...interface{})

EqualError fails if the err is nil or its `Error()` value is not equal to the expected.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func Error

func Error(t TestingT, err error, formatWithArgs ...interface{})

Error fails if the err is nil.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func ErrorIs

func ErrorIs(t TestingT, err, target error, formatWithArgs ...interface{})

ErrorIs fails if the err is nil or errors.Is fails against the expected.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func False

func False(t TestingT, actual bool, formatWithArgs ...interface{})

False fails if the actual value was true.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func Nil

func Nil(t TestingT, object interface{}, formatWithArgs ...interface{})

Nil fails if the object is not nil.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func NoError

func NoError(t TestingT, err error, formatWithArgs ...interface{})

NoError fails if the err is not nil.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func NotEqual

func NotEqual(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})

NotEqual fails if the actual value is equal to the expected.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func NotNil

func NotNil(t TestingT, object interface{}, formatWithArgs ...interface{})

NotNil fails if the object is nil.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func NotSame

func NotSame(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})

NotSame fails if the inputs point to the same object.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func Same

func Same(t TestingT, expected, actual interface{}, formatWithArgs ...interface{})

Same fails if the inputs don't point to the same object.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func True

func True(t TestingT, actual bool, formatWithArgs ...interface{})

True fails if the actual value wasn't.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

func Zero

func Zero(t TestingT, i interface{}, formatWithArgs ...interface{})

Zero fails if the actual value wasn't.

  • formatWithArgs are optional. When the first is a string that contains '%', it is treated like fmt.Sprintf.

Note: This isn't precise to numeric types, but we don't care as being more precise is more code and tests.

Types

type TestingT

type TestingT interface {
	Fatal(args ...interface{})
}

TestingT is an interface wrapper of functions used in TestingT

Jump to

Keyboard shortcuts

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