The problem is that you are doing a AreEqual
. Passing in two parameters will force AreEqual(Object^, Object^)
which:
Verifies that two specified objects are equal. The assertion fails if the objects are not equal.
What you are actually looking for is the comparison of a wchar*
and a char*
. There is not a direct comparison function between the two so it will be necessary to convert from a string
to a wstring
. There are lots of examples of how to do that, such as: https://stackoverflow.com/a/7159944/2642059 and you'll need to do something similar, for example:
wstring get_wstring(const string& s) {
wstring buf;
const char* cs = s.c_str();
const size_t wn = mbsrtowcs(nullptr, &cs, 0, nullptr);
if (wn == string::npos) {
cout << "Error in mbsrtowcs(): " << errno << endl;
} else {
buf.resize(wn + 1);
if(mbsrtowcs(&*buf.begin(), &cs, wn + 1, nullptr) == string::npos) {
cout << "Error in mbsrtowcs(): " << errno << endl;
buf.resize(0);
}
}
return buf;
}
The return of get_wstring(expected)
and actual
will now both be wchar
s and can thereby be compared in the using AreEqual(String^, String^, bool)