1 // Copyright (c) 2020 Andrey Semashev
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)
7 #ifndef BOOST_ATOMIC_TEST_LIGHTWEIGHT_TEST_STREAM_HPP_INCLUDED_
8 #define BOOST_ATOMIC_TEST_LIGHTWEIGHT_TEST_STREAM_HPP_INCLUDED_
11 #include <boost/config.hpp>
13 struct test_stream_type
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&);
19 template< typename T >
20 test_stream_type const& operator<< (T const& value) const
26 test_stream_type const& operator<< (ios_base_manip manip) const
31 test_stream_type const& operator<< (basic_ios_manip manip) const
36 test_stream_type const& operator<< (stream_manip manip) const
42 // Make sure characters are printed as numbers if tests fail
43 test_stream_type const& operator<< (char value) const
45 std::cerr << static_cast< int >(value);
48 test_stream_type const& operator<< (signed char value) const
50 std::cerr << static_cast< int >(value);
53 test_stream_type const& operator<< (unsigned char value) const
55 std::cerr << static_cast< unsigned int >(value);
58 test_stream_type const& operator<< (short value) const
60 std::cerr << static_cast< int >(value);
63 test_stream_type const& operator<< (unsigned short value) const
65 std::cerr << static_cast< unsigned int >(value);
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
73 std::cerr << static_cast< long long >(v);
76 test_stream_type const& operator<< (boost::uint128_type const& v) const
78 std::cerr << static_cast< unsigned long long >(v);
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
86 std::cerr << static_cast< double >(v);
89 #endif // defined(BOOST_HAS_FLOAT128)
92 const test_stream_type test_stream = {};
94 #define BOOST_LIGHTWEIGHT_TEST_OSTREAM test_stream
96 #include <boost/core/lightweight_test.hpp>
98 #endif // BOOST_ATOMIC_TEST_LIGHTWEIGHT_TEST_STREAM_HPP_INCLUDED_