Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation unit contamination #264

Open
jordfras opened this issue Dec 4, 2020 · 0 comments
Open

Compilation unit contamination #264

jordfras opened this issue Dec 4, 2020 · 0 comments

Comments

@jordfras
Copy link

jordfras commented Dec 4, 2020

Is it possible to have two different custom generators for one type in two different compilation units?

I have two different tests in two different compilation units that both need to generate objects of the same custom class, but they need to generate them very differently. Is this possible?

For instance

class Vector
{
public:
  Vector(int offset, int length);
};

namespace rc {
template<>
struct Arbitrary<Vector>
{
  static Gen<Vector> arbitrary()
  {
    return gen::construct<Vector>(gen::arbitrary<int>(), gen::positive<int>());
  }
};
}

Let's say I need another generator in another test that generates Vectors with only positive offset. I cannot put the generator in an anonymous namespace and thus there will be leakage between compilation units.

Is there an established way to work around this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant