googletest
googletest copied to clipboard
[FR]: Make `Combine` generating custom types (CombineTo)
trafficstars
Does the feature exist in the most recent commit?
I did not find that functionality.
Why do we need this feature?
It would be more handy to write:
struct MyStruct {
int a;
std::string b;
};
ParamGenerator<MyStruct> gen = CombineTo<MyStruct>(Values(1, 2, 3), Values("a", "b", "c"));
Than:
struct MyStruct {
int a;
std::string b;
using TupleT = std::tuple<int, std::string>;
MyStruct(const TupleT& t): a(std::get<0>(t)), b(std::get<1>(t)) {}
};
ParamGenerator<MyStruct> gen = ConvertGenerator<MyStruct::TupleT>(Combine(Values(1, 2, 3), Values("a", "b", "c")));
Describe the proposal.
Actually I have already developed it. https://github.com/google/googletest/pull/4727
In two words: I have introduced a new function CombineTo and refactored CartesianProductGenerator to support custom types instantiation.
Maybe it is better to rename to CombineAs.
Is the feature specific to an operating system, compiler, or build system version?
No