Ticket #6624: ticket6624.2.patch

File ticket6624.2.patch, 6.8 KB (added by dtrebbien@…, 11 years ago)

Patch

  • boost/test/tools/impl.hpp

     
    166166    CHECK_BITWISE_EQUAL,
    167167    CHECK_PRED_WITH_ARGS,
    168168    CHECK_EQUAL_COLL,
     169    CHECK_NE_COLL,
    169170    CHECK_BUILT_ASSERTION
    170171};
    171172
     
    425426
    426427//____________________________________________________________________________//
    427428
     429struct ne_coll_impl {
     430    template <typename Left, typename Right>
     431    predicate_result operator()( Left left_begin, Left left_end, Right right_begin, Right right_end )
     432    {
     433        predicate_result    pr( true );
     434        Left left_begin_copy( left_begin );
     435        std::size_t         pos = 0;
     436
     437        for( ; left_begin != left_end && right_begin != right_end; ++left_begin, ++right_begin, ++pos ) {
     438            if( *left_begin != *right_begin ) {
     439                return pr;
     440            }
     441        }
     442
     443        if ( left_begin != left_end || right_begin != right_end ) {
     444            return pr;
     445        }
     446
     447        pr = false;
     448        pr.message() << "\nCollections have the same size (" << pos << ") and contents:";
     449
     450        pos = 0;
     451        for ( ; left_begin_copy != left_end; ++left_begin_copy, ++pos ) {
     452            pr.message() << '\n' << pos << ": " << *left_begin_copy;
     453        }
     454
     455        return pr;
     456    }
     457};
     458
     459//____________________________________________________________________________//
     460
    428461struct bitwise_equal_impl {
    429462    template <class Left, class Right>
    430463    predicate_result    operator()( Left const& left, Right const& right )
  • boost/test/impl/test_tools.ipp

    Property changes on: boost/test/tools/impl.hpp
    ___________________________________________________________________
    Modified: svn:mime-type
       - test/plain
       + text/plain
    
     
    261261        break;
    262262    }
    263263
     264    case CHECK_NE_COLL: {
     265        char const* left_begin_descr    = va_arg( args, char const* );
     266        char const* left_end_descr      = va_arg( args, char const* );
     267        char const* right_begin_descr   = va_arg( args, char const* );
     268        char const* right_end_descr     = va_arg( args, char const* );
     269
     270        os << prefix << "{ " << left_begin_descr  << ", " << left_end_descr  << " } != { "
     271                             << right_begin_descr << ", " << right_end_descr << " }"
     272           << suffix;
     273
     274        if( !pr.has_empty_message() )
     275            os << ". " << pr.message();
     276        break;
     277    }
     278
    264279    case CHECK_BITWISE_EQUAL: {
    265280        char const* left_descr    = va_arg( args, char const* );
    266281        char const* right_descr   = va_arg( args, char const* );
  • boost/test/test_tools.hpp

     
    284284
    285285//____________________________________________________________________________//
    286286
     287#define BOOST_WARN_NE_COLLECTIONS( L_begin, L_end, R_begin, R_end )                  \
     288    BOOST_TEST_TOOL_IMPL( 1, ::boost::test_tools::tt_detail::ne_coll_impl(),         \
     289        "", WARN, CHECK_NE_COLL, (L_begin)(L_end)(R_begin)(R_end), BOOST_PP_EMPTY() )  \
     290/**/
     291#define BOOST_CHECK_NE_COLLECTIONS( L_begin, L_end, R_begin, R_end )                 \
     292    BOOST_TEST_TOOL_IMPL( 1, ::boost::test_tools::tt_detail::ne_coll_impl(),         \
     293        "", CHECK, CHECK_NE_COLL, (L_begin)(L_end)(R_begin)(R_end), BOOST_PP_EMPTY() ) \
     294/**/
     295#define BOOST_REQUIRE_NE_COLLECTIONS( L_begin, L_end, R_begin, R_end )               \
     296    BOOST_TEST_TOOL_IMPL( 1, ::boost::test_tools::tt_detail::ne_coll_impl(),         \
     297        "", REQUIRE, CHECK_NE_COLL, (L_begin)(L_end)(R_begin)(R_end), BOOST_PP_EMPTY() )\
     298/**/
     299
     300//____________________________________________________________________________//
     301
    287302#define BOOST_WARN_BITWISE_EQUAL( L, R )    BOOST_TEST_TOOL_IMPL( 1, \
    288303    ::boost::test_tools::tt_detail::bitwise_equal_impl(), "", WARN, CHECK_BITWISE_EQUAL, (L)(R), BOOST_PP_EMPTY() )
    289304#define BOOST_CHECK_BITWISE_EQUAL( L, R )   BOOST_TEST_TOOL_IMPL( 1, \
  • libs/test/doc/src/utf.testing-tools.xml

     
    688688    <para role="first-line-indented">
    689689     These tools are used to perform an element by element comparison of two collections. They print all mismatched
    690690     positions, collection elements at these positions and check that the collections have the same size. The first two
    691      parameters designate begin and end of the first collection. The two parameters designate begin and end of the
     691     parameters designate begin and end of the first collection. The last two parameters designate begin and end of the
    692692     second collection.
    693693    </para>
    694694   
     
    697697    </btl-example>
    698698
    699699    <seealso>
     700     <ref>BOOST_&lt;level&gt;_NE_COLLECTIONS</ref>
    700701     <ref>BOOST_&lt;level&gt;_EQUAL</ref>
    701702    </seealso>
    702703   </refentry>
    703704
     705   <refentry name="BOOST_&lt;level&gt;_NE_COLLECTIONS">
     706    <inline-synopsis>
     707     <macro name="BOOST_WARN_NE_COLLECTIONS" kind="functionlike" ref-id="utf.testing-tools.reference">
     708       <macro-parameter name="left_begin"/>
     709       <macro-parameter name="left_end"/>
     710       <macro-parameter name="right_begin"/>
     711       <macro-parameter name="right_end"/>
     712     </macro>
     713     <macro name="BOOST_CHECK_NE_COLLECTIONS" kind="functionlike" ref-id="utf.testing-tools.reference">
     714       <macro-parameter name="left_begin"/>
     715       <macro-parameter name="left_end"/>
     716       <macro-parameter name="right_begin"/>
     717       <macro-parameter name="right_end"/>
     718     </macro>
     719     <macro name="BOOST_REQUIRE_NE_COLLECTIONS" kind="functionlike" ref-id="utf.testing-tools.reference">
     720       <macro-parameter name="left_begin"/>
     721       <macro-parameter name="left_end"/>
     722       <macro-parameter name="right_begin"/>
     723       <macro-parameter name="right_end"/>
     724     </macro>
     725    </inline-synopsis>
     726
     727    <para role="first-line-indented">
     728     These tools are used to perform a comparison of two collections to check that they are not equal. The first two
     729     parameters designate begin and end of the first collection. The last two parameters designate begin and end of the
     730     second collection.
     731    </para>
     732
     733    <seealso>
     734     <ref>BOOST_&lt;level&gt;_EQUAL_COLLECTIONS</ref>
     735     <ref>BOOST_&lt;level&gt;_NE</ref>
     736    </seealso>
     737   </refentry>
     738
    704739   <refentry name="BOOST_&lt;level&gt;_EXCEPTION">
    705740    <inline-synopsis>
    706741     <macro name="BOOST_WARN_EXCEPTION" kind="functionlike" ref-id="utf.testing-tools.reference">