36 lines
641 B
Go
Raw Normal View History

2023-07-05 11:14:37 +00:00
package assert
import (
"reflect"
)
// Equal asserts that the two parameters are equal.
2023-08-31 15:03:52 +00:00
func Equal[T comparable](t test, a T, b T) {
2023-07-05 11:14:37 +00:00
if a == b {
return
}
2023-07-05 11:37:11 +00:00
2023-08-31 15:03:52 +00:00
t.Errorf(twoParameters, file(), "Equal", a, b)
2023-07-05 11:14:37 +00:00
t.FailNow()
}
// NotEqual asserts that the two parameters are not equal.
2023-08-31 15:03:52 +00:00
func NotEqual[T comparable](t test, a T, b T) {
2023-07-05 11:14:37 +00:00
if a != b {
return
}
2023-08-31 15:03:52 +00:00
t.Errorf(twoParameters, file(), "NotEqual", a, b)
2023-07-05 11:14:37 +00:00
t.FailNow()
}
// DeepEqual asserts that the two parameters are deeply equal.
2023-08-31 15:03:52 +00:00
func DeepEqual[T any](t test, 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-08-31 15:03:52 +00:00
t.Errorf(twoParameters, file(), "DeepEqual", a, b)
2023-07-05 11:14:37 +00:00
t.FailNow()
}