catchorg / catchorg/Catch2

Creation generator inside function call is broken

Open
#1,997 2 comments 0 reactions 0 assignees View on GitHub
Query
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

I have many tests and I made much common code with generators. They make my tests more clearly and shorter.
But after #1913 my code is broken.

I have alike code:
```
int makeGenerator(int x) { return GENERATOR(x, x+1, x+2); }

void test()
{
int a = makeGenerator(10);
int b = makeGenerator(5);
CHECK(a > b);
}
```
It worked fine before #1913.
After this change **b** have taken wrong values.
As I understand, because new code thinks that is the same generator.

Of course in this situation I can replace function **makeGenerator()** by macros.
But I have more complex functions with checkings, filtering and returning different generators in dependent of parameters.
And its replacing with macroses creates "not good" code.

Was the code so bad before #1913?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.