...

Package require

import "github.com/tetratelabs/wazero/internal/testing/require"
Overview
Index

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.

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.

func Equal

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

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

func EqualErrno

func EqualErrno(t TestingT, expected sys.Errno, err error, formatWithArgs ...interface{})

EqualErrno should be used for functions that return sys.Errno or nil.

func EqualError

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

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

func Error

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

Error fails if the err is nil.

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.

func False

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

False fails if the actual value was true.

func Nil

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

Nil fails if the object is not nil.

func NoError

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

NoError fails if the err is not nil.

func NotEqual

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

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

func NotNil

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

NotNil fails if the object is nil.

func NotSame

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

NotSame fails if the inputs point to the same object.

func Same

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

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

func True

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

True fails if the actual value wasn't.

func Zero

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

Zero fails if the actual value wasn't.

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

type EqualTo

type EqualTo interface {
    EqualTo(that interface{}) bool
}

type TestingT

TestingT is an interface wrapper of functions used in TestingT

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