package module
Version: v0.0.0-...-63f1cf6 Latest Latest

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

Go to latest
Published: Feb 2, 2020 License: BSD-3-Clause Imports: 9 Imported by: 12




Package ensure provides utilities for testing to ensure the given conditions are met and Fatal if they aren't satisified.

The various functions here show a useful error message automatically including identifying source location. They additionally support arbitary arguments which will be printed using the spew library.



This section is empty.


This section is empty.


func DeepEqual

func DeepEqual(t Fataler, actual, expected interface{}, a ...interface{})

DeepEqual ensures actual and expected are equal. It does so using reflect.DeepEqual.

func DisorderedSubset

func DisorderedSubset(t Fataler, a, s interface{}, extra ...interface{})

DisorderedSubset attempts to find all the given subsets in the list of actuals. Does not allow one actual to match more than one subset, be warray of the possibility of insufficiently specific subsets.

func Err

func Err(t Fataler, err error, re *regexp.Regexp, a ...interface{})

Err ensures the error satisfies the given regular expression.

func False

func False(t Fataler, v bool, a ...interface{})

False ensures v is false.

func Nil

func Nil(t Fataler, v interface{}, a ...interface{})

Nil ensures v is nil.

func NotDeepEqual

func NotDeepEqual(t Fataler, actual, expected interface{}, a ...interface{})

NotDeepEqual ensures actual and expected are not equal. It does so using reflect.DeepEqual.

func NotNil

func NotNil(t Fataler, v interface{}, a ...interface{})

NotNil ensures v is not nil.

func PanicDeepEqual

func PanicDeepEqual(t Fataler, expected interface{}, a ...interface{})

PanicDeepEqual ensures a panic occurs and the recovered value is DeepEqual to the expected value.

func SameElements

func SameElements(t Fataler, actual, expected interface{}, extra ...interface{})

SameElements ensures the two given slices contain the same elements, ignoring the order. It uses DeepEqual for element comparison.

func StringContains

func StringContains(t Fataler, s, substr string, a ...interface{})

StringContains ensures string s contains the string substr.

func StringDoesNotContain

func StringDoesNotContain(t Fataler, s, substr string, a ...interface{})

StringDoesNotContain ensures string s does not contain the string substr.

func Subset

func Subset(t Fataler, actual, subset interface{}, a ...interface{})

Subset ensures actual matches subset.

func True

func True(t Fataler, v bool, a ...interface{})

True ensures v is true.


type Fataler

type Fataler interface {
	Fatal(a ...interface{})

Fataler defines the minimal interface necessary to trigger a Fatal when a condition is hit. testing.T & testing.B satisfy this for example.

Source Files

Jump to

Keyboard shortcuts

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