Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / test / tools / cstring_comparison_op.hpp
1 //  (C) Copyright Gennadiy Rozental 2001.
2 //  Distributed under the Boost Software License, Version 1.0.
3 //  (See accompanying file LICENSE_1_0.txt or copy at
4 //  http://www.boost.org/LICENSE_1_0.txt)
5
6 //  See http://www.boost.org/libs/test for the library home page.
7 //
8 //!@file
9 //!@brief C string comparison with enhanced reporting
10 // ***************************************************************************
11
12 #ifndef BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
13 #define BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
14
15 // Boost.Test
16 #include <boost/test/tools/assertion.hpp>
17
18 #include <boost/test/utils/is_cstring.hpp>
19 #include <boost/test/utils/basic_cstring/compare.hpp>
20
21 // Boost
22 #include <boost/utility/enable_if.hpp>
23
24 #include <boost/test/detail/suppress_warnings.hpp>
25
26 //____________________________________________________________________________//
27
28 namespace boost {
29 namespace test_tools {
30 namespace assertion {
31 namespace op {
32
33 // ************************************************************************** //
34 // **************               string_compare                 ************** //
35 // ************************************************************************** //
36
37 #define DEFINE_CSTRING_COMPARISON( oper, name, rev )                \
38 template<typename Lhs,typename Rhs>                                 \
39 struct name<Lhs,Rhs,typename boost::enable_if_c<                    \
40     (   unit_test::is_cstring_comparable<Lhs>::value                \
41      && unit_test::is_cstring_comparable<Rhs>::value)               \
42     >::type >                                                       \
43 {                                                                   \
44     typedef typename unit_test::deduce_cstring_transform<Lhs>::type lhs_char_type; \
45     typedef typename unit_test::deduce_cstring_transform<Rhs>::type rhs_char_type; \
46 public:                                                             \
47     typedef assertion_result result_type;                           \
48                                                                     \
49     typedef name<                                                   \
50         typename lhs_char_type::value_type,                         \
51         typename rhs_char_type::value_type> elem_op;                \
52                                                                     \
53     static bool                                                     \
54     eval( Lhs const& lhs, Rhs const& rhs)                           \
55     {                                                               \
56         return lhs_char_type(lhs) oper rhs_char_type(rhs);          \
57     }                                                               \
58                                                                     \
59     template<typename PrevExprType>                                 \
60     static void                                                     \
61     report( std::ostream&       ostr,                               \
62             PrevExprType const& lhs,                                \
63             Rhs const&          rhs)                                \
64     {                                                               \
65         lhs.report( ostr );                                         \
66         ostr << revert()                                            \
67              << tt_detail::print_helper( rhs );                     \
68     }                                                               \
69                                                                     \
70     static char const* revert()                                     \
71     { return " " #rev " "; }                                        \
72 };                                                                  \
73 /**/
74
75 BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_CSTRING_COMPARISON )
76 #undef DEFINE_CSTRING_COMPARISON
77
78 //____________________________________________________________________________//
79
80 } // namespace op
81 } // namespace assertion
82 } // namespace test_tools
83 } // namespace boost
84
85 #include <boost/test/detail/enable_warnings.hpp>
86
87 #endif // BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
88