I am trying to do a unit test on some c++ code but am running into some trouble.
I have something similar to the following lines of code…
std::string s1 = obj->getName();
std::string s2 = "ExpectedName";
Assert::AreEqual(s1, s2, "Unexpected Object Name");
And I’m getting the following compiler error…
error C2665: 'Microsoft::VisualStudio::TestTools::UnitTesting::Assert::AreEqual' :
none of the 15 overloads could convert all the argument types
It seems like it should be a match with the following overload:
AreEqual<(Of <(T>)>)(T, T, String)
Isn’t the above overload a template overload that should support any object, as long as arguments 1 and 2 are of the same type? Or am I missing something?
Is there some other way that I can accomplish this Assert?
I hacked up a bit of a workaround so that integers are compared instead of strings:
In the future, we will likely switch to native C++ unit testing, but in the meantime, this does the trick. Obviously the messaging for this isn’t very helpful
But it’s better than nothing.