google / google/googletest

[FR]: Make `Combine` generating custom types (CombineTo)

Open
#4,728 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### 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:
```c++
struct MyStruct {
int a;
std::string b;
};

ParamGenerator gen = CombineTo(Values(1, 2, 3), Values("a", "b", "c"));
```
Than:
```c++
struct MyStruct {
int a;
std::string b;

using TupleT = std::tuple;

MyStruct(const TupleT& t): a(std::get<0>(t)), b(std::get<1>(t)) {}
};

ParamGenerator gen = ConvertGenerator(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

Contributor guide

Open the contributing guide

Research direction

Start by reviewing pull request #4727, which the issue identifies as the existing implementation. Read the proposal for CombineTo and the requested CartesianProductGenerator refactor, including the possible CombineAs rename. Done means the feature and naming decision are resolved in the linked pull request.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.