]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc
3 // Copyright (C) 1999-2016 Free Software Foundation, Inc.
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
8 // Free Software Foundation; either version 3, or (at your option)
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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 21.3.3 string capacity
23 #include <testsuite_hooks.h>
27 // POD types : resize, capacity, reserve
28 bool test
__attribute__((unused
)) = true;
30 typedef std::string::size_type size_type_s
;
32 size_type_s sz01
= str01
.capacity();
34 size_type_s sz02
= str01
.capacity();
35 VERIFY( sz02
>= sz01
);
36 VERIFY( sz02
>= 100 );
38 sz01
= str01
.capacity();
39 #if _GLIBCXX_USE_CXX11_ABI
45 sz01
= str01
.size() + 5;
48 VERIFY( sz01
== sz02
);
50 sz01
= str01
.size() - 5;
53 VERIFY( sz01
== sz02
);
55 std::string
str05(30, 'q');
56 std::string str06
= str05
;
57 str05
= str06
+ str05
;
58 VERIFY( str05
.capacity() >= str05
.size() );
59 VERIFY( str06
.capacity() >= str06
.size() );
61 // POD types: size, length, max_size, clear(), empty()
65 VERIFY( b01
== true );
67 sz02
= str01
.length();
68 VERIFY( sz01
== sz02
);
71 sz02
= str01
.length();
72 VERIFY( sz01
== sz02
);
74 sz01
= str01
.length();
76 str011
= str01
+ "_addendum_";
78 sz02
= str01
.length();
79 VERIFY( sz01
== sz02
);
80 sz02
= str011
.length();
81 VERIFY( sz02
> sz01
);
83 // trickster allocator issues involved with these:
84 std::string str3
= "8-chars_8-chars_";
85 std::string str4
= str3
+ "7-chars";
88 sz02
= str01
.max_size();
89 VERIFY( sz02
>= sz01
);
94 VERIFY( b01
== true );
96 VERIFY( sz01
>= sz02
);