]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc
3 // Copyright (C) 1999-2017 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
29 typedef std::string::size_type size_type_s
;
31 size_type_s sz01
= str01
.capacity();
33 size_type_s sz02
= str01
.capacity();
34 VERIFY( sz02
>= sz01
);
35 VERIFY( sz02
>= 100 );
37 sz01
= str01
.capacity();
38 #if _GLIBCXX_USE_CXX11_ABI
44 sz01
= str01
.size() + 5;
47 VERIFY( sz01
== sz02
);
49 sz01
= str01
.size() - 5;
52 VERIFY( sz01
== sz02
);
54 std::string
str05(30, 'q');
55 std::string str06
= str05
;
56 str05
= str06
+ str05
;
57 VERIFY( str05
.capacity() >= str05
.size() );
58 VERIFY( str06
.capacity() >= str06
.size() );
60 // POD types: size, length, max_size, clear(), empty()
64 VERIFY( b01
== true );
66 sz02
= str01
.length();
67 VERIFY( sz01
== sz02
);
70 sz02
= str01
.length();
71 VERIFY( sz01
== sz02
);
73 sz01
= str01
.length();
75 str011
= str01
+ "_addendum_";
77 sz02
= str01
.length();
78 VERIFY( sz01
== sz02
);
79 sz02
= str011
.length();
80 VERIFY( sz02
> sz01
);
82 // trickster allocator issues involved with these:
83 std::string str3
= "8-chars_8-chars_";
84 std::string str4
= str3
+ "7-chars";
87 sz02
= str01
.max_size();
88 VERIFY( sz02
>= sz01
);
93 VERIFY( b01
== true );
95 VERIFY( sz01
>= sz02
);