0

我的单元测试中有这段代码:

Assert::AreEqual(std::chrono::system_clock::now(), ntp.testntp);

我得到这个错误:

Error   1   error C2338: Test writer must define specialization of ToString<const >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<class >std::chrono::time_point<struct std::chrono::system_clock,class >std::chrono::duration<__int64,struct std::ratio<1,10000000> > >>(const class >std::chrono::time_point<struct std::chrono::system_clock,class >std::chrono::duration<__int64,struct std::ratio<1,10000000> > > &). 

我的理解是,您必须按照以下方式做一些事情:

template<> static std::wstring ToString<system_clock>(const system_clock& t) { RETURN_WIDE_STRING(t); }

编译器不喜欢这个RETURN_WIDE_STRING(t)部分。我该如何正确地做到这一点?

4

0 回答 0