Test that functions return expected errors:
func TestDivideByZero(t *testing.T) {
_, err := divide(10, 0)
if err == nil {
t.Error("expected error for division by zero")
}
}
Check both that errors occur when expected and don't occur in normal cases. Use errors.Is to check for specific errors.