unassert

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 0 Imported by: 10

README

unassert - providing a lack of assertions

unassert is a library that provides assertions based on the provided build tags.

By default assertions are disabled (NOP implementation) to provide the best possible performance. There are multiple implementations available that can be enabled to discover issues in automated test runs or in QA environments.

GoDoc Build Status Go Report License

Go Get

go get -u github.com/markus-wa/go-unassert

Example

package main

import (
    "fmt"

    "github.com/markus-wa/go-unassert"
)

func main() {
    unassert.True(true)

    fmt.Println("Hello")

    unassert.Same("a", "b")

    fmt.Println("World")
}
Assertions disabled
$ go run main.go
Hello
World
unassert_panic
$ go run -tags unassert_panic main.go
Hello
panic: assertion failed: a != b

goroutine 1 [running]:
github.com/markus-wa/go-unassert.Same(...)
    C:/Users/mwalt/dev/go-unassert/panic.go:11
main.main()
    C:/Users/mwalt/dev/go-unassert/example/example.go:14 +0x1c3
exit status 2
unassert_stderr
$ go run -tags unassert_stderr main.go
Hello
assertion failed: a != b
goroutine 1 [running]:
runtime/debug.Stack(0x19, 0x0, 0x0)
    C:/Users/mwalt/scoop/apps/go/current/src/runtime/debug/stack.go:24 +0xa4
runtime/debug.PrintStack()
    C:/Users/mwalt/scoop/apps/go/current/src/runtime/debug/stack.go:16 +0x29
github.com/markus-wa/go-unassert.Same(0x4aace0, 0x4e8b00, 0x4aace0, 0x4e8b10)
    C:/Users/mwalt/dev/go-unassert/stderr.go:14 +0xc4
main.main()
    C:/Users/mwalt/dev/go-unassert/example/example.go:14 +0xb6
World

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Same

func Same(a interface{}, b interface{})

Same checks if a == b. Behaves according to 'unassert_' build tags.

func True

func True(b bool)

True checks if b is true. Behaves according to 'unassert_' build tags.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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