gocheck2

package
v0.0.0-...-436d200 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Overview

Package gocheck2 contains extensions to the go-check unittest framework.

NOTE: see https://github.com/go-check/check/pull/6 for reasons why these checkers live here.

Index

Constants

This section is empty.

Variables

View Source
var AlmostEqual = &almostEqualChecker{}
View Source
var BytesEquals = &bytesEquals{}

BytesEquals checker compares two bytes sequence using bytes.Equal.

For example:

c.Assert(b, BytesEquals, []byte("bar"))

Main difference between DeepEquals and BytesEquals is that BytesEquals treats `nil` as empty byte sequence while DeepEquals doesn't.

c.Assert(nil, BytesEquals, []byte("")) // succeeds
c.Assert(nil, DeepEquals, []byte("")) // fails
View Source
var DeepEqualsPretty = &deepEqualsPretty{}

Standard gocheck DeepEquals just prints the values using %#v when it fails, which does traverse pointers during comparison but doesn't for printing, so if the difference is through a pointer the debug message is completely useless. Plus they're printed all on one line and very hard to read.

DeepEqualsPretty prints the entire structure of both args, with newlines and indendation, and diffs them, so it's easy to pick out what's different.

View Source
var GreaterOrEquals = &intCmp{"GreaterOrEquals", ">=", func(a, b int64) bool { return a >= b }}
View Source
var GreaterThan = &intCmp{"GreaterThan", ">", func(a, b int64) bool { return a > b }}
View Source
var HasKey = &hasKey{}

The HasKey checker verifies that the obtained map contains the given key.

For example:

c.Assert(myMap, HasKey, "foo")
View Source
var IsFalse Checker = &isBoolValueChecker{
	&CheckerInfo{Name: "IsFalse", Params: []string{"obtained"}},
	false,
}

The IsFalse checker verifies that the obtained value is false.

For example:

c.Assert(value, IsFalse)
View Source
var IsTrue Checker = &isBoolValueChecker{
	&CheckerInfo{Name: "IsTrue", Params: []string{"obtained"}},
	true,
}

The IsTrue checker verifies that the obtained value is true.

For example:

c.Assert(value, IsTrue)
View Source
var LessOrEquals = &intCmp{"LessOrEquals", "<=", func(a, b int64) bool { return a <= b }}
View Source
var LessThan = &intCmp{"LessThan", "<", func(a, b int64) bool { return a < b }}
View Source
var MultilineErrorMatches multilineErrorMatches = multilineErrorMatches{}
View Source
var MultilineMatches multilineMatches = multilineMatches{}
View Source
var NoErr = &noErr{}

The NoErr checker tests that the obtained value is nil. On failure, the checker adjusts the output so that a multi-line error message will be printed in a readable fashion.

For example:

c.Assert(err, NoErr)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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