[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-testing
Subject:    Re: [Boost-testing] BOOST_CHECK_EQUAL on user-defined type
From:       Jarosław_Bober <jaroslaw.bober () gmail ! com>
Date:       2011-11-14 10:13:03
Message-ID: CALVDZzQQHN32yHzs2KvFyx5oR09F42BjDhQMMEGXb898=B7EDw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@gmail.com>

> 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@lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/boost-testing
>

[Attachment #5 (text/html)]

Yes, I was looking at these examples all the time:<br><a \
href="http://www.boost.org/doc/libs/1_45_0/libs/test/doc/html/utf/testing-tools/custom \
-predicate.html">http://www.boost.org/doc/libs/1_45_0/libs/test/doc/html/utf/testing-tools/custom-predicate.html</a><br>
 but i couldn&#39;t actually find that there is a solution to my problem and your \
suggestion gave me direction.<br>Complete solution looks like this:<br><br>using \
namespace boost::test_tools;<br>predicate_result<br>compare(MyClass const&amp; \
expected, MyClass const&amp; received)<br> {<br>   if(expected.a != received.a) {<br> \
predicate_result res( false );<br>        res.message() &lt;&lt; &quot;Difference in \
field a: &quot; &lt;&lt; expected.a &lt;&lt; &quot;, &quot; &lt;&lt; received.a;<br>  \
return res;<br>  }<br><br>   if(expected.b != received.b) {<br>        \
predicate_result res( false );<br>        res.message() &lt;&lt; &quot;Difference in \
field b: &quot; &lt;&lt; expected.b &lt;&lt; &quot;, &quot; &lt;&lt; received.b;<br>  \
return res;<br>   }<br><br>   return true;<br>}<br><br>Thanks <br><br><div \
class="gmail_quote">2011/11/14 Gennadiy Rozental <span dir="ltr">&lt;<a \
href="mailto:rogeeff@gmail.com">rogeeff@gmail.com</a>&gt;</span><br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex;"> <div class="im">Jarosław Bober &lt;jaroslaw.bober \
&lt;at&gt; <a href="http://gmail.com" target="_blank">gmail.com</a>&gt; writes:<br> \
<br> &gt;<br>
&gt;<br>
</div><div class="im">&gt; Thank you Gennadiy, now it works like it should \
:)Regards<br> <br>
</div>Actually in a haste I forgot to actually write &quot;return res;&quot; and the \
result type<br> should be predicate_result, but looks like you&#39;ve figured it out \
;)<br> <div><div></div><div class="h5"><br>
Gennadiy<br>
<br>
<br>
_______________________________________________<br>
Boost-Testing mailing list<br>
<a href="mailto:Boost-Testing@lists.boost.org">Boost-Testing@lists.boost.org</a><br>
<a href="http://lists.boost.org/mailman/listinfo.cgi/boost-testing" \
target="_blank">http://lists.boost.org/mailman/listinfo.cgi/boost-testing</a></div></div></blockquote></div><br>




_______________________________________________
Boost-Testing mailing list
Boost-Testing@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-testing

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic