Hello,
This is my first post on this list. I'm working with boost test for some time now and I find it very nice to work with.
I'm making tests for a legacy code and so I would like to have macro that compares some huge objects.
I'm looking for some information on the subject, but i couldn't find good example in docs nor in mailing list.
I would like to have good diagnostic information in console when comparing type that I defined.
Here's my example:
class MyClass
{
public:
int a;
int b;
};
bool operator==(MyClass expected, MyClass received)
{
return (expected.a == received.a) && (expected.b == received.b);
}
std::ostream& operator<<(std::ostream& str,MyClass const& myClass)
{
str << "MyClass::a: " << myClass.a << " MyClass::b: " << myClass.b ;
return str;
}
Now I have a test case:
BOOST_AUTO_TEST_CASE( test )
{
MyClass expected,received ;
expected.a = expected.b = received.a = 1;
received.b = 2;
BOOST_CHECK_EQUAL( expected, received );
}
it gives me these results:
test.cpp(72): error in "test": check expected == received failed [MyClass::a: 1
MyClass::b: 1 != MyClass::a: 1 MyClass::b: 2]
And I have a question. Is there possibility that in results i'll see only those members that failed assertion?
like
[expected.b: 1 != received.b: 2]
without having to manually search for failed member?
Regards