Boost logo

Boost Testing :

Subject: Re: [Boost-testing] BOOST_CHECK_EQUAL on user-defined type
From: Jaros³aw Bober (jaroslaw.bober_at_[hidden])
Date: 2011-11-14 05:13:03


Yes, I was looking at these examples all the time:
http://www.boost.org/doc/libs/1_45_0/libs/test/doc/html/utf/testing-tools/custom-predicate.html
but i couldn't actually find that there is a solution to my problem and
your suggestion gave me direction.
Complete solution looks like this:

using namespace boost::test_tools;
predicate_result
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;
    return res;
   }

   if(expected.b != received.b) {
        predicate_result res( false );
        res.message() << "Difference in field b: " << expected.b << ", " <<
received.b;
    return res;
   }

   return true;
}

Thanks

2011/11/14 Gennadiy Rozental <rogeeff_at_[hidden]>

> Jaros³aw Bober <jaroslaw.bober <at> gmail.com> writes:
>
> >
> >
> > Thank you Gennadiy, now it works like it should :)Regards
>
> Actually in a haste I forgot to actually write "return res;" and the
> result type
> should be predicate_result, but looks like you've figured it out ;)
>
> Gennadiy
>
>
> _______________________________________________
> Boost-Testing mailing list
> Boost-Testing_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-testing
>



Boost-testing list run by mbergal at meta-comm.com