]>
Commit | Line | Data |
---|---|---|
8d9254fc | 1 | // Copyright (C) 2018-2020 Free Software Foundation, Inc. |
c397f267 JW |
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. | |
8 | ||
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. | |
13 | ||
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/>. | |
17 | ||
18 | // { dg-do run { target c++11 } } | |
19 | ||
20 | #include <tr2/dynamic_bitset> | |
21 | #include <testsuite_hooks.h> | |
22 | ||
23 | void | |
24 | test01() | |
25 | { | |
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() ); | |
35 | ||
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 ); | |
45 | ||
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 ); | |
58 | ||
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 ); | |
70 | } | |
71 | ||
72 | int | |
73 | main() | |
74 | { | |
75 | test01(); | |
76 | } |