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.
|
2023-07-18 12:35:29 +00:00
|
|
|
func DeepEqual[T any](t testing.TB, a T, b T) {
|
2023-07-05 11:14:37 +00:00
|
|
|
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()
|
|
|
|
}
|