2023-07-05 11:14:37 +00:00
|
|
|
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
|
|
|
|
}
|
2023-07-05 11:37:11 +00:00
|
|
|
|
2023-07-10 09:36:17 +00:00
|
|
|
t.Errorf(formatTwoParameters, file(), "Equal", a, b)
|
2023-07-05 11:14:37 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-07-10 09:36:17 +00:00
|
|
|
t.Errorf(formatTwoParameters, file(), "NotEqual", a, b)
|
2023-07-05 11:14:37 +00:00
|
|
|
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
|
|
|
|
}
|
2023-07-05 11:37:11 +00:00
|
|
|
|
2023-07-10 09:36:17 +00:00
|
|
|
t.Errorf(formatTwoParameters, file(), "DeepEqual", a, b)
|
2023-07-05 11:14:37 +00:00
|
|
|
t.FailNow()
|
|
|
|
}
|