#include <catch2/catch_all.hpp>
#include <catch2/trompeloeil.hpp>
class i
{
public:
virtual void abs() = 0;
};
class test : public i
{
MAKE_MOCK0(abs, void());
};
void
f()
{
test mock;
REQUIRE_CALL(mock, abs()).SIDE_EFFECT([] {
CHECK_FALSE(true);
}());
}
Fails to build with Catch2 v3.1.1 and g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, but works just fine with Clang.
After investigating preprocessor output of both, it was observed that GCC actually emits pragmas in incorrect place:
GCC output:
The possibility to immediately declare and invoke lambdas inside side_effect seems very convenient to me considering the situation when someone wants to performs complex checks agains mock' input.
Following code:
Fails to build with Catch2 v3.1.1 and g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, but works just fine with Clang.
After investigating preprocessor output of both, it was observed that GCC actually emits pragmas in incorrect place: GCC output:
Clang output:
The possibility to immediately declare and invoke lambdas inside side_effect seems very convenient to me considering the situation when someone wants to performs complex checks agains mock' input.