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 //! Lexicographic comparison manipulator implementation
10 // ***************************************************************************
11
12 #ifndef BOOST_TEST_TOOLS_DETAIL_LEXICOGRAPHIC_MANIP_HPP_050815GER
13 #define BOOST_TEST_TOOLS_DETAIL_LEXICOGRAPHIC_MANIP_HPP_050815GER
14
15 // Boost Test
16 #include <boost/test/tools/detail/fwd.hpp>
17 #include <boost/test/tools/detail/indirections.hpp>
18
19 #include <boost/test/tools/assertion.hpp>
20 #include <boost/test/utils/lazy_ostream.hpp>
21 #include <boost/test/tools/collection_comparison_op.hpp>
22
23 #include <ostream>
24
25 #include <boost/test/detail/suppress_warnings.hpp>
26
27 //____________________________________________________________________________//
28
29 namespace boost {
30 namespace test_tools {
31
32 // ************************************************************************** //
33 // ************** per element comparison manipulator ************** //
34 // ************************************************************************** //
35
36 //! Lexicographic comparison manipulator, for containers
37 //! This is a terminal that involves evaluation of the expression
38 struct lexicographic {};
39
40 //____________________________________________________________________________//
41
42 inline unit_test::lazy_ostream&
operator <<(unit_test::lazy_ostream & o,lexicographic)43 operator<<( unit_test::lazy_ostream & o, lexicographic ) { return o; }
44
45 // needed for the lazy evaluation in lazy_ostream as lexicographic is a terminal
46 inline std::ostream&
operator <<(std::ostream & o,lexicographic)47 operator<<( std::ostream& o, lexicographic ) { return o; }
48
49 //____________________________________________________________________________//
50
51 namespace tt_detail {
52
53 template<typename T1, typename T2, typename OP>
54 inline assertion_result
operator <<(assertion_evaluate_t<assertion::binary_expr<T1,T2,OP>> const & ae,lexicographic)55 operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,OP> > const& ae, lexicographic )
56 {
57 typedef typename OP::elem_op elem_op;
58 return assertion::op::lexicographic_compare<elem_op>( ae.m_e.lhs().value(), ae.m_e.rhs() );
59 }
60
61 //____________________________________________________________________________//
62
63 inline assertion_type
operator <<(assertion_type const &,lexicographic)64 operator<<( assertion_type const&, lexicographic )
65 {
66 return assertion_type(CHECK_BUILT_ASSERTION);
67 }
68
69 //____________________________________________________________________________//
70
71 } // namespace tt_detail
72 } // namespace test_tools
73 } // namespace boost
74
75 #include <boost/test/detail/enable_warnings.hpp>
76
77 #endif // BOOST_TEST_TOOLS_DETAIL_LEXICOGRAPHIC_MANIP_HPP_050815GER
78