googletest icon indicating copy to clipboard operation
googletest copied to clipboard

[FR]: Document that parameters used in parametrized tests must implement operator<<

Open carlosgalvezp opened this issue 2 years ago • 0 comments
trafficstars

Does the feature exist in the most recent commit?

No

Why do we need this feature?

To clarify the usage of parametrized tests and avoid Valgrind warnings.

Describe the proposal.

When using a custom struct as a parameter in a parametrized test, GoogleTest will always print its bytes as default (regardless of whether the test succeeds or fails). This can lead to Valgrind warnings if the struct has padding bytes (which are uninitialized).

According to this comment, the user must ensure the struct is correctly printable. This is not stated in the documentation, and seems important enough to mention it (accessing uninitialized data is Undefined Behavior).

Thus I'm opening this ticket to request adding this information to the documentation.

Is the feature specific to an operating system, compiler, or build system version?

No.

carlosgalvezp avatar Apr 12 '23 08:04 carlosgalvezp