【发布时间】:2020-12-22 20:20:27
【问题描述】:
有没有办法将 Visual Studio 原生 C++ 单元测试框架配置为使用 std::string 而不是 std::wstrings ?
Assert::Equal<class T>(const T & t1,const T &t2)
需要函数
template<class T> std::wstring ToSring<class T>(const T & t) /* note the wstring here */
由测试编写者为要测试的对象(类型 T)编写/专门化。我已经有了这个功能:
ostream & operator<<(ostream & o, const T & t) /* note the ostream vs wostream */
我想重新使用(建立第三方窄字符串库),但我没有 wostream 等效项,也不想重写。
我有什么选择?
【问题讨论】:
-
我使用宏来根据需要将消息从
string转换为wstring...然后只需使用Assert::Fail而不是Assert::AreEqual -
如果没有其他解决方案,我肯定会去,我认为值得回答......
标签: c++ unit-testing visual-studio-2019 vs-unit-testing-framework