Assert :: AreEqual定义system :: clock

时间:2015-12-09 21:02:06

标签: c++ unit-testing visual-studio-2013 microsoft-cpp-unit-test

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

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)部分。 我该怎么做呢?

0 个答案:

没有答案