Je continue à recevoir ces erreurs lors de l'exécution make:Est-ce que GoogleMock me fait implémenter un destructeur dans une classe fictive?
debug/main.o: In function `MockMQAdapter<SomeClass>::MockMQAdapter()':
/source/Tests/testsfoo/MockMQAdapter.h:30: undefined reference to `MQAdapter<SomeClass>::~MQAdapter()'
debug/main.o:(.rodata._ZTVN2TW9MQAdapterI6ThingyEE[_ZTVN2TW9MQAdapterI6ThingyEE]+0x10): undefined reference to MQAdapter<SomeClass>::~MQAdapter()'
debug/main.o:(.rodata._ZTVN2TW9MQAdapterI6ThingyEE[_ZTVN2TW9MQAdapterI6ThingyEE]+0x18): undefined reference to `MQAdapter<SomeClass>::~MQAdapter()'
debug/main.o:(.rodata._ZTVN2TW9MQAdapterI6ThingyEE[_ZTVN2TW9MQAdapterI6ThingyEE]+0x20): undefined reference to `MQAdapter<SomeClass>::publish(std::string const&, std::string &message)'
Voici mon code:
#include <gmock/gmock.h>
template<typename S>
class MQAdapter {
public:
MQAdapter(const std::string host, uint16_t port);
virtual ~MQAdapter();
virtual void publish(const std::string queue, std::string message);
};
MQAdapter::MQAdapter(const std::string host, uint16_t port) {}
//Generated by gmock_gen.py
template <typename T0>
class MockMQAdapter : public MQAdapter<T0> {
public:
MOCK_METHOD2_T(publish,
void(std::string, std::string));
};
J'ai suivi les guides simulacres google assez près. Je ne comprends pas ce que ces erreurs signifient. Voici ce que mon test ressemble à:
TEST(MyTest, ExpectCall) {
MockMQAdapter<SomeClass> *adapter = new MockMQAdapter<SomeClass>("host", 1);
EXPECT_CALL(*adapter, publish("hi", "hello"));
adapter->publish("hi", "hello");
}
Les premiers et deuxièmes extraits de code dans différentes unités de traduction (fichiers C++)? – Csq
Pourquoi n'avez-vous pas défini '~ MQAdapter()'? –