Documentation ¶
Overview ¶
Package assert contains two functions, which allow you to make fluent truth comparisons which t.FailNow a test.
Example:
assert.That(t, 10, should.Equal(20)) assert.Loosely(t, myCustomInt(10), should.Equal(20))
In the example above, the test case would halt immediately after the first `assert.That`, because 10 does not equal 20, and `assert.That` will call t.FailNow().
This package has a sibling package `check` which instead does t.Fail, allowing tests to make multiple checks without halting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrIsLike ¶
ErrIsLike is a short helper to check that a given `err` matches a string or error `target`.
This is identical to:
assert.That(t, err, should.ErrLike(target))
See should.ErrLike.
func Loosely ¶
func Loosely[T any](t truth.TestingTB, actual any, compare comparison.Func[T], opts ...truth.Option)
Loosely will compare `actual` using `compare.CastCompare(actual)`.
If this results in a failure.Summary, it will be reported with truth.Report, and the test will be failed with t.Fail().
Example: `assert.Loosely(t, 10, should.Equal(20))`
Returns `true` iff `compare.CastCompare(actual)` returned no failure (i.e. nil)
func NoErr ¶
NoErr is a short helper to check that a given `err` is nil.
This is identical to:
assert.That(t, err, should.ErrLike(nil))
See should.ErrLike.
Types ¶
This section is empty.