supernova: c++11 compile fixes
[supercollider.git] / external_libraries / boost_endian / libs / integer / test / endian_binary_stream_test.cpp
blob3b4df2203171246458019cf82702877445478688
1 // endian_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/integer/endian_binary_stream.hpp>
9 #include <iostream>
10 #include <sstream>
12 using namespace boost;
13 using namespace boost::integer;
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__ )
31 int main()
33 std::stringstream ss( std::ios_base::in | std::ios_base::out | std::ios_base::binary );
35 // big tests
37 big8_t big8_t_1(0x01), big8_t_2;
38 ss <= big8_t_1;
39 ss >= big8_t_2;
40 BOOST_VERIFY( big8_t_1 == big8_t_2 );
42 big16_t big16_t_1(0x0102), big16_t_2;
43 ss <= big16_t_1;
44 ss >= big16_t_2;
45 BOOST_VERIFY( big16_t_1 == big16_t_2 );
47 big24_t big24_t_1(0x010203L), big24_t_2;
48 ss <= big24_t_1;
49 ss >= big24_t_2;
50 BOOST_VERIFY( big24_t_1 == big24_t_2 );
52 big32_t big32_t_1(0x01020304L), big32_t_2;
53 ss <= big32_t_1;
54 ss >= big32_t_2;
55 BOOST_VERIFY( big32_t_1 == big32_t_2 );
57 big40_t big40_t_1(0x0102030405LL), big40_t_2;
58 ss <= big40_t_1;
59 ss >= big40_t_2;
60 BOOST_VERIFY( big40_t_1 == big40_t_2 );
62 big48_t big48_t_1(0x010203040506LL), big48_t_2;
63 ss <= big48_t_1;
64 ss >= big48_t_2;
65 BOOST_VERIFY( big48_t_1 == big48_t_2 );
67 big56_t big56_t_1(0x01020304050607LL), big56_t_2;
68 ss <= big56_t_1;
69 ss >= big56_t_2;
70 BOOST_VERIFY( big56_t_1 == big56_t_2 );
72 big64_t big64_t_1(0x0102030405060808LL), big64_t_2;
73 ss <= big64_t_1;
74 ss >= big64_t_2;
75 BOOST_VERIFY( big64_t_1 == big64_t_2 );
77 // ubig tests
79 ubig8_t ubig8_t_1(0x01), ubig8_t_2;
80 ss <= ubig8_t_1;
81 ss >= ubig8_t_2;
82 BOOST_VERIFY( ubig8_t_1 == ubig8_t_2 );
84 ubig16_t ubig16_t_1(0x0102), ubig16_t_2;
85 ss <= ubig16_t_1;
86 ss >= ubig16_t_2;
87 BOOST_VERIFY( ubig16_t_1 == ubig16_t_2 );
89 ubig24_t ubig24_t_1(0x010203L), ubig24_t_2;
90 ss <= ubig24_t_1;
91 ss >= ubig24_t_2;
92 BOOST_VERIFY( ubig24_t_1 == ubig24_t_2 );
94 ubig32_t ubig32_t_1(0x01020304L), ubig32_t_2;
95 ss <= ubig32_t_1;
96 ss >= ubig32_t_2;
97 BOOST_VERIFY( ubig32_t_1 == ubig32_t_2 );
99 ubig40_t ubig40_t_1(0x0102030405LL), ubig40_t_2;
100 ss <= ubig40_t_1;
101 ss >= ubig40_t_2;
102 BOOST_VERIFY( ubig40_t_1 == ubig40_t_2 );
104 ubig48_t ubig48_t_1(0x010203040506LL), ubig48_t_2;
105 ss <= ubig48_t_1;
106 ss >= ubig48_t_2;
107 BOOST_VERIFY( ubig48_t_1 == ubig48_t_2 );
109 ubig56_t ubig56_t_1(0x01020304050607LL), ubig56_t_2;
110 ss <= ubig56_t_1;
111 ss >= ubig56_t_2;
112 BOOST_VERIFY( ubig56_t_1 == ubig56_t_2 );
114 ubig64_t ubig64_t_1(0x0102030405060808LL), ubig64_t_2;
115 ss <= ubig64_t_1;
116 ss >= ubig64_t_2;
117 BOOST_VERIFY( ubig64_t_1 == ubig64_t_2 );
119 // little tests
121 little8_t little8_t_1(0x01), little8_t_2;
122 ss <= little8_t_1;
123 ss >= little8_t_2;
124 BOOST_VERIFY( little8_t_1 == little8_t_2 );
126 little16_t little16_t_1(0x0102), little16_t_2;
127 ss <= little16_t_1;
128 ss >= little16_t_2;
129 BOOST_VERIFY( little16_t_1 == little16_t_2 );
131 little24_t little24_t_1(0x010203L), little24_t_2;
132 ss <= little24_t_1;
133 ss >= little24_t_2;
134 BOOST_VERIFY( little24_t_1 == little24_t_2 );
136 little32_t little32_t_1(0x01020304L), little32_t_2;
137 ss <= little32_t_1;
138 ss >= little32_t_2;
139 BOOST_VERIFY( little32_t_1 == little32_t_2 );
141 little40_t little40_t_1(0x0102030405LL), little40_t_2;
142 ss <= little40_t_1;
143 ss >= little40_t_2;
144 BOOST_VERIFY( little40_t_1 == little40_t_2 );
146 little48_t little48_t_1(0x010203040506LL), little48_t_2;
147 ss <= little48_t_1;
148 ss >= little48_t_2;
149 BOOST_VERIFY( little48_t_1 == little48_t_2 );
151 little56_t little56_t_1(0x01020304050607LL), little56_t_2;
152 ss <= little56_t_1;
153 ss >= little56_t_2;
154 BOOST_VERIFY( little56_t_1 == little56_t_2 );
156 little64_t little64_t_1(0x0102030405060808LL), little64_t_2;
157 ss <= little64_t_1;
158 ss >= little64_t_2;
159 BOOST_VERIFY( little64_t_1 == little64_t_2 );
161 // ulittle tests
163 ulittle8_t ulittle8_t_1(0x01), ulittle8_t_2;
164 ss <= ulittle8_t_1;
165 ss >= ulittle8_t_2;
166 BOOST_VERIFY( ulittle8_t_1 == ulittle8_t_2 );
168 ulittle16_t ulittle16_t_1(0x0102), ulittle16_t_2;
169 ss <= ulittle16_t_1;
170 ss >= ulittle16_t_2;
171 BOOST_VERIFY( ulittle16_t_1 == ulittle16_t_2 );
173 ulittle24_t ulittle24_t_1(0x010203L), ulittle24_t_2;
174 ss <= ulittle24_t_1;
175 ss >= ulittle24_t_2;
176 BOOST_VERIFY( ulittle24_t_1 == ulittle24_t_2 );
178 ulittle32_t ulittle32_t_1(0x01020304L), ulittle32_t_2;
179 ss <= ulittle32_t_1;
180 ss >= ulittle32_t_2;
181 BOOST_VERIFY( ulittle32_t_1 == ulittle32_t_2 );
183 ulittle40_t ulittle40_t_1(0x0102030405LL), ulittle40_t_2;
184 ss <= ulittle40_t_1;
185 ss >= ulittle40_t_2;
186 BOOST_VERIFY( ulittle40_t_1 == ulittle40_t_2 );
188 ulittle48_t ulittle48_t_1(0x010203040506LL), ulittle48_t_2;
189 ss <= ulittle48_t_1;
190 ss >= ulittle48_t_2;
191 BOOST_VERIFY( ulittle48_t_1 == ulittle48_t_2 );
193 ulittle56_t ulittle56_t_1(0x01020304050607LL), ulittle56_t_2;
194 ss <= ulittle56_t_1;
195 ss >= ulittle56_t_2;
196 BOOST_VERIFY( ulittle56_t_1 == ulittle56_t_2 );
198 ulittle64_t ulittle64_t_1(0x0102030405060808LL), ulittle64_t_2;
199 ss <= ulittle64_t_1;
200 ss >= ulittle64_t_2;
201 BOOST_VERIFY( ulittle64_t_1 == ulittle64_t_2 );
203 // native tests
205 native8_t native8_t_1(0x01), native8_t_2;
206 ss <= native8_t_1;
207 ss >= native8_t_2;
208 BOOST_VERIFY( native8_t_1 == native8_t_2 );
210 native16_t native16_t_1(0x0102), native16_t_2;
211 ss <= native16_t_1;
212 ss >= native16_t_2;
213 BOOST_VERIFY( native16_t_1 == native16_t_2 );
215 native24_t native24_t_1(0x010203L), native24_t_2;
216 ss <= native24_t_1;
217 ss >= native24_t_2;
218 BOOST_VERIFY( native24_t_1 == native24_t_2 );
220 native32_t native32_t_1(0x01020304L), native32_t_2;
221 ss <= native32_t_1;
222 ss >= native32_t_2;
223 BOOST_VERIFY( native32_t_1 == native32_t_2 );
225 native40_t native40_t_1(0x0102030405LL), native40_t_2;
226 ss <= native40_t_1;
227 ss >= native40_t_2;
228 BOOST_VERIFY( native40_t_1 == native40_t_2 );
230 native48_t native48_t_1(0x010203040506LL), native48_t_2;
231 ss <= native48_t_1;
232 ss >= native48_t_2;
233 BOOST_VERIFY( native48_t_1 == native48_t_2 );
235 native56_t native56_t_1(0x01020304050607LL), native56_t_2;
236 ss <= native56_t_1;
237 ss >= native56_t_2;
238 BOOST_VERIFY( native56_t_1 == native56_t_2 );
240 native64_t native64_t_1(0x0102030405060808LL), native64_t_2;
241 ss <= native64_t_1;
242 ss >= native64_t_2;
243 BOOST_VERIFY( native64_t_1 == native64_t_2 );
245 // unative tests
247 unative8_t unative8_t_1(0x01), unative8_t_2;
248 ss <= unative8_t_1;
249 ss >= unative8_t_2;
250 BOOST_VERIFY( unative8_t_1 == unative8_t_2 );
252 unative16_t unative16_t_1(0x0102), unative16_t_2;
253 ss <= unative16_t_1;
254 ss >= unative16_t_2;
255 BOOST_VERIFY( unative16_t_1 == unative16_t_2 );
257 unative24_t unative24_t_1(0x010203L), unative24_t_2;
258 ss <= unative24_t_1;
259 ss >= unative24_t_2;
260 BOOST_VERIFY( unative24_t_1 == unative24_t_2 );
262 unative32_t unative32_t_1(0x01020304L), unative32_t_2;
263 ss <= unative32_t_1;
264 ss >= unative32_t_2;
265 BOOST_VERIFY( unative32_t_1 == unative32_t_2 );
267 unative40_t unative40_t_1(0x0102030405LL), unative40_t_2;
268 ss <= unative40_t_1;
269 ss >= unative40_t_2;
270 BOOST_VERIFY( unative40_t_1 == unative40_t_2 );
272 unative48_t unative48_t_1(0x010203040506LL), unative48_t_2;
273 ss <= unative48_t_1;
274 ss >= unative48_t_2;
275 BOOST_VERIFY( unative48_t_1 == unative48_t_2 );
277 unative56_t unative56_t_1(0x01020304050607LL), unative56_t_2;
278 ss <= unative56_t_1;
279 ss >= unative56_t_2;
280 BOOST_VERIFY( unative56_t_1 == unative56_t_2 );
282 unative64_t unative64_t_1(0x0102030405060808LL), unative64_t_2;
283 ss <= unative64_t_1;
284 ss >= unative64_t_2;
285 BOOST_VERIFY( unative64_t_1 == unative64_t_2 );
287 cout << errors << " error(s) detected\n";
288 return errors;