1 | // boost integer_mask.hpp test program -------------------------------------// |
---|
2 | |
---|
3 | // (C) Copyright Daryle Walker 2001. |
---|
4 | // Distributed under the Boost Software License, Version 1.0. (See |
---|
5 | // accompanying file LICENSE_1_0.txt or copy at |
---|
6 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | |
---|
8 | // See http://www.boost.org for most recent version including documentation. |
---|
9 | |
---|
10 | // Revision History |
---|
11 | // 23 Sep 2001 Initial version (Daryle Walker) |
---|
12 | |
---|
13 | #define BOOST_INCLUDE_MAIN |
---|
14 | #include <boost/test/test_tools.hpp> // for main |
---|
15 | |
---|
16 | #include <boost/cstdlib.hpp> // for boost::exit_success |
---|
17 | #include <boost/integer/integer_mask.hpp> // for boost::high_bit_mask_t, etc. |
---|
18 | |
---|
19 | #include <iostream> // for std::cout (std::endl indirectly) |
---|
20 | |
---|
21 | |
---|
22 | #define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \ |
---|
23 | (v) >::high_bit == (1ul << (v)) ); |
---|
24 | #define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \ |
---|
25 | (v) >::high_bit_fast == (1ul << (v)) ); |
---|
26 | #define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \ |
---|
27 | PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false) |
---|
28 | |
---|
29 | #define PRIVATE_LOW_BITS_SLOW_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \ |
---|
30 | (v) >::sig_bits == ((1ul << (v)) - 1) ); |
---|
31 | #define PRIVATE_LOW_BITS_FAST_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \ |
---|
32 | (v) >::sig_bits_fast == ((1ul << (v)) - 1) ); |
---|
33 | #define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \ |
---|
34 | PRIVATE_LOW_BITS_FAST_TEST(v); } while (false) |
---|
35 | |
---|
36 | |
---|
37 | int test_main( int, char*[] ) |
---|
38 | { |
---|
39 | using std::cout; |
---|
40 | using std::endl; |
---|
41 | |
---|
42 | cout << "Doing high_bit_mask_t tests." << endl; |
---|
43 | PRIVATE_HIGH_BIT_TEST( 31 ); |
---|
44 | PRIVATE_HIGH_BIT_TEST( 30 ); |
---|
45 | PRIVATE_HIGH_BIT_TEST( 29 ); |
---|
46 | PRIVATE_HIGH_BIT_TEST( 28 ); |
---|
47 | PRIVATE_HIGH_BIT_TEST( 27 ); |
---|
48 | PRIVATE_HIGH_BIT_TEST( 26 ); |
---|
49 | PRIVATE_HIGH_BIT_TEST( 25 ); |
---|
50 | PRIVATE_HIGH_BIT_TEST( 24 ); |
---|
51 | PRIVATE_HIGH_BIT_TEST( 23 ); |
---|
52 | PRIVATE_HIGH_BIT_TEST( 22 ); |
---|
53 | PRIVATE_HIGH_BIT_TEST( 21 ); |
---|
54 | PRIVATE_HIGH_BIT_TEST( 20 ); |
---|
55 | PRIVATE_HIGH_BIT_TEST( 19 ); |
---|
56 | PRIVATE_HIGH_BIT_TEST( 18 ); |
---|
57 | PRIVATE_HIGH_BIT_TEST( 17 ); |
---|
58 | PRIVATE_HIGH_BIT_TEST( 16 ); |
---|
59 | PRIVATE_HIGH_BIT_TEST( 15 ); |
---|
60 | PRIVATE_HIGH_BIT_TEST( 14 ); |
---|
61 | PRIVATE_HIGH_BIT_TEST( 13 ); |
---|
62 | PRIVATE_HIGH_BIT_TEST( 12 ); |
---|
63 | PRIVATE_HIGH_BIT_TEST( 11 ); |
---|
64 | PRIVATE_HIGH_BIT_TEST( 10 ); |
---|
65 | PRIVATE_HIGH_BIT_TEST( 9 ); |
---|
66 | PRIVATE_HIGH_BIT_TEST( 8 ); |
---|
67 | PRIVATE_HIGH_BIT_TEST( 7 ); |
---|
68 | PRIVATE_HIGH_BIT_TEST( 6 ); |
---|
69 | PRIVATE_HIGH_BIT_TEST( 5 ); |
---|
70 | PRIVATE_HIGH_BIT_TEST( 4 ); |
---|
71 | PRIVATE_HIGH_BIT_TEST( 3 ); |
---|
72 | PRIVATE_HIGH_BIT_TEST( 2 ); |
---|
73 | PRIVATE_HIGH_BIT_TEST( 1 ); |
---|
74 | PRIVATE_HIGH_BIT_TEST( 0 ); |
---|
75 | |
---|
76 | cout << "Doing low_bits_mask_t tests." << endl; |
---|
77 | PRIVATE_LOW_BITS_TEST( 32 ); // Undefined behavior? Whoops! |
---|
78 | PRIVATE_LOW_BITS_TEST( 31 ); |
---|
79 | PRIVATE_LOW_BITS_TEST( 30 ); |
---|
80 | PRIVATE_LOW_BITS_TEST( 29 ); |
---|
81 | PRIVATE_LOW_BITS_TEST( 28 ); |
---|
82 | PRIVATE_LOW_BITS_TEST( 27 ); |
---|
83 | PRIVATE_LOW_BITS_TEST( 26 ); |
---|
84 | PRIVATE_LOW_BITS_TEST( 25 ); |
---|
85 | PRIVATE_LOW_BITS_TEST( 24 ); |
---|
86 | PRIVATE_LOW_BITS_TEST( 23 ); |
---|
87 | PRIVATE_LOW_BITS_TEST( 22 ); |
---|
88 | PRIVATE_LOW_BITS_TEST( 21 ); |
---|
89 | PRIVATE_LOW_BITS_TEST( 20 ); |
---|
90 | PRIVATE_LOW_BITS_TEST( 19 ); |
---|
91 | PRIVATE_LOW_BITS_TEST( 18 ); |
---|
92 | PRIVATE_LOW_BITS_TEST( 17 ); |
---|
93 | PRIVATE_LOW_BITS_TEST( 16 ); |
---|
94 | PRIVATE_LOW_BITS_TEST( 15 ); |
---|
95 | PRIVATE_LOW_BITS_TEST( 14 ); |
---|
96 | PRIVATE_LOW_BITS_TEST( 13 ); |
---|
97 | PRIVATE_LOW_BITS_TEST( 12 ); |
---|
98 | PRIVATE_LOW_BITS_TEST( 11 ); |
---|
99 | PRIVATE_LOW_BITS_TEST( 10 ); |
---|
100 | PRIVATE_LOW_BITS_TEST( 9 ); |
---|
101 | PRIVATE_LOW_BITS_TEST( 8 ); |
---|
102 | PRIVATE_LOW_BITS_TEST( 7 ); |
---|
103 | PRIVATE_LOW_BITS_TEST( 6 ); |
---|
104 | PRIVATE_LOW_BITS_TEST( 5 ); |
---|
105 | PRIVATE_LOW_BITS_TEST( 4 ); |
---|
106 | PRIVATE_LOW_BITS_TEST( 3 ); |
---|
107 | PRIVATE_LOW_BITS_TEST( 2 ); |
---|
108 | PRIVATE_LOW_BITS_TEST( 1 ); |
---|
109 | |
---|
110 | return boost::exit_success; |
---|
111 | } |
---|