Но, мой код имеет два параметра шаблона, как я могу его протестировать?
Код: Выделить всё
// two element type
template
class QueueNew
{
public:
QueueNew() {}
void Enqueue(const E& element) {}
E* Dequeue() {}
F size() const
{
return (F)123;
}
};
< /code>
, для которого я написал тестовый код ниже: < /p>
template
QueueNew* CreateQueue();
template
QueueNew* CreateQueue()
{
return new QueueNew < int, int > ;
}
template
QueueNew* CreateQueue()
{
return new QueueNew < char, char > ;
}
template
class QueueTestNew;
template
class QueueTestNew : public testing::Test
{
protected:
QueueTestNew() : queue(CreateQueue()){}
virtual ~QueueTestNew(){ delete queue; }
QueueNew* const queue;
};
template
class QueueTestNew : public testing::Test
{
protected:
QueueTestNew() : queue(CreateQueue()){}
virtual ~QueueTestNew(){ delete queue; }
QueueNew* const queue;
};
// The list of types we want to test.
typedef ::testing::Types Implementations;
TYPED_TEST_CASE(QueueTestNew, Implementations);
TYPED_TEST(QueueTestNew, DefaultConstructor)
{
EXPECT_EQ(123u, this->queue->size());
}
< /code>
Но при создании я получаю ошибку: < /p>
error C2976: 'QueueTestNew' : too few template arguments
see declaration of 'QueueTestNew'
...
Подробнее здесь: https://stackoverflow.com/questions/293 ... sing-gtest
Мобильная версия