Hope this question will not be too stupid. I'm quite new in using gtest and it's been quite a very long time that I don't make use of C++.
Let suppose w have this simplistic template Point
class:
template <class T>
struct Point
{
union
{
T _data [2];
struct { T x, y; };
};
constexpr Point(T x_, T y_) noexcept : x(x_), y(x_) {}
};
Then using gtest, I'm trying to check if Point
is default constructible:
TEST_P(PointTest,Concept)
{
ASSERT_TRUE(std::is_nothrow_constructible<Point<float>,float,float>::value);
}
Then I get this compilation error with Clang 6.0.1 with C++11 flags:
"error: too many arguments provided to function-like macro invocation"
Any help will be welcome. I do know that special care must be taken when combining templates and googletest. But I didn't figure out a solution. Thank you !
I suppose it's a problem with C++ preprocessor that recognize the commas between templates arguments
// ...................................................v.....v
ASSERT_TRUE(std::is_nothrow_constructible<Point<float>,float,float>::value);
as macros arguments separators.
I suggest to calculate the value outside the macro call
TEST_P(PointTest,Concept)
{
constexpr auto val
= std::is_nothrow_constructible<Point<float>, float, float>::value;
ASSERT_TRUE( val );
}
or to pass through a using
for the type
TEST_P(PointTest ,Concept)
{
using inc = std::is_nothrow_constructible<Point<float>, float, float>;
ASSERT_TRUE( inc::value );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With