testutil

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConvertibleTo Checker = &convertibleToChecker{
	&CheckerInfo{Name: "ConvertibleTo", Params: []string{"value", "sample"}}}

ConvertibleTo determines whether a value of one type can be converted to another type.

For example:

c.Check(err, ConvertibleTo, *os.PathError{})
View Source
var ErrorAs Checker = &errorAsChecker{
	&CheckerInfo{Name: "ErrorAs", Params: []string{"value", "target"}}}

ErrorAs determines whether any error in a chain has a specific type, using errors.As.

For example:

var e *os.PathError
c.Check(err, ErrorAs, &e)
c.Check(e.Path, Equals, "/foo/bar")
View Source
var ErrorIs Checker = &errorIsChecker{
	&CheckerInfo{Name: "ErrorIs", Params: []string{"value", "expected"}}}

ErrorIs determines whether any error in a chain has a specific value, using errors.Is

For example:

c.Check(err, ErrorIs, io.EOF)
View Source
var IntEqual Checker = &intChecker{
	&CheckerInfo{Name: "IntEqual", Params: []string{"x", "y"}}}

IntEqual checks that x is equal to y. Both values must be an integer kind. They don't have to have the same type, although y must be representable by the type of x.

For example:

c.Check(x, IntEqual, 10)
View Source
var IntGreater Checker = &intChecker{
	&CheckerInfo{Name: "IntGreater", Params: []string{"x", "y"}}}

IntGreater checks that x is greater than y. Both values must be an integer kind. They don't have to have the same type, although y must be representable by the type of x.

For example:

c.Check(x, IntGreater, 10)
View Source
var IntGreaterEqual Checker = &intChecker{
	&CheckerInfo{Name: "IntGreaterEqual", Params: []string{"x", "y"}}}

IntGreaterEqual checks that x is greater than or equal to y. Both values must be an integer kind. They don't have to have the same type, although y must be representable by the type of x.

For example:

c.Check(x, IntGreaterEqual, 10)
View Source
var IntLess Checker = &intChecker{
	&CheckerInfo{Name: "IntLess", Params: []string{"x", "y"}}}

IntLess checks that x is less than y. Both values must be an integer kind. They don't have to have the same type, although y must be representable by the type of x.

For example:

c.Check(x, IntLess, 10)
View Source
var IntLessEqual Checker = &intChecker{
	&CheckerInfo{Name: "IntLessEqual", Params: []string{"x", "y"}}}

IntLessEqual checks that x is less than or equal to y. Both values must be an integer kind. They don't have to have the same type, although y must be representable by the type of x.

For example:

c.Check(x, IntLessEqual, 10)
View Source
var IntNotEqual Checker = &intChecker{
	&CheckerInfo{Name: "IntNotEqual", Params: []string{"x", "y"}}}

IntNotEqual checks that x is not equal to y. Both values must be an integer kind. They don't have to have the same type, although y must be representable by the type of x.

For example:

c.Check(x, IntNotEqual, 10)
View Source
var IsFalse Checker = &isFalseChecker{
	&CheckerInfo{Name: "IsFalse", Params: []string{"value"}}}

IsFalse determines whether a boolean value is false.

View Source
var IsTrue Checker = &isTrueChecker{
	&CheckerInfo{Name: "IsTrue", Params: []string{"value"}}}

IsTrue determines whether a boolean value is true.

View Source
var LenEquals Checker = &hasLenChecker{
	&CheckerInfo{Name: "LenEquals", Params: []string{"value", "n"}}, IntEqual}

LenEquals checks that the value has the specified length. This differs from check.HasLen in that it returns an error string containing the actual length if the check fails.

For example:

c.Check(value, LenEquals, 5)
View Source
var LenGreater Checker = &hasLenChecker{
	&CheckerInfo{Name: "LenGreater", Params: []string{"value", "n"}}, IntGreater}

LenGreater checks that the value has a length that is greater than n.

For example:

c.Check(value, LenGreater, 5)
View Source
var LenGreaterEquals Checker = &hasLenChecker{
	&CheckerInfo{Name: "LenGreaterEquals", Params: []string{"value", "n"}}, IntGreaterEqual}

LenGreaterEquals checks that the value has a length that is greater than or equal to n.

For example:

c.Check(value, LenGreaterEquals, 5)

Functions

func DecodeHexString

func DecodeHexString(c *C, s string) []byte

DecodeHexString decodes the supplied hex string in to a byte slice.

func DecodeHexStringT

func DecodeHexStringT(t *testing.T, s string) []byte

DecodeHexStringT decodes the supplied hex string in to a byte slice.

func IsOneOf

func IsOneOf(checker Checker) Checker

IsOneOf determines whether a value is contained in the provided slice, using the specified checker.

For example:

c.Check(value, IsOneOf(Equals), []int{1, 2, 3})

Types

This section is empty.

Jump to

Keyboard shortcuts

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