Skip to content

Generator::currentElementAsString breaks compilation of a lot of our tests #2453

@stefanhaller

Description

@stefanhaller

In 48f3226, a new method currentElementAsString was added to generators. As far as I can tell, it isn't used for anything.

The problem is that this breaks compilation of a lot of our tests, with no obvious workaround. The reason is that we define CATCH_CONFIG_FALLBACK_STRINGIFIER to a non-existing symbol in order to catch mistakes where failing CHECKs wouldn't stringify correctly. This is very useful, and actually I think it should be the default.

But this now causes compilation failures for GENERATE statements where the type that's generated isn't stringifiable.

To illustrate, here's a common pattern that we tend to use a lot in our tests:

using T = std::tuple<InputType1, InputType2, SomeHelper, ExpectedOutput1, ExpectedOutput2>;
const auto [input1, input2, helper, expectedOutput1, expectedOutput2] = GENERATE(values<T>({
  { ... },
}));

CAPTURE(input1, input2);

// ...

In this example, InputType1 and InputType2 are stringifiable, and have to be because of the CAPTURE. SomeHelper might, for example, be a std::function. ExpectedOutput1 and ExpectedOutput2 only need to be stringifiable if they appear in a CHECK statement, which they often do, but don't necessarily have to.

I'd appreciate advice how to work around this. I suppose I could subclass FixedValuesGenerator with an overwritten stringifyImpl method (which would only assert(false)?), but this seems like a lot of work.

For now we revert 48f3226 locally, but this is not a satisfactory long-term solution either, of course.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions