|
Boost Testing : |
Subject: Re: [Boost-testing] BOOST_CHECK_EQUAL on user-defined type
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2011-11-13 12:17:42
JarosÅaw Bober <jaroslaw.bober <at> gmail.com> writes:
> 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
What you can do is to implement custom comparator which returns
predicate_result. Something like this:
bool compare(MyClass const& expected, MyClass const& received)
{
if(expected.a != received.a) {
predicate_result res( false );
res.message() << "Difference in field a: " << expected.a << ", "
received.a;
}
if(expected.b != received.b) {
predicate_result res( false );
res.message() << "Difference in field b: " << expected.b << ", "
received.b;
}
return true;
}
Gennadiy