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
28namespace boost {
29namespace test_tools {
30namespace assertion {
31namespace op {
32
33// ************************************************************************** //
34// ************** string_compare ************** //
35// ************************************************************************** //
36
37#define DEFINE_CSTRING_COMPARISON( oper, name, rev, name_inverse ) \
38template<typename Lhs,typename Rhs> \
39struct 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; \
46public: \
47 typedef assertion_result result_type; \
48 typedef name_inverse<Lhs, Rhs> inverse; \
49 \
50 typedef name< \
51 typename lhs_char_type::value_type, \
52 typename rhs_char_type::value_type> elem_op; \
53 \
54 static bool \
55 eval( Lhs const& lhs, Rhs const& rhs) \
56 { \
57 return lhs_char_type(lhs) oper rhs_char_type(rhs); \
58 } \
59 \
60 template<typename PrevExprType> \
61 static void \
62 report( std::ostream& ostr, \
63 PrevExprType const& lhs, \
64 Rhs const& rhs) \
65 { \
66 lhs.report( ostr ); \
67 ostr << revert() \
68 << tt_detail::print_helper( rhs ); \
69 } \
70 \
71 static char const* forward() \
72 { return " " #oper " "; } \
73 static char const* revert() \
74 { return " " #rev " "; } \
75}; \
76/**/
77
78BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_CSTRING_COMPARISON )
79#undef DEFINE_CSTRING_COMPARISON
80
81//____________________________________________________________________________//
82
83} // namespace op
84} // namespace assertion
85} // namespace test_tools
86} // namespace boost
87
88#include <boost/test/detail/enable_warnings.hpp>
89
90#endif // BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
91
92

source code of include/boost/test/tools/cstring_comparison_op.hpp