Open MikeWeller opened 2 years ago
Note: I would be interested in working on this myself assuming there is agreement on this being useful.
I would like this, too. Any idea if this is being worked on?
I have a fix for this that I am using. It Is not exactly as in the issue. It involves changing this:
INSTANTIATE_TEST_CASE_P(
Parameterized,
MyTest,
testing::Combine(
testing::Bool(),
testing::Values(123, 456),
testing::Values("foo", "bar")));
to this
INSTANTIATE_TEST_SUITE_P(
Parameterized,
MyTest,
testing::ConvertGenerator<MyTestParameters::GTestTuple>(
testing::Combine(
testing::Bool(),
testing::Values(123, 456),
testing::Values("foo", "bar"))));
@MikeWeller @asoffer Is that an acceptable solution? Should I open a PR with this?
@BMBurstein this looks great, though I think the testing::ConvertGenerator<MyTestParameters::GTestTuple>
in your example should instead just be testing::ConvertGenerator<MyTestParameters>(
which should match the tuple constructor during conversion.
@BMBurstein this looks great, though I think the
testing::ConvertGenerator<MyTestParameters::GTestTuple>
in your example should instead just betesting::ConvertGenerator<MyTestParameters>(
which should match the tuple constructor during conversion.
Ideally, I would have liked it to work that way, too. The problem is that the ConvertGenerator needs to know the intermediate type through which to do the conversion. The whole reason it is needed in the first place is so that it can do a "double conversion", converting the wrapped generator into the template type, and then converting that type into the final type.
This was merged in #3967
This was merged in #3967
Awesome!
Does the feature exist in the most recent commit?
No
Why do we need this feature?
More strongly typed parameterized test types, and improved/customizable output of those parameters
Describe the proposal
I would like the ability to pass a custom (non-
std::tuple
) type toWithParamInterface
/TestWithParam
while using thetesting::Combine
generator to generate constructor arguments for this type. Google Test would construct the type with thestd::tuple<TYPES...>
that is currently produced (orTYPES...
directly), and the type ofGetParam()
would be of the custom type.The following code demonstrates what I mean:
https://godbolt.org/z/Wr36Eqc8z
Note: I'm using
WithParamInterface
above since our use case is that we have our own base class that inherits fromtesting::Test
so need to add theWithParamInterface
separately. However this feature request applies equally to usingTestWithParam
.Is the feature specific to an operating system, compiler, or build system version?
No