I wrote a DLL with inline
implementations. I'm pretty new to Unit Tests in C++, so I added some as described here and they just worked perfectly fine. Assertions were reacting correctly etc.
After extracting the methods in their .cpp
for reasons, I learned that the class has to be exported (LNK2019, LNK2001). Or at least the methods which should be able to be tested. But exporting methods expecting fe. std::string
or STL containers as an argument, or even members of another class causes trouble with C4251, what I wanted to avoid with #4 from here (TL;DR export everything else as well - does not work: C2242).
It's possible to ignore the C4251 but then the tests are failing with an C000005 exception and the following stack trace:
Error Message: Exception Code: C0000005 Stack Trace:
at std::allocator<char>::deallocate() in c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0:line 573
at std::_Wrap_alloc<std::allocator<char> >::deallocate() in c:\program files (x86)\microsoft visual studio
12.0\vc\include\xmemory0:line 859
at std::basic_string<char,std::char_traits<char>,std::allocator<char>
::_Tidy() in c:\program files (x86)\microsoft visual studio 12.0\vc\include\xstring:line 2284
at std::basic_string<char,std::char_traits<char>,std::allocator<char>
::~basic_string<char,std::char_traits<char>,std::allocator<char> >() in c:\program files (x86)\microsoft visual studio
12.0\vc\include\xstring:line 992
But that evolved already in directions where I never wanted to go. Is there any solution for my issue? Like test project config or sth.? Do I have to change the test framework?