assert

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package assert provides the assersion feature for *testing.T You can use assert functions by `assert.New(t)`

import (
    "testing"
    "github.com/speedland/go/x/xtesting/assert"
)

func TestSomething(t *testing.T){
    assert := assert.New(t)
    assert.OK(true)
    assert.EqInt(1, 1)
    assert.EqStr("Expects", "Got", "Somthing wrong!")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assert

type Assert struct {
	*testing.T
}

Assert is a helper struct for testing assersion

func New

func New(t *testing.T) *Assert

New return a new *Assert

func (*Assert) EqByteString

func (a *Assert) EqByteString(expect string, got []byte, msgContext ...interface{})

EqByteString for equality assertion ([]byte string)

func (*Assert) EqFloat32

func (a *Assert) EqFloat32(expect, got float32, msgContext ...interface{})

EqFloat32 for equality assertion (float32)

func (*Assert) EqFloat64

func (a *Assert) EqFloat64(expect, got float64, msgContext ...interface{})

EqFloat64 for equality assertion (float64)

func (*Assert) EqInt

func (a *Assert) EqInt(expect, got int, msgContext ...interface{})

EqInt for equality assertion (int)

func (*Assert) EqInt32

func (a *Assert) EqInt32(expect, got int32, msgContext ...interface{})

EqInt32 for equality assertion (int32)

func (*Assert) EqInt64

func (a *Assert) EqInt64(expect, got int64, msgContext ...interface{})

EqInt64 for equality assertion (int64)

func (*Assert) EqStr

func (a *Assert) EqStr(expect, got string, msgContext ...interface{})

EqStr for equality assertion (string)

func (*Assert) EqTime

func (a *Assert) EqTime(expect, got time.Time, msgContext ...interface{})

EqTime for equality assertion (time.Time)

func (*Assert) Failure

func (a *Assert) Failure(expect interface{}, got interface{}, msgContext ...interface{})

Failure fails the test with a report This function expects to be used by another assertion package, not by test code.

func (*Assert) GtInt

func (a *Assert) GtInt(min, got int, msgContext ...interface{})

GtInt for 'greater than' assertion (int)

func (*Assert) LtInt

func (a *Assert) LtInt(max, got int, msgContext ...interface{})

LtInt for 'less than' assertion (int)

func (*Assert) Nil

func (a *Assert) Nil(v interface{}, msgContext ...interface{})

Nil for nil assertion

func (*Assert) Not

func (a *Assert) Not(ok bool, msgContext ...interface{})

Not for false assertion

func (*Assert) NotNil

func (a *Assert) NotNil(v interface{}, msgContext ...interface{})

NotNil for non-nil assertion

func (*Assert) NotZero

func (a *Assert) NotZero(v interface{}, msgContext ...interface{})

NotZero for non Zero assertion

func (*Assert) OK

func (a *Assert) OK(ok bool, msgContext ...interface{})

OK for true assertion.

func (Assert) SkipIfErr

func (a Assert) SkipIfErr(err error)

SkipIfErr skip the test if an error occurrs.

func (*Assert) Zero

func (a *Assert) Zero(v interface{}, msgContext ...interface{})

Zero for Zero value assertion

Jump to

Keyboard shortcuts

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