Is there a way to configure Visual Studio native C++ unit testing framework to work with std::string instead of std::wstrings ?
Assert::Equal<class T>(const T & t1,const T &t2)
requires the function
template<class T> std::wstring ToSring<class T>(const T & t) /* note the wstring here */
to be written/specialized by the test writer for the object to be tested (of type T). I already have this function:
ostream & operator<<(ostream & o, const T & t) /* note the ostream vs wostream */
I would like to re-use (build uppon a third party narrow strings library), but I don't have the wostream equivalent, and don't want to rewrite one.
What are my options ?
If your class did have the
wostreammethod then your specialization forToStringcould simply use the provided macroRETURN_WIDE_STRING:But without changing the code under test, you could write a similar macro (or function) to convert the
ostreamto awstringand use it in the same way:The new macro might look something like:
You can also avoid the whole
ToStringspecialization problem by usingAssertvariants that don't require it:This is likely to be as much or more work though, depending how much detail you want in the fail messages.