Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/test/bitwise.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.6 KB
Line 
1
2// Copyright Aleksey Gurtovoy 2003-2004
3// Copyright Jaap Suter 2003
4//
5// Distributed under the Boost Software License,Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9// See http://www.boost.org/libs/mpl for documentation.
10
11// $Source: /cvsroot/boost/boost/libs/mpl/test/bitwise.cpp,v $
12// $Date: 2004/09/02 15:41:35 $
13// $Revision: 1.2 $
14
15#include <boost/mpl/bitwise.hpp>
16#include <boost/mpl/integral_c.hpp>
17#include <boost/mpl/aux_/test.hpp>
18
19typedef integral_c<unsigned int, 0> _0;
20typedef integral_c<unsigned int, 1> _1;
21typedef integral_c<unsigned int, 2> _2;
22typedef integral_c<unsigned int, 8> _8;
23typedef integral_c<unsigned int, 0xffffffff> _ffffffff;
24
25MPL_TEST_CASE()
26{
27    MPL_ASSERT_RELATION( (bitand_<_0,_0>::value), ==, 0 );
28    MPL_ASSERT_RELATION( (bitand_<_1,_0>::value), ==, 0 );
29    MPL_ASSERT_RELATION( (bitand_<_0,_1>::value), ==, 0 );
30    MPL_ASSERT_RELATION( (bitand_<_0,_ffffffff>::value), ==, 0 );
31    MPL_ASSERT_RELATION( (bitand_<_1,_ffffffff>::value), ==, 1 );
32    MPL_ASSERT_RELATION( (bitand_<_8,_ffffffff>::value), ==, 8 );
33}
34
35MPL_TEST_CASE()
36{
37    MPL_ASSERT_RELATION( (bitor_<_0,_0>::value), ==, 0 );
38    MPL_ASSERT_RELATION( (bitor_<_1,_0>::value), ==, 1 );
39    MPL_ASSERT_RELATION( (bitor_<_0,_1>::value), ==, 1 );
40    MPL_ASSERT_RELATION( (bitor_<_0,_ffffffff>::value), ==, 0xffffffff );
41    MPL_ASSERT_RELATION( (bitor_<_1,_ffffffff>::value), ==, 0xffffffff );
42    MPL_ASSERT_RELATION( (bitor_<_8,_ffffffff>::value), ==, 0xffffffff );
43}
44
45MPL_TEST_CASE()
46{
47    MPL_ASSERT_RELATION( (bitxor_<_0,_0>::value), ==, 0 );
48    MPL_ASSERT_RELATION( (bitxor_<_1,_0>::value), ==, 1 );
49    MPL_ASSERT_RELATION( (bitxor_<_0,_1>::value), ==, 1 );
50    MPL_ASSERT_RELATION( (bitxor_<_0,_ffffffff>::value), ==, (0xffffffff ^ 0) );
51    MPL_ASSERT_RELATION( (bitxor_<_1,_ffffffff>::value), ==, (0xffffffff ^ 1) );
52    MPL_ASSERT_RELATION( (bitxor_<_8,_ffffffff>::value), ==, (0xffffffff ^ 8) );
53}
54
55MPL_TEST_CASE()
56{
57    MPL_ASSERT_RELATION( (shift_right<_0,_0>::value), ==, 0 );
58    MPL_ASSERT_RELATION( (shift_right<_1,_0>::value), ==, 1 );
59    MPL_ASSERT_RELATION( (shift_right<_1,_1>::value), ==, 0 );
60    MPL_ASSERT_RELATION( (shift_right<_2,_1>::value), ==, 1 );
61    MPL_ASSERT_RELATION( (shift_right<_8,_1>::value), ==, 4 );
62}
63
64MPL_TEST_CASE()
65{
66    MPL_ASSERT_RELATION( (shift_left<_0,_0>::value), ==, 0 );
67    MPL_ASSERT_RELATION( (shift_left<_1,_0>::value), ==, 1 );
68    MPL_ASSERT_RELATION( (shift_left<_1,_1>::value), ==, 2 );
69    MPL_ASSERT_RELATION( (shift_left<_2,_1>::value), ==, 4 );
70    MPL_ASSERT_RELATION( (shift_left<_8,_1>::value), ==, 16 );
71}
Note: See TracBrowser for help on using the repository browser.