assert

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: BSD-3-Clause Imports: 8 Imported by: 1

README

Assert for Go1.9+ testing

Build Status Go Report Card GoDoc

Install

  1. go get -u github.com/chai2010/assert
  2. go test

Example

package somepkg_test

import (
	. "github.com/chai2010/assert"
)

func TestAssert(t *testing.T) {
	Assert(t, 1 == 1)
	Assert(t, 1 == 1, "message1", "message2")
}

func TestAssertf(t *testing.T) {
	Assertf(t, 1 == 1, "%v:%v", "message1", "message2")
}

BUGS

Report bugs to chaishushan@gmail.com.

Thanks!

Documentation

Overview

Package assert provides assert helper functions for testing package.

Example:

package somepkg_test

import (
	. "github.com/chai2010/assert"
)

func TestAssert(t *testing.T) {
	Assert(t, 1 == 1)
	Assert(t, 1 == 1, "message1", "message2")
}

func TestAssertf(t *testing.T) {
	Assertf(t, 1 == 1, "%v:%v", "message1", "message2")
}

See failed test output (assert_failed_test.go):

go test -assert.failed

Report bugs to <chaishushan@gmail.com>.

Thanks!

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(tb testing.TB, condition bool, args ...interface{})

func AssertBetween

func AssertBetween(tb testing.TB, min, max, val float64, args ...interface{})

func AssertEqual

func AssertEqual(tb testing.TB, expected, got interface{}, args ...interface{})

func AssertFalse

func AssertFalse(tb testing.TB, condition bool, args ...interface{})

func AssertFileExists

func AssertFileExists(tb testing.TB, path string, args ...interface{})

func AssertFileNotExists

func AssertFileNotExists(tb testing.TB, path string, args ...interface{})

func AssertImageEqual

func AssertImageEqual(tb testing.TB, expected, got image.Image, maxDelta color.Color, args ...interface{})

func AssertImplements

func AssertImplements(tb testing.TB, interfaceObj, obj interface{}, args ...interface{})

func AssertMapContain

func AssertMapContain(tb testing.TB, m, key, val interface{}, args ...interface{})

func AssertMapContainKey

func AssertMapContainKey(tb testing.TB, m, key interface{}, args ...interface{})

func AssertMapContainVal

func AssertMapContainVal(tb testing.TB, m, val interface{}, args ...interface{})

func AssertMapEqual

func AssertMapEqual(tb testing.TB, expected, got interface{}, args ...interface{})

func AssertMapNotContain

func AssertMapNotContain(tb testing.TB, m, key, val interface{}, args ...interface{})

func AssertMapNotContainKey

func AssertMapNotContainKey(tb testing.TB, m, key interface{}, args ...interface{})

func AssertMapNotContainVal

func AssertMapNotContainVal(tb testing.TB, m, val interface{}, args ...interface{})

func AssertMatch

func AssertMatch(tb testing.TB, expectedPattern string, got []byte, args ...interface{})

func AssertMatchString

func AssertMatchString(tb testing.TB, expectedPattern, got string, args ...interface{})

func AssertNear

func AssertNear(tb testing.TB, expected, got, abs float64, args ...interface{})

func AssertNil

func AssertNil(tb testing.TB, p interface{}, args ...interface{})

func AssertNotBetween

func AssertNotBetween(tb testing.TB, min, max, val float64, args ...interface{})

func AssertNotEqual

func AssertNotEqual(tb testing.TB, expected, got interface{}, args ...interface{})

func AssertNotNil

func AssertNotNil(tb testing.TB, p interface{}, args ...interface{})

func AssertNotPanic

func AssertNotPanic(tb testing.TB, f func(), args ...interface{})

func AssertNotZero

func AssertNotZero(tb testing.TB, val interface{}, args ...interface{})

func AssertPanic

func AssertPanic(tb testing.TB, f func(), args ...interface{})

func AssertSameType

func AssertSameType(tb testing.TB, expectedType interface{}, obj interface{}, args ...interface{})

func AssertSliceContain

func AssertSliceContain(tb testing.TB, slice, val interface{}, args ...interface{})

func AssertSliceNotContain

func AssertSliceNotContain(tb testing.TB, slice, val interface{}, args ...interface{})

func AssertTrue

func AssertTrue(tb testing.TB, condition bool, args ...interface{})

func AssertZero

func AssertZero(tb testing.TB, val interface{}, args ...interface{})

func Assertf

func Assertf(tb testing.TB, condition bool, format string, a ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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