googletest
googletest copied to clipboard
[FR]: `EXPECT_NONFATAL_FAILURE` and friends: Support multiple (variadic) substrings
I would like to be able to pass multiple substrings to EXPECT_NONFATAL_FAILURE so that all the substrings must appear in the failure output.
This should I guess also apply to the other EXPECT_(FATAL|NONFATAL)_FAILURE[_ON_ALL_THREADS].
Does the feature exist in the most recent commit?
No
Why do we need this feature?
When testing matchers that produce detailed output (e.g. multi-line, or printing details from inner/nested matchers), it's brittle and cumbersome to test either one big string (where the test now depends on unimportant indentation/formatting), or have to repeat the entire EXPECT_NONFATAL_FAILURE multiple times to verify multiple substrings.
Describe the proposal.
For my use case, I want to be able to do something like:
EXPECT_NONFATAL_FAILURE(
[&] {
EXPECT_THAT(myObject, MyMatcher(...));
}(),
"Substring 1",
"Substring 2");
I haven't looked at whether this can be done in a backward compatible way using __VA_ARGS__/__VA_OPT__/etc.
Is the feature specific to an operating system, compiler, or build system version?
No.