I am having trouble running a typed test for my struct.
So consider in my test.cpp
I have a template struct
template<typename T>
struct Something {
T value;
// Constructors
};
Now I declare typedefs
as mention in documentation.
using MyTypes =
testing::Types<char, unsigned char, short int, unsigned short int, int,
unsigned int, long int, unsigned long int, long long int,
unsigned long long int, float, double, long double>;
Then I create the test suite and the typed test for my struct.
TYPED_TEST_SUITE(Something,MyTypes);
TYPED_TEST(Something,arithmetics) {
Something<TypeParam> smth;
.....
}
But when I run this, I get compile error error: only virtual member functions can be marked 'override' TYPED_TEST(Something,arithmetics) {
What am I doing wrong???
You're not deriving Something
from testing::Test
.
It should look like this:
template<typename T>
class Something : public testing::Test {
public:
T value;
// ...
};
Then inside TYPED_TEST
you don't need to create an instance of this class, you already have it:
TYPED_TEST(Something, Arithmetics) {
EXPECT_EQ(this->value, 0);
}