]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
35 | // ************************************************************************** // | |
36 | // ************** string_compare ************** // | |
37 | // ************************************************************************** // | |
38 | ||
39 | #define DEFINE_CSTRING_COMPARISON( oper, name, rev ) \ | |
40 | template<typename Lhs,typename Rhs> \ | |
41 | struct name<Lhs,Rhs,typename boost::enable_if_c< \ | |
42 | unit_test::is_cstring<Lhs>::value && \ | |
43 | unit_test::is_cstring<Rhs>::value>::type> { \ | |
44 | typedef typename boost::add_const< \ | |
45 | typename remove_pointer< \ | |
46 | typename decay<Lhs>::type>::type>::type \ | |
47 | lhs_char_type; \ | |
48 | typedef typename boost::add_const< \ | |
49 | typename remove_pointer< \ | |
50 | typename decay<Rhs>::type>::type>::type \ | |
51 | rhs_char_type; \ | |
52 | public: \ | |
53 | typedef assertion_result result_type; \ | |
54 | \ | |
55 | static bool \ | |
56 | eval( Lhs const& lhs, Rhs const& rhs) \ | |
57 | { \ | |
58 | return unit_test::basic_cstring<lhs_char_type>(lhs) oper \ | |
59 | unit_test::basic_cstring<rhs_char_type>(rhs); \ | |
60 | } \ | |
61 | \ | |
62 | template<typename PrevExprType> \ | |
63 | static void \ | |
64 | report( std::ostream& ostr, \ | |
65 | PrevExprType const& lhs, \ | |
66 | Rhs const& rhs) \ | |
67 | { \ | |
68 | lhs.report( ostr ); \ | |
69 | ostr << revert() \ | |
70 | << tt_detail::print_helper( rhs ); \ | |
71 | } \ | |
72 | \ | |
73 | static char const* revert() \ | |
74 | { return " " #rev " "; } \ | |
75 | }; \ | |
76 | /**/ | |
77 | ||
78 | BOOST_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 |