PR libstdc++/87784 fix dynamic_bitset::push_back
[official-gcc.git] / libstdc++-v3 / testsuite / tr2 / dynamic_bitset / pr87784.cc
blob52dc3893a310133424cd3d2382c236a433635746
1 // Copyright (C) 2018 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target c++11 } }
20 #include <tr2/dynamic_bitset>
21 #include <testsuite_hooks.h>
23 void
24 test01()
26 std::tr2::dynamic_bitset<unsigned> b;
27 VERIFY( b.size() == 0 );
28 VERIFY( b.find_first() == b.size() );
29 b.push_back(0);
30 VERIFY( b.size() == 1 );
31 VERIFY( b.find_first() == b.size() );
32 b.push_back(0);
33 VERIFY( b.size() == 2 );
34 VERIFY( b.find_first() == b.size() );
36 b.push_back(1);
37 VERIFY( b.size() == 3 );
38 VERIFY( b.find_first() == b.size() - 1 );
39 b.push_back(1);
40 VERIFY( b.size() == 4 );
41 VERIFY( b.find_first() == b.size() - 2 );
42 b.push_back(0);
43 VERIFY( b.size() == 5 );
44 VERIFY( b.find_first() == b.size() - 3 );
46 b.clear();
47 VERIFY( b.size() == 0 );
48 VERIFY( b.find_first() == b.size() );
49 b.push_back(1);
50 VERIFY( b.size() == 1 );
51 VERIFY( b.find_first() == 0 );
52 b.push_back(1);
53 VERIFY( b.size() == 2 );
54 VERIFY( b.find_first() == 0 );
55 b.push_back(1);
56 VERIFY( b.size() == 3 );
57 VERIFY( b.find_first() == 0 );
59 b.clear();
60 b.append(2u);
61 VERIFY( b.size() == b.bits_per_block );
62 VERIFY( b.find_first() == 1 );
63 b <<= 1;
64 VERIFY( b.find_first() == 2 );
65 b <<= 3;
66 VERIFY( b.find_first() == 5 );
67 b <<= 6;
68 VERIFY( b.find_first() == 11 );
69 VERIFY( b.size() == b.bits_per_block );
72 int
73 main()
75 test01();