]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/test/writing-test-ts/user-defined-types-logging-customization-points.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / test / test / writing-test-ts / user-defined-types-logging-customization-points.cpp
1 // (C) Copyright Raffi Enficiaud 2017.
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 //! Customization point for printing user defined types
10 // *****************************************************************************
11
12 #define BOOST_TEST_MODULE user type logger customization points
13 #include <boost/test/unit_test.hpp>
14
15 namespace printing_test {
16 struct user_defined_type {
17 int value;
18
19 user_defined_type(int value_) : value(value_)
20 {}
21
22 bool operator==(int right) const {
23 return right == value;
24 }
25 };
26
27 std::ostream& boost_test_print_type(std::ostream& ostr, user_defined_type const& right) {
28 ostr << "** value of my type is " << right.value << " **";
29 return ostr;
30 }
31 }
32
33 //using namespace printing_test;
34
35 BOOST_AUTO_TEST_CASE(test1)
36 {
37 //using printing_test::user_defined_type;
38 printing_test::user_defined_type t(10);
39 BOOST_CHECK_EQUAL(t, 10);
40 #ifndef BOOST_TEST_MACRO_LIMITED_SUPPORT
41 BOOST_TEST(t == 10);
42 #endif
43 BOOST_TEST_MESSAGE("Printing t: " << t);
44 }
45
46 // on unary expressions as well
47 struct s {
48 operator bool() const { return true; }
49 };
50 std::ostream &boost_test_print_type(std::ostream &o, const s &) {
51 return o << "printed-s";
52 }
53
54 BOOST_AUTO_TEST_CASE( test_logs )
55 {
56 BOOST_TEST(s());
57 BOOST_TEST_MESSAGE("Printing s(): " << s());
58 }