godropbox: github.com/dropbox/godropbox/gocheck2 Index | Files

package gocheck2

import "github.com/dropbox/godropbox/gocheck2"

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

Package Files

checkers.go

Variables

var AlmostEqual = &almostEqualChecker{}
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
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.

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

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

For example:

c.Assert(myMap, HasKey, "foo")
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)
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)
var LessOrEquals = &intCmp{"LessOrEquals", "<=", func(a, b int64) bool { return a <= b }}
var LessThan = &intCmp{"LessThan", "<", func(a, b int64) bool { return a < b }}
var MultilineErrorMatches multilineErrorMatches = multilineErrorMatches{}
var MultilineMatches multilineMatches = multilineMatches{}
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)

Package gocheck2 imports 8 packages (graph) and is imported by 1 packages. Updated 2020-03-04. Refresh now. Tools for package owners.