Documentation
¶
Overview ¶
Package musta provides assertions that fail the test immediately.
Index ¶
- func BeDeepEqual(tb TB, actual, expected any)
- func BeEqual[T cmp.Ordered](tb TB, actual, expected T)
- func BeFalse(tb TB, actual bool)
- func BeGreater[T cmp.Ordered](tb TB, actual, expected T)
- func BeLess[T cmp.Ordered](tb TB, actual, expected T)
- func BeNil(tb TB, actual any)
- func BeTrue(tb TB, actual bool)
- func BeZero[T cmp.Ordered](tb TB, actual T)
- func CompareEqual[T any](tb TB, actual, expected T, compare func(_, _ T) int)
- func CompareGreater[T any](tb TB, actual, expected T, compare func(_, _ T) int)
- func CompareLess[T any](tb TB, actual, expected T, compare func(_, _ T) int)
- func CompareWith[T any](tb TB, actual, expected T, order cmp.Order, compare func(_, _ T) int)
- func Satisfy[T any](tb TB, actual T, predicate func(_ T) bool)
- func SatisfyWith[T any](tb TB, actual, expected T, predicate func(_, _ T) bool)
- type TB
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeDeepEqual ¶
BeDeepEqual checks that actual and expected are deeply equal.
Example ¶
BeDeepEqual(t, []int{13}, []int64{13})
Output: Values are not deep equal: actual: []int{13} expected: []int64{13} FAIL
func CompareEqual ¶
CompareEqual checks that compare(actual, expected) returns 0 (cmp.OrderEqual).
func CompareGreater ¶
CompareGreater checks that compare(actual, expected) returns 1 (cmp.OrderGreater).
func CompareLess ¶
CompareLess checks that compare(actual, expected) returns -1 (cmp.OrderLess).
func CompareWith ¶
CompareWith checks that compare(actual, expected) returns order.
func Satisfy ¶
Satisfy checks that predicate returns true for actual.
Example (Inline) ¶
Satisfy(t, 13, func(v int) bool { return v > 42 })
Output: predicate is not satisfied for actual: 13 FAIL
Example (MethodExpression) ¶
actual := time.Date(2026, time.April, 9, 17, 32, 42, 123, time.UTC) Satisfy(t, actual, time.Time.IsZero)
Output: predicate is not satisfied for actual: 2026-04-09 17:32:42.000000123 +0000 UTC FAIL
Example (MethodValue) ¶
actual := time.Date(2026, time.April, 9, 17, 32, 42, 123, time.UTC) Satisfy(t, actual, time.Now().Before)
Output: predicate is not satisfied for actual: 2026-04-09 17:32:42.000000123 +0000 UTC FAIL
func SatisfyWith ¶
SatisfyWith checks that predicate returns true for actual and expected.
Example (Function) ¶
SatisfyWith(t, 13, 42, cmp.Greater)
Output: predicate is not satisfied with actual: 13 expected: 42 FAIL
Example (Inline) ¶
SatisfyWith(t, 13, 42, func(x, y int) bool { return x > y })
Output: predicate is not satisfied with actual: 13 expected: 42 FAIL
Example (Method_expression) ¶
actual := time.Date(2026, time.April, 9, 17, 32, 42, 123, time.UTC)
expected := time.Date(2026, time.April, 9, 17, 32, 42, 123, time.FixedZone("My", 4*int(time.Hour.Seconds())))
SatisfyWith(t, actual, expected, time.Time.Before)
Output: predicate is not satisfied with actual: 2026-04-09 17:32:42.000000123 +0000 UTC expected: 2026-04-09 17:32:42.000000123 +0400 My FAIL
Types ¶
type TB ¶
TB is a subset of testing.TB that is sufficient for assertions.
Click to show internal directories.
Click to hide internal directories.