supernova: c++11 compile fixes
[supercollider.git] / external_libraries / boost_endian / libs / integer / test / binary_stream_test.cpp
blob633669a2ca9a87c232cdbb494e1ea3feced6dab9
1 // binary_stream_test.cpp ------------------------------------------------------------//
3 // Copyright Beman Dawes 2009
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
8 #include <boost/binary_stream.hpp>
9 #include <string>
10 #include <iostream>
11 #include <sstream>
13 using namespace boost;
14 using namespace std;
16 namespace
18 int errors = 0;
20 void verify( bool x, const char * file, int line )
22 if ( x ) return;
23 ++errors;
24 cout << file << "(" << line << ") : error: predicate is false\n" << endl;
29 #define BOOST_VERIFY(predicate) verify( predicate, __FILE__, __LINE__ )
32 int main()
34 std::stringstream ss( std::ios_base::in | std::ios_base::out | std::ios_base::binary );
36 short short_1(0x0102), short_2;
37 ss <= short_1;
38 ss >= short_2;
39 BOOST_VERIFY( short_1 == short_2 );
41 unsigned short ushort_1(0x0102), ushort_2;
42 ss <= ushort_1;
43 ss >= ushort_2;
44 BOOST_VERIFY( ushort_1 == ushort_2 );
46 int int_1(0x01020304), int_2;
47 ss <= int_1;
48 ss >= int_2;
49 BOOST_VERIFY( int_1 == int_2 );
51 unsigned int uint_1(0x01020304), uint_2;
52 ss <= uint_1;
53 ss >= uint_2;
54 BOOST_VERIFY( uint_1 == uint_2 );
56 long long_1(0x01020304L), long_2;
57 ss <= long_1;
58 ss >= long_2;
59 BOOST_VERIFY( long_1 == long_2 );
61 unsigned long ulong_1(0x01020304UL), ulong_2;
62 ss <= ulong_1;
63 ss >= ulong_2;
64 BOOST_VERIFY( ulong_1 == ulong_2 );
66 long long long_long_1(0x0102030405060708LL), long_long_2;
67 ss <= long_long_1;
68 ss >= long_long_2;
69 BOOST_VERIFY( long_long_1 == long_long_2 );
71 unsigned long long ulong_long_1(0x0102030405060708ULL), ulong_long_2;
72 ss <= ulong_long_1;
73 ss >= ulong_long_2;
74 BOOST_VERIFY( ulong_long_1 == ulong_long_2 );
76 float float_1(1.2F), float_2;
77 ss <= float_1;
78 ss >= float_2;
79 BOOST_VERIFY( float_1 == float_2 );
81 double double_1(1.2), double_2;
82 ss <= double_1;
83 ss >= double_2;
84 BOOST_VERIFY( double_1 == double_2 );
86 long double long_double_1(1.2), long_double_2;
87 ss <= long_double_1;
88 ss >= long_double_2;
89 BOOST_VERIFY( long_double_1 == long_double_2 );
91 char char_1(0x01), char_2;
92 ss <= char_1;
93 ss >= char_2;
94 BOOST_VERIFY( char_1 == char_2 );
96 signed char schar_1(0x01), schar_2;
97 ss <= schar_1;
98 ss >= schar_2;
99 BOOST_VERIFY( schar_1 == schar_2 );
101 unsigned char uchar_1(0x01), uchar_2;
102 ss <= uchar_1;
103 ss >= uchar_2;
104 BOOST_VERIFY( uchar_1 == uchar_2 );
106 wchar_t wchar_t_1(L'1'), wchar_t_2;
107 ss <= wchar_t_1;
108 ss >= wchar_t_2;
109 BOOST_VERIFY( wchar_t_1 == wchar_t_2 );
111 string string_1("foobar"), string_2;
112 ss <= string_1.c_str();
113 ss >= string_2;
114 BOOST_VERIFY( string_1 == string_2 );
115 ss <= string_1;
116 ss >= string_2;
117 BOOST_VERIFY( string_1 == string_2 );
119 cout << errors << " error(s) detected\n";
120 return errors;