Very simple tools for test assertions.
Go to file
2025-02-15 16:52:59 -06:00
.gitignore Initial commit 2025-02-15 13:47:05 -06:00
contains.go version 1 2025-02-15 16:52:59 -06:00
equal.go version 1 2025-02-15 16:52:59 -06:00
errors.go version 1 2025-02-15 16:52:59 -06:00
go.mod version 1 2025-02-15 16:52:59 -06:00
LICENSE Initial commit 2025-02-15 13:47:05 -06:00
nil.go version 1 2025-02-15 16:52:59 -06:00
README.md version 1 2025-02-15 16:52:59 -06:00
test_test.go version 1 2025-02-15 16:52:59 -06:00
test.go version 1 2025-02-15 16:52:59 -06:00
true.go version 1 2025-02-15 16:52:59 -06:00

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