48 lines
786 B
Go

package assert
import (
"reflect"
"testing"
)
// Equal asserts that the two parameters are equal.
func Equal[T comparable](t testing.TB, a T, b T) {
if a == b {
return
}
t.Errorf(`Equal:
file: %s
assert: Equal
value: %v
expected: %v`, file(t), a, b)
t.FailNow()
}
// NotEqual asserts that the two parameters are not equal.
func NotEqual[T comparable](t testing.TB, a T, b T) {
if a != b {
return
}
t.Errorf(`NotEqual:
file: %s
assert: NotEqual
value: %v`, file(t), a)
t.FailNow()
}
// DeepEqual asserts that the two parameters are deeply equal.
func DeepEqual[T comparable](t testing.TB, a T, b T) {
if reflect.DeepEqual(a, b) {
return
}
t.Errorf(`
file: %s
assert: DeepEqual
value: %v
expected: %v`, file(t), a, b)
t.FailNow()
}