package
1.0.1
Repository: https://github.com/subchen/go-stack.git
Documentation: pkg.go.dev

# README

assert

Go Report Card GoDoc

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

https://godoc.org/github.com/subchen/go-stack/assert