assert

package module
v0.0.0-...-f1ab783 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: MIT Imports: 5 Imported by: 0

README

assert

NO LONGER MAINTAINED - Just use Go's testing package.

Build Status codecov goreportcard for eleztian/assert godoc for eleztian/assert MIT Licence

Fork Form github.com/bmizerany/assert

Assertions for Go tests

Install

$ go get github.com/eleztian/assert

Use

point.go

package point

type Point struct {
    x, y int
}
func (p Point) String() string {
    return fmt.Sprintf("%d,%d", p.X, p.Y)
}

point_test.go

package point

import (
    "testing"
    "github.com/bmizerany/assert"
)

func TestAsserts(t *testing.T) {
    p1 := Point{1, 1}
    p2 := Point{2, 1}

    assert.Equal(t, p1, p2)
}
func TestTestTable(t *testing.T) {
    tb := assert.TestTable{
        Point{1,1}:"1,1",
        Point{2,2}:"2,2",
        Point{3,2}:"3,2",
    }

    tb.Test(t, func(cond interface{}) (i interface{}, e error) {
        return cond.(Point).String(), nil
    })
}

output

$ go test
 --- FAIL: TestAsserts (0.00 seconds)
 assert.go:15: /Users/flavio.barbosa/dev/stewie/src/point_test.go:12
     assert.go:24: ! X: 1 != 2
 FAIL

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(t *testing.T, exp, got interface{}, args ...interface{})

func Equalf

func Equalf(t *testing.T, exp, got interface{}, format string, args ...interface{})

func NotEqual

func NotEqual(t *testing.T, exp, got interface{}, args ...interface{})

func Panic

func Panic(t *testing.T, err interface{}, fn func())

func T

func T(t *testing.T, result bool, args ...interface{})

func Tf

func Tf(t *testing.T, result bool, format string, args ...interface{})

Types

type TestTable

type TestTable map[interface{}]interface{}

func (TestTable) Test

func (tb TestTable) Test(t *testing.T, f func(cond interface{}) (interface{}, error))

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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