Debian Codegraph @

libstdc++-v3/testsuite/tr2/dynamic_bitset/pr115399.cc

raw
1 // { dg-do run { target c++11 } }
2
3 // PR libstdc++/115399
4 // std::tr2::dynamic_bitset shift behaves differently from std::bitset
5
6 #include <tr2/dynamic_bitset>
7 #include <testsuite_hooks.h>
8
9 void
10 test_left_shift()
11 {
12 std::tr2::dynamic_bitset<> b(65);
13 b[0] = 1;
14 auto b2 = b << 64;
15 VERIFY(b2[64] == 1);
16 VERIFY(b2[0] == 0);
17 b <<= 64;
18 VERIFY( b2 == b );
19 }
20
21 void
22 test_right_shift()
23 {
24 std::tr2::dynamic_bitset<> b(65);
25 b[64] = 1;
26 auto b2 = b >> 64;
27 VERIFY(b2[64] == 0);
28 VERIFY(b2[0] == 1);
29 b >>= 64;
30 VERIFY( b2 == b );
31 }
32
33 int main()
34 {
35 test_left_shift();
36 test_right_shift();
37 }