0

I use the Microsoft Unit Testing for C++, but when I use Assert::AreEqual comparing string and the string contains Chinese words. The Test Explorer display unrecognizable characters.

using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace tests
{
 using std::string,std::wstring;
 TEST_CLASS(Test)
 {
 public:
 TEST_METHOD(test)
 {
 Assert::AreEqual("测试", "测试1");
 }
 };
}

unrecognizable characters

If I should use converter to change the string or char* to wstring or wcahr_t*?

using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace tests
{
 using std::string,std::wstring;
 TEST_CLASS(Test)
 {
 public:
 TEST_METHOD(test)
 {
 Assert::AreEqual(L"测试", L"测试1");
 }
 };
}

recognizable characters

Thanks in advance.

asked Mar 21, 2024 at 2:20

1 Answer 1

0

It fails to display the correct character set but does not affect the results.

For displaying Chinese, you need to use wide characters.

answered Mar 21, 2024 at 3:40
Sign up to request clarification or add additional context in comments.

2 Comments

That said, normally I don't need to change my original working code, and if I want to display it properly in my tests, is it better to convert to wide characters or wait for Microsoft to improve this detail someday?
You can submit a report to Visual Studio Developer Community. But currently it is better to use wide characters.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.