3 // Copyright (C) 1999, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // 21.3.3 string capacity
24 #include <testsuite_hooks.h>
28 // POD types : resize, capacity, reserve
29 bool test
__attribute__((unused
)) = true;
31 typedef std::string::size_type size_type_s
;
33 size_type_s sz01
= str01
.capacity();
35 size_type_s sz02
= str01
.capacity();
36 VERIFY( sz02
>= sz01
);
37 VERIFY( sz02
>= 100 );
39 sz01
= str01
.capacity();
42 sz01
= str01
.size() + 5;
45 VERIFY( sz01
== sz02
);
47 sz01
= str01
.size() - 5;
50 VERIFY( sz01
== sz02
);
52 std::string
str05(30, 'q');
53 std::string str06
= str05
;
54 str05
= str06
+ str05
;
55 VERIFY( str05
.capacity() >= str05
.size() );
56 VERIFY( str06
.capacity() >= str06
.size() );
58 // POD types: size, length, max_size, clear(), empty()
62 VERIFY( b01
== true );
64 sz02
= str01
.length();
65 VERIFY( sz01
== sz02
);
68 sz02
= str01
.length();
69 VERIFY( sz01
== sz02
);
71 sz01
= str01
.length();
73 str011
= str01
+ "_addendum_";
75 sz02
= str01
.length();
76 VERIFY( sz01
== sz02
);
77 sz02
= str011
.length();
78 VERIFY( sz02
> sz01
);
80 // trickster allocator issues involved with these:
81 std::string str3
= "8-chars_8-chars_";
82 std::string str4
= str3
+ "7-chars";
85 sz02
= str01
.max_size();
86 VERIFY( sz02
>= sz01
);
91 VERIFY( b01
== true );
93 VERIFY( sz01
>= sz02
);