# README
assert
The assert package provides some helpful methods that allow you to write better test code in Go.
- Prints friendly for read
- Readable code
Installation
$ go get github.com/subchen/go-stack/assert
Usage
import (
"testing"
"github.com/subchen/go-stack/assert"
)
func TestToString(t *testing.T) {
assert.Equal(t, ToString(nil), "")
assert.Equal(t, ToString(true), "true")
assert.Equal(t, ToString(0), "0")
}
if you assert many times, use the below:
import (
"testing"
"github.com/subchen/go-stack/assert"
)
func TestToString(t *testing.T) {
assert := assert.New(t)
assert.Equal(ToString(nil), "")
assert.Equal(ToString(true), "true")
assert.Equal(ToString(0), "0")
}
result on failure
$ go test
--- FAIL: TestToString (0.00s)
to_string_test.go:12
Expected: "true"
Actual : "false"
FAIL
exit status 1
API on godoc.org
# Functions
Support array, slice, map, chan, string.
Empty asserts that the specified object is empty.
Equal asserts that two objects are equal.
EqualVal asserts that two objects are equal (convertable to the same types and equal).
Error asserts that the specified error is not nil.
False asserts that the specified value is false.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Implements asserts that an object is implemented by the specified interface.
Support array, slice, map, chan, string.
No description provided by the author
Nil asserts that the specified object is nil.
NoError asserts that the specified error is nil.
No description provided by the author
Support array, slice, map, chan, string.
array, slice, map, channel, string with len == 0.
NotEqual asserts that the specified values are NOT equal.
NotEqualVal asserts that two objects are NOT equal(convertable to the same types and equal).
NotNil asserts that the specified object is not nil.
NotZero asserts that object is not the zero value for its type and returns the truth.
No description provided by the author
SameType asserts that the specified objects are of the same type.
True asserts that the specified value is true.
Zero asserts that object is the zero value for its type and returns the truth.