Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > by-pkgid > ef9bad9e14fc2a68cb7c992c11d75f5e > files > 4095

libboost1-devel-1.31.0-1mdk.i586.rpm

<HTML>
<HEAD>
<TITLE>The Test Tools</TITLE>
<LINK rel="stylesheet" type="text/css" href="../../../style/btl.css" media="screen">
<LINK rel="stylesheet" type="text/css" href="../../../style/btl-print.css" media="print">
<META http-equiv="Content-Language" content="en-us">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STYLE type="text/css">
H4
{
    margin:     0px;
}
</STYLE>
</HEAD>
<BODY>
<DIV class="body"> 
  <H3>BOOST_CHECK_PREDICATE( predicate, predicate_arity, arguments_list ) </H3>
  <P class="first-line-indented">This tool is used to validate the supplied predicate functor. This test 
    tool is generic. It allows to validate arbitrary one or two arity predicate. To validate zero or more 
    then two arity predicate use <A href="BOOST_CHECK.html" target="descr">BOOST_CHECK</A> tool. The advantage 
    of this tool is that shows arguments values in case of predicate failure.</P>
  <P class="first-line-indented">If predicate produces <I>true</I> value, the tool produces a confirmation 
    message (note: to manage what messages appear in the test output stream set the proper log level), 
    in other case it produces an error message in a form &quot;error in ...: test &lt;predicate&gt;( arguments 
    list ) fail for (arguments values)&quot;.</P>
  <P class="first-line-indented">The tools first parameter is the predicate itself. The tools second parameter 
    the predicate arity. The last third argument is wrapped in round brackets, comma separated list of 
    predicate arguments.</P>
  <H4>Example: test.cpp</H4>
<PRE class="code"><SPAN class="cpp-type">bool</SPAN> is_even( <SPAN class="cpp-type">int</SPAN> i ) {
    <SPAN class="reserv-word">return</SPAN> i%<SPAN class="literal">2</SPAN> == <SPAN class="literal">0</SPAN>;
}

<SPAN class="cpp-type">int</SPAN> test.cpp( <SPAN class="cpp-type">int</SPAN>, <SPAN class="cpp-type">char</SPAN>* [] ) {
    <SPAN class="cpp-type">int</SPAN> i = <SPAN class="literal">17</SPAN>;
    BOOST_CHECK_PREDICATE( &amp;is_even, <SPAN class="literal">1</SPAN>, (i) );

    <SPAN class="reserv-word">return</SPAN> <SPAN class="literal">0</SPAN>;
}
</PRE>
  <H4>Output:</H4>
  <P class="test-output">test.cpp(3) : error in test_main: test &amp;is_even(i) failed for 17 </P>
  <H4>Example: test.cpp</H4>
  <PRE class="code"><SPAN class="cpp-type">int</SPAN> test.cpp( <SPAN class="cpp-type">int</SPAN>, <SPAN class="cpp-type">char</SPAN>* [] ) {
    <SPAN class="cpp-type">int</SPAN> i = <SPAN class="literal">17</SPAN>;

    BOOST_CHECK_PREDICATE( std::not_equal_to&lt;<SPAN class="cpp-type">int</SPAN>&gt;(), <SPAN class="literal">2</SPAN>, (i,<SPAN class="literal">17</SPAN>) );

    <SPAN class="reserv-word">return</SPAN> <SPAN class="literal">0</SPAN>;
}
</PRE>
  <H4>Output:</H4>
  <P class="test-output">test.cpp(3) : error in test_main: test std::not_equal_to&lt;int&gt;()(i, 17) 
    failed for (17, 17) </P>
  <DIV class="see_also"> 
    <H4>See Also</H4>
    <P class="see-also-content"><A href="BOOST_CHECK.html" target="descr">BOOST_CHECK</A></P>
  </DIV>
</DIV>
</BODY>
</HTML>