Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:40

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 //!@file
0009 //!@brief C string comparison with enhanced reporting
0010 // ***************************************************************************
0011 
0012 #ifndef BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
0013 #define BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
0014 
0015 // Boost.Test
0016 #include <boost/test/tools/assertion.hpp>
0017 
0018 #include <boost/test/utils/is_cstring.hpp>
0019 #include <boost/test/utils/basic_cstring/compare.hpp>
0020 
0021 // Boost
0022 #include <boost/utility/enable_if.hpp>
0023 
0024 #include <boost/test/detail/suppress_warnings.hpp>
0025 
0026 //____________________________________________________________________________//
0027 
0028 namespace boost {
0029 namespace test_tools {
0030 namespace assertion {
0031 namespace op {
0032 
0033 // ************************************************************************** //
0034 // **************               string_compare                 ************** //
0035 // ************************************************************************** //
0036 
0037 #define DEFINE_CSTRING_COMPARISON( oper, name, rev, name_inverse )  \
0038 template<typename Lhs,typename Rhs>                                 \
0039 struct name<Lhs,Rhs,typename boost::enable_if_c<                    \
0040     (   unit_test::is_cstring_comparable<Lhs>::value                \
0041      && unit_test::is_cstring_comparable<Rhs>::value)               \
0042     >::type >                                                       \
0043 {                                                                   \
0044     typedef typename unit_test::deduce_cstring_transform<Lhs>::type lhs_char_type; \
0045     typedef typename unit_test::deduce_cstring_transform<Rhs>::type rhs_char_type; \
0046 public:                                                             \
0047     typedef assertion_result result_type;                           \
0048     typedef name_inverse<Lhs, Rhs> inverse;                         \
0049                                                                     \
0050     typedef name<                                                   \
0051         typename lhs_char_type::value_type,                         \
0052         typename rhs_char_type::value_type> elem_op;                \
0053                                                                     \
0054     static bool                                                     \
0055     eval( Lhs const& lhs, Rhs const& rhs)                           \
0056     {                                                               \
0057         return lhs_char_type(lhs) oper rhs_char_type(rhs);          \
0058     }                                                               \
0059                                                                     \
0060     template<typename PrevExprType>                                 \
0061     static void                                                     \
0062     report( std::ostream&       ostr,                               \
0063             PrevExprType const& lhs,                                \
0064             Rhs const&          rhs)                                \
0065     {                                                               \
0066         lhs.report( ostr );                                         \
0067         ostr << revert()                                            \
0068              << tt_detail::print_helper( rhs );                     \
0069     }                                                               \
0070                                                                     \
0071     static char const* forward()                                    \
0072     { return " " #oper " "; }                                       \
0073     static char const* revert()                                     \
0074     { return " " #rev " "; }                                        \
0075 };                                                                  \
0076 /**/
0077 
0078 BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_CSTRING_COMPARISON )
0079 #undef DEFINE_CSTRING_COMPARISON
0080 
0081 //____________________________________________________________________________//
0082 
0083 } // namespace op
0084 } // namespace assertion
0085 } // namespace test_tools
0086 } // namespace boost
0087 
0088 #include <boost/test/detail/enable_warnings.hpp>
0089 
0090 #endif // BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
0091