Improved code quality

This commit is contained in:
2023-08-31 17:03:52 +02:00
parent a7e65ca27f
commit 95976e39bf
16 changed files with 128 additions and 69 deletions

View File

@ -2,35 +2,34 @@ package assert
import (
"reflect"
"testing"
)
// Equal asserts that the two parameters are equal.
func Equal[T comparable](t testing.TB, a T, b T) {
func Equal[T comparable](t test, a T, b T) {
if a == b {
return
}
t.Errorf(formatTwoParameters, file(), "Equal", a, b)
t.Errorf(twoParameters, file(), "Equal", a, b)
t.FailNow()
}
// NotEqual asserts that the two parameters are not equal.
func NotEqual[T comparable](t testing.TB, a T, b T) {
func NotEqual[T comparable](t test, a T, b T) {
if a != b {
return
}
t.Errorf(formatTwoParameters, file(), "NotEqual", a, b)
t.Errorf(twoParameters, file(), "NotEqual", a, b)
t.FailNow()
}
// DeepEqual asserts that the two parameters are deeply equal.
func DeepEqual[T any](t testing.TB, a T, b T) {
func DeepEqual[T any](t test, a T, b T) {
if reflect.DeepEqual(a, b) {
return
}
t.Errorf(formatTwoParameters, file(), "DeepEqual", a, b)
t.Errorf(twoParameters, file(), "DeepEqual", a, b)
t.FailNow()
}