assert

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: MIT Imports: 3 Imported by: 0

README

go-assert

Build Status Go Report Card go.dev reference

Simple asserts to use with golang testing.

Quickstart

// file test_test.go
package test

import (
    "testing"

    assert "github.com/allisson/go-assert"
)

func TestExamples(t *testing.T) {
    assert.Equal(t, 1, 1)
    assert.NotEqual(t, 1, 2)
    assert.Nil(t, nil)
    assert.NotNil(t, 1)
}
go test -v
=== RUN   TestExamples
--- PASS: TestExamples (0.00s)
PASS
// file test_test.go
package test

import (
    "testing"

    assert "github.com/allisson/go-assert"
)

func TestExamples(t *testing.T) {
    assert.Equal(t, 1, 2)
}
go test -v
=== RUN   TestExamples
--- FAIL: TestExamples (0.00s)
    test_test.go:10: assertion_type=Equal, expected_value=1, expected_type=int, current_value=2, current_type=int
FAIL
exit status 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(t *testing.T, expected, current interface{})

Equal compares two values using reflect.DeepEqual and fails if not equals

func Nil

func Nil(t *testing.T, current interface{})

Nil fails if value is not nil

func NotEqual

func NotEqual(t *testing.T, expected, current interface{})

NotEqual compares two values using reflect.DeepEqual and fails if equals

func NotNil

func NotNil(t *testing.T, current interface{})

NotNil fails is value is nil

Types

This section is empty.

Jump to

Keyboard shortcuts

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