GoogleTest Framework doesn't seem to work with lambda functions (continued)
This is my last question:
Google Test macros don't seem to work with Lambda functions
The solution mentioned in this case worked in this particular case, namely, the constructor of the template class inside the lambda can be wrapped in parentheses and the assembly will succeed. And I accepted this answer. But the question still remains that the GoogleTest Framework doesn't seem to work with Lambda functions. I don't see anything in the documentation.
I did the following test:
TEST(errorhandlingInterpolator, NOTtoolargeInput) {
ASSERT_NO_THROW(throw);
}
which will cause the test to fail. Good.
Then I did this,
TEST(errorhandlingInterpolator, NOTtoolargeInput) {
ASSERT_NO_THROW([](){throw;});
}
which will cause the NOT test to fail. It's strange.
So finally, to be careful (something so trivial), I tested the following bit.
void dummy() { throw; }
TEST(errorhandlingInterpolator, NOTtoolargeInput) {
ASSERT_NO_THROW(throw);
}
and the exception caused the test to fail. Things are good.
Which raised the flag in my head, make exceptions even when working with lambda functions. I thought they were just like regular functions, apart from anonymous ones. Apparently they do it. This is indicated by the following two questions.
Can C ++ lambda-expression throw?
throw an exception from a lambda expression, a bad habit?
So it looks like it boils down to the fact that macros in the Google Analytics framework DO NOT work with lambda functions.
source to share