Skip to content

Conversation

@hovinen
Copy link
Contributor

@hovinen hovinen commented Aug 4, 2023

A test which only uses the expect_* family of assertions (thus requiring #[googletest::test]) will only ever return Ok(()). There is therefore no reason to require the function itself to return a Result. That requirement just creates unnecessary boilerplate.

This change modifies the #[googletest::test] implementation to remove the requirement that the return type be present. If it is present, then it must still be a Result.

The generated compiler error can no longer occur and is removed. It would be ideal to check whether the given return type is in fact a Result and return a compiler error if it is not, but that is beyond the scope of this change.

A test which only uses the `expect_*` family of assertions (thus requiring `#[googletest::test]`) will only ever return `Ok(())`. There is therefore no reason to require the function itself to return a `Result`. That requirement just creates unnecessary boilerplate.

This change modifies the `#[googletest::test]` implementation to remove the requirement that the return type be present. If it is present, then it must still be a `Result`.

The generated compiler error can no longer occur and is removed. It would be ideal to check whether the given return type is in fact a `Result` and return a compiler error if it is not, but that is beyond the scope of this change.
@copybara-service copybara-service bot merged commit ba77526 into main Aug 4, 2023
@gribozavr gribozavr deleted the support-googletest-test-returning-unit branch February 17, 2025 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants