refactor: Simplify t.Fatalf (#984)

This commit is contained in:
Oleksandr Redko
2025-05-10 22:14:34 +03:00
committed by GitHub
parent ee07c9203b
commit 85e2448ce5
+2 -2
View File
@@ -79,7 +79,7 @@ func Zero[T any](t testing.TB, value T, msgAndArgs ...any) {
} }
t.Helper() t.Helper()
msg := formatMsgAndArgs("Expected zero value but got:", msgAndArgs...) msg := formatMsgAndArgs("Expected zero value but got:", msgAndArgs...)
t.Fatalf("%s\n%s", msg, fmt.Sprintf("%v", value)) t.Fatalf("%s\n%v", msg, value)
} }
func NotZero[T any](t testing.TB, value T, msgAndArgs ...any) { func NotZero[T any](t testing.TB, value T, msgAndArgs ...any) {
@@ -92,7 +92,7 @@ func NotZero[T any](t testing.TB, value T, msgAndArgs ...any) {
} }
t.Helper() t.Helper()
msg := formatMsgAndArgs("Unexpected zero value:", msgAndArgs...) msg := formatMsgAndArgs("Unexpected zero value:", msgAndArgs...)
t.Fatalf("%s\n%s", msg, fmt.Sprintf("%v", value)) t.Fatalf("%s\n%v", msg, value)
} }
func formatMsgAndArgs(msg string, args ...any) string { func formatMsgAndArgs(msg string, args ...any) string {