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 | //! Per element comparison manipulator implementation |
10 | // *************************************************************************** |
11 | |
12 | #ifndef BOOST_TEST_TOOLS_DETAIL_PER_ELEMENT_MANIP_HPP_050815GER |
13 | #define BOOST_TEST_TOOLS_DETAIL_PER_ELEMENT_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/utils/lazy_ostream.hpp> |
20 | #include <boost/test/tools/assertion.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 | //! Per element comparison manipulator, for containers |
37 | //! This is a terminal that involves evaluation of the expression |
38 | struct per_element {}; |
39 | |
40 | //____________________________________________________________________________// |
41 | |
42 | inline unit_test::lazy_ostream& |
43 | operator<<( unit_test::lazy_ostream &o, per_element ) { return o; } |
44 | |
45 | // needed for the lazy evaluation in lazy_ostream as per_element is a terminal |
46 | inline std::ostream& |
47 | operator<<( std::ostream& o, per_element ) { return o; } |
48 | |
49 | //____________________________________________________________________________// |
50 | |
51 | namespace tt_detail { |
52 | |
53 | template<typename T1, typename T2, typename OP> |
54 | inline assertion_result |
55 | operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,OP> > const& ae, per_element ) |
56 | { |
57 | typedef typename OP::elem_op elem_op; |
58 | return assertion::op::element_compare<elem_op>( ae.m_e.lhs().value(), ae.m_e.rhs() ); |
59 | } |
60 | |
61 | //____________________________________________________________________________// |
62 | |
63 | inline assertion_type |
64 | operator<<( assertion_type const&, per_element ) |
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_PER_ELEMENT_MANIP_HPP_050815GER |
78 | |