Reputation: 1917
Note: I know this question was asked in different ways, but I couldn't solve it based on my restrictions:
1.7
I am writing google test for a library I have created.
In my library, I have 3 structs, as follows:
struct utc_clock{ .... }
struct system_clock {....}
struct cpu_clock {....}
moreover, I have another class that uses them as template parameters.
In my test case, I do as follows:
TEST(MyTest, testImportantThings)
{
time_point<utc_clock> tp = utc_clock::now();
ASSERT_EQ(..things with tp... );
... more ASSERTION
}
What I am trying to do, is to run
TEST(MyTest, testImportantThings)
multiple times for each of the utc_clock
, system_clock
, cpu_clock
I have looked into How to get gtest TYPED_TEST parameter type,
after that, I got the following:
template<typename T>
struct MyTest: public testing::Test{
using MyParamType = T;
};
using MyTypes = testing::TYpes<utc_clock, system_clock, cpu_clock>;
TYPED_TEST_CASE(MyTest, MyTypes);
TYPED_TEST(MyTest, testImportantStuff)
{
using clock = typename TestFixture::MyParamType;
timepoint<clock> tp = clock::now();
ASSERT_EQ(..things with tp... );
... more ASSERTION
}
But I get the following errors:
unexpected token(s) preceding ';' on:
using MyParamType = T;
testing::internal::TYpeList use of class template requires template arguement list online on:
using MyTypes = testing::TYpes<utc_clock, system_clock, cpu_clock>;
and more...
Upvotes: 0
Views: 490
Reputation: 4673
It is possible that your compiler is too old to support defining type aliases with using
. What if you replace those with old-style typedef statements?
For example, you could replace
using MyParamType = T;
With the equivalent:
typedef T MyParamType;
Upvotes: 1