当我尝试在 Visual Studio 2013 中编译单元测试时收到以下错误:
Error 1 error C2338: Test writer must define specialization of ToString<Q* q> for your class class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl Microsoft::VisualStudio::CppUnitTestFramework::ToString<struct HINSTANCE__>(struct HINSTANCE__ *).
您可以通过如下测试方法重现错误:
const std::wstring moduleName = L"kernel32.dll";
const HMODULE expected = GetModuleHandle(moduleName.c_str());
Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(expected, expected);
有谁知道我需要如何编写这样一个 ToString
的特化?
最佳答案
我在比较类对象时遇到了同样的问题。 对我来说,我可以通过简单地写来解决它
Assert::IsTrue(bitmap1 == bitmap2);
代替
Assert::AreEqual(bitmap1, bitmap2);
关于c++ - Microsoft Visual Studio 单元测试的 C2338 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28739852/