assert

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: Unlicense Imports: 5 Imported by: 0

README

Assert

Very simple tools for test assertions. Why doesn't Go have assertions built in? Anyone's guess! All credit to Eduard Urbach. The only reason this package exists is to keep a local copy of it for myself, and to handle stylistic differences.

Features

  • Simple API; few brain cells required
  • Tiny codebase; little overhead
  • Zero dependencies; self-contained, built-in Go code. It's predictable!

Installation

go get git.sharkk.net/Go/Assert

Usage

assert.Nil(t, nil)
assert.True(t, true)
assert.Equal(t, "Hello", "Hello")
assert.DeepEqual(t, "Hello", "Hello")
assert.Contains(t, "Hello", "ello")

Tests

PASS: TestContains
PASS: TestNotContains
PASS: TestFailContains
PASS: TestFailNotContains
PASS: TestEqual
PASS: TestNotEqual
PASS: TestDeepEqual
PASS: TestFailEqual
PASS: TestFailNotEqual
PASS: TestFailDeepEqual
PASS: TestNil
PASS: TestNotNil
PASS: TestFailNil
PASS: TestFailNotNil
PASS: TestTrue
coverage: 100.0% of statements

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(t test, container any, element any)

Contains asserts that a contains b

func DeepEqual

func DeepEqual[T any](t test, expected T, actual T)

DeepEqual asserts that the two given values are deeply equal

func Equal

func Equal[T comparable](t test, expected T, actual T)

Equal asserts that the two given values are equal

func False

func False(t test, value bool)

False asserts that the given value is false

func Nil

func Nil(t test, value any)

Nil asserts that the given value equals nil

func NotContains

func NotContains(t test, container any, element any)

NotContains asserts that a doesn't contain b

func NotEqual

func NotEqual[T comparable](t test, expected T, actual T)

NotEqual asserts that the two given values are not equal

func NotNil

func NotNil(t test, value any)

NotNil asserts that the given value does not equal nil

func True

func True(t test, value bool)

True asserts that the given value is true

Types

This section is empty.

Jump to

Keyboard shortcuts

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