]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc
3 // Copyright (C) 1999-2014 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::wstring::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();
41 sz01
= str01
.size() + 5;
44 VERIFY( sz01
== sz02
);
46 sz01
= str01
.size() - 5;
49 VERIFY( sz01
== sz02
);
51 std::wstring
str05(30, L
'q');
52 std::wstring str06
= str05
;
53 str05
= str06
+ str05
;
54 VERIFY( str05
.capacity() >= str05
.size() );
55 VERIFY( str06
.capacity() >= str06
.size() );
57 // POD types: size, length, max_size, clear(), empty()
61 VERIFY( b01
== true );
63 sz02
= str01
.length();
64 VERIFY( sz01
== sz02
);
67 sz02
= str01
.length();
68 VERIFY( sz01
== sz02
);
70 sz01
= str01
.length();
72 str011
= str01
+ L
"_addendum_";
74 sz02
= str01
.length();
75 VERIFY( sz01
== sz02
);
76 sz02
= str011
.length();
77 VERIFY( sz02
> sz01
);
79 // trickster allocator issues involved with these:
80 std::wstring str3
= L
"8-chars_8-chars_";
81 std::wstring str4
= str3
+ L
"7-chars";
84 sz02
= str01
.max_size();
85 VERIFY( sz02
>= sz01
);
90 VERIFY( b01
== true );
92 VERIFY( sz01
>= sz02
);