]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/vector/bool/capacity/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / vector / bool / capacity / 1.cc
CommitLineData
15ecde8e
PC
1// 2006-08-05 Paolo Carlini <pcarlini@suse.de>
2
a5544970 3// Copyright (C) 2006-2019 Free Software Foundation, Inc.
15ecde8e
PC
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
15ecde8e
PC
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
15ecde8e
PC
19
20// 23.2.5 vector<bool> resize
21
22#include <vector>
23#include <testsuite_hooks.h>
24
25const bool A1[] = {0};
26const bool A2[] = {0, 0, 0};
27const bool A3[] = {0, 0};
28const bool A4[] = {0, 0, 1, 1, 1, 1, 1};
29const bool A5[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
30const bool A6[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
32 1, 1, 1, 1};
33const bool A7[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
35 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36 0, 0, 0, 0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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
56 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
57 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
58 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
59 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
60 1, 1};
61const bool A11[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
62
63const unsigned N1 = sizeof(A1) / sizeof(bool);
64const unsigned N2 = sizeof(A2) / sizeof(bool);
65const unsigned N3 = sizeof(A3) / sizeof(bool);
66const unsigned N4 = sizeof(A4) / sizeof(bool);
67const unsigned N5 = sizeof(A5) / sizeof(bool);
68const unsigned N6 = sizeof(A6) / sizeof(bool);
69const unsigned N7 = sizeof(A7) / sizeof(bool);
70const unsigned N8 = sizeof(A8) / sizeof(bool);
71const unsigned N9 = sizeof(A9) / sizeof(bool);
72const unsigned N10 = sizeof(A10) / sizeof(bool);
73const unsigned N11 = sizeof(A11) / sizeof(bool);
74
75void
76test01()
77{
15ecde8e
PC
78 typedef std::vector<bool> vec_type;
79
80 vec_type v;
81
82 v.resize(1);
83 VERIFY( v.size() == 1 );
84 VERIFY( std::equal(v.begin(), v.end(), A1) );
85
86 v.resize(3);
87 VERIFY( v.size() == 3 );
88 VERIFY( std::equal(v.begin(), v.end(), A2) );
89
90 v.resize(2);
91 VERIFY( v.size() == 2 );
92 VERIFY( std::equal(v.begin(), v.end(), A3) );
93
94 v.resize(7, true);
95 VERIFY( v.size() == 7 );
96 VERIFY( std::equal(v.begin(), v.end(), A4) );
97
98 v.resize(18, false);
99 VERIFY( v.size() == 18 );
100 VERIFY( std::equal(v.begin(), v.end(), A5) );
101
102 v.resize(40, true);
103 VERIFY( v.size() == 40 );
104 VERIFY( std::equal(v.begin(), v.end(), A6) );
105
106 v.resize(80, false);
107 VERIFY( v.size() == 80 );
108 VERIFY( std::equal(v.begin(), v.end(), A7) );
109
110 v.resize(90, true);
111 VERIFY( v.size() == 90 );
112 VERIFY( std::equal(v.begin(), v.end(), A8) );
113
114 v.resize(100, false);
115 VERIFY( v.size() == 100 );
116 VERIFY( std::equal(v.begin(), v.end(), A9) );
117
118 v.resize(200, true);
119 VERIFY( v.size() == 200 );
120 VERIFY( std::equal(v.begin(), v.end(), A10) );
121
122 v.resize(13, true);
123 VERIFY( v.size() == 13 );
124 VERIFY( std::equal(v.begin(), v.end(), A11) );
125
126 v.resize(13, false);
127 VERIFY( v.size() == 13 );
128 VERIFY( std::equal(v.begin(), v.end(), A11) );
129}
130
131int main()
132{
133 test01();
134 return 0;
135}