I would like to be able to parameterize my tests for various types through the following code snippet:
template <typename T>
class MyTestSuite : public testing::TestWithParam<tuple<T, vector<vector<T>>, T, T>>
{
public:
MyTestSuite()
{
_var = get<0>(GetParam());
// and the rest of the test params
}
protected:
T _var;
};
TYPED_TEST_SUITE_P(MyTestSuite);
TYPED_TEST_P(MyTestSuite, MyTests)
{
ASSERT_EQ(this->_expected, this->DoSomething(this->_var));
}
REGISTER_TYPED_TEST_SUITE_P(MyTestSuite,
MyTests);
using MyTypes = ::testing::Types<size_t>;
INSTANTIATE_TYPED_TEST_SUITE_P(
MyGroup,
MyTestSuite,
::testing::Combine(
::testing::Values(4, vector<vector<size_t>>{{1, 2}, {1, 3}, {3, 4}}, 1, 1),
::testing::Values(10, vector<vector<size_t>>{{1, 2}, {1, 3}, {3, 4}}, 1, 2),
::testing::Values(20, vector<vector<size_t>>{{1, 2}, {1, 3}, {3, 4}}, 1, 4)));
and bump into the following compilation error:
error: there are no arguments to ‘GetParam’ that depend on a template parameter, so a declaration of ‘GetParam’ must be available [-fpermissive]
[build] 284 | _var = get<0>(GetParam());
This post has been quite some time: Google Test: Is there a way to combine a test which is both type parameterized and value parameterized? Is it still not possible to kill these 2 birds with one stone, judging from the compilation error above?
error: use of undeclared identifier 'testing'
. Plus other 20 errors. – Moye