I have a class called skiplist which has 3 public virtual methods and which are defined in the .cpp file.
I have a test class called TestSkipList which is used for gmock test. And I am trying to test the real class object instead of a mock object.
But this is giving me linking error saying that Insert methods definition is not found, Please suggest me what might be the problem.
class SkipList {
public:
virtual bool Insert(int key, T value);
virtual bool Remove(int key);
virtual bool Lookup(int key);
virtual ~SkipList() {
}
}
class TestSkipList : public ::testing::Test {
protected:
TestSkipList() {}
virtual ~TestSkipList() {}
virtual void SetUp() {
S = SkipList<string>();
}
virtual void TearDown() {
}
SkipList <string>S;
};
TEST_F(TestSkipList, Insertion) {
EXPECT_EQ(1,S.Insert(2,"nkh"));
}
int main(int argc, char** argv) {
// The following line must be executed to initialize Google Mock
// (and Google Test) before running the tests.
::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
CMakeFiles/test_skiplist.dir/test_skiplist.cpp.o: In function `TestSkipList_Insertion_Test::TestBody()':
/.../test/test_skiplist.cpp:29: undefined reference to `SkipList<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Insert(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
CMakeFiles/test_skiplist.dir/test_skiplist.cpp.o:(.rodata._ZTV8SkipListINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE[_ZTV8SkipListINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE]+0x10): undefined reference to `SkipList<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Insert(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
CMakeFiles/test_skiplist.dir/test_skiplist.cpp.o:(.rodata._ZTV8SkipListINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE[_ZTV8SkipListINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE]+0x18): undefined reference to `SkipList<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Remove(int)'
CMakeFiles/test_skiplist.dir/test_skiplist.cpp.o:(.rodata._ZTV8SkipListINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE[_ZTV8SkipListINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE]+0x20): undefined reference to `SkipList<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Lookup(int)'
collect2: error: ld returned 1 exit status
}