]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/atomic/test/lightweight_test_stream.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / atomic / test / lightweight_test_stream.hpp
1 // Copyright (c) 2020 Andrey Semashev
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 #ifndef BOOST_ATOMIC_TEST_LIGHTWEIGHT_TEST_STREAM_HPP_INCLUDED_
8 #define BOOST_ATOMIC_TEST_LIGHTWEIGHT_TEST_STREAM_HPP_INCLUDED_
9
10 #include <iostream>
11 #include <boost/config.hpp>
12
13 struct test_stream_type
14 {
15 typedef std::ios_base& (*ios_base_manip)(std::ios_base&);
16 typedef std::basic_ios< char, std::char_traits< char > >& (*basic_ios_manip)(std::basic_ios< char, std::char_traits< char > >&);
17 typedef std::ostream& (*stream_manip)(std::ostream&);
18
19 template< typename T >
20 test_stream_type const& operator<< (T const& value) const
21 {
22 std::cerr << value;
23 return *this;
24 }
25
26 test_stream_type const& operator<< (ios_base_manip manip) const
27 {
28 std::cerr << manip;
29 return *this;
30 }
31 test_stream_type const& operator<< (basic_ios_manip manip) const
32 {
33 std::cerr << manip;
34 return *this;
35 }
36 test_stream_type const& operator<< (stream_manip manip) const
37 {
38 std::cerr << manip;
39 return *this;
40 }
41
42 // Make sure characters are printed as numbers if tests fail
43 test_stream_type const& operator<< (char value) const
44 {
45 std::cerr << static_cast< int >(value);
46 return *this;
47 }
48 test_stream_type const& operator<< (signed char value) const
49 {
50 std::cerr << static_cast< int >(value);
51 return *this;
52 }
53 test_stream_type const& operator<< (unsigned char value) const
54 {
55 std::cerr << static_cast< unsigned int >(value);
56 return *this;
57 }
58 test_stream_type const& operator<< (short value) const
59 {
60 std::cerr << static_cast< int >(value);
61 return *this;
62 }
63 test_stream_type const& operator<< (unsigned short value) const
64 {
65 std::cerr << static_cast< unsigned int >(value);
66 return *this;
67 }
68
69 #if defined(BOOST_HAS_INT128)
70 // Some GCC versions don't provide output operators for __int128
71 test_stream_type const& operator<< (boost::int128_type const& v) const
72 {
73 std::cerr << static_cast< long long >(v);
74 return *this;
75 }
76 test_stream_type const& operator<< (boost::uint128_type const& v) const
77 {
78 std::cerr << static_cast< unsigned long long >(v);
79 return *this;
80 }
81 #endif // defined(BOOST_HAS_INT128)
82 #if defined(BOOST_HAS_FLOAT128)
83 // libstdc++ does not provide output operators for __float128
84 test_stream_type const& operator<< (boost::float128_type const& v) const
85 {
86 std::cerr << static_cast< double >(v);
87 return *this;
88 }
89 #endif // defined(BOOST_HAS_FLOAT128)
90 };
91
92 const test_stream_type test_stream = {};
93
94 #define BOOST_LIGHTWEIGHT_TEST_OSTREAM test_stream
95
96 #include <boost/core/lightweight_test.hpp>
97
98 #endif // BOOST_ATOMIC_TEST_LIGHTWEIGHT_TEST_STREAM_HPP_INCLUDED_