check

package
v3.12.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

This package provindes extensions to "gopkg.in/check.v1".

The build-in checkers are defined as public variables.

ChannelEquals

This checker checks two channels that if they are same(for both len() and content).

c.Assert(checkedChannel, check.JsonEquals, expectedChannel)

JsonEquals

This checker checks JSON content(supports various types).

c.Assert("[3, 4, 5]", check.JsonEquals, "[3, 4, 5")
c.Assert("[3, 4, 5]", check.JsonEquals, []byte("[3, 4, 5]"))
c.Assert(jsonObject, check.JsonEquals, "[3, 4, 5]")
c.Assert(anyObject, check.JsonEquals, "[3, 4, 5]")

Number checkers

These number checkers supports comparison between numbers without enforcement on types.

For example: compares "int16(34)" and "int32(77)"

LargerThan - obtained > expected
c.Assert(obtained, check.LargerThan, expected)

LargerThanOrequalTo - obtained >= expected
c.Assert(obtained, check.LargerThanOrEqualTo, expected)

SmallerThan - obtained < expected
c.Assert(obtained, check.SmallerThan, expected)

SmallerThanOrequalTo - obtained <= expected
c.Assert(obtained, check.SmallerThanOrEqualTo, expected)

StringContains

Checks if a sub-string is contained in checked string.

c.Assert("Hello World", check.StringContains, "llo")

Time checkers

The time checkers only checks value of UNIX time, the time zone is ignored.

TimeEquals - Equivalence of two values of time
c.Assert(obtainedTime, TimeEquals, expectedTime)

TimeBefore - The obtained one must be earlier the expected one
c.Assert(obtainedTime, TimeEquals, expectedTime)

TimeAfter - The obtained one must be latter the expected one
c.Assert(obtainedTime, TimeEquals, expectedTime)

ViableValue

This checker checks if a value is viable.

See "utils.ValueExt.IsViable()" for detail.

Index

Constants

This section is empty.

Variables

View Source
var ChannelEquals = channelEquals(true)

This checking would check:

  1. The len() for both of the channels and
  2. Every element(be put back) in both of the channels
View Source
var JsonEquals = &checkJsonEquals{}

Checks two varialbes which could be converted to "*go-simplejson.Json"

Various types of variable are supported:

string - JSON string
[]byte - As JSON string
io.Reader - A reader contains JSON
*go-simplejson.Json

If non of above types is matched, this checker uses "encoding/json.Marshal()" to marshal the object to JSON format and performs comparison.

See "https://godoc.org/github.com/bitly/go-simplejson" for detail information of simplejson

View Source
var LargerThan = &checkForCompare{largerThan, "LargerThan", "The left value **is not** larger than right value"}

Checks if obtained > expected

View Source
var LargerThanOrEqualTo = &checkForCompare{largerThanOrEqualTo, "LargerThanOrEqual", "The left value **is not** larger than or equal to right value"}

Checks if obtained >= expected

View Source
var SmallerThan = &checkForCompare{smallerThan, "SmallerThan", "The left value **is not** larger than right value"}

Checks if obtained < expected

View Source
var SmallerThanOrEqualTo = &checkForCompare{smallerThanOrEqualTo, "SmallerThanOrEqual", "The left value **is not** larger than or equal to right value"}

Checks if obtained <= expected

View Source
var StringContains = stringContains(true)
View Source
var TimeAfter timeAfterImpl

Checks if the obtained time is after expected time(only UNIX time).

View Source
var TimeBefore timeBeforeImpl

Checks if the obtained time is before expected time(only UNIX time).

View Source
var TimeEquals timeEqualsImpl

Checks if the both of time value are equal(only UNIX time).

View Source
var ViableValue = viableValue(true)

See "utils.ValueExt.IsViable()" function

Functions

func LogTestCase

func LogTestCase(c *C, testCase interface{})

func TestCaseComment

func TestCaseComment(index int) CommentInterface

Types

This section is empty.

Jump to

Keyboard shortcuts

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