3 // Copyright (C) 1999, 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.5.2 basic_string::append
25 #include <testsuite_hooks.h>
29 bool test
__attribute__((unused
)) = true;
30 typedef std::wstring::size_type csize_type
;
31 typedef std::wstring::const_reference cref
;
32 typedef std::wstring::reference ref
;
35 const wchar_t str_lit01
[] = L
"point bolivar, texas";
36 const std::wstring
str01(str_lit01
);
37 const std::wstring
str02(L
"corpus, ");
38 const std::wstring str03
;
42 // wstring& append(const wstring&)
45 VERIFY( str05
== L
"corpus, corpus, " );
47 VERIFY( str05
== L
"corpus, corpus, point bolivar, texas" );
49 VERIFY( str05
== L
"corpus, corpus, point bolivar, texas" );
52 VERIFY( str06
== str05
);
55 // wstring& append(const wstring&, size_type pos, size_type n)
60 str06
.append(str03
, csz01
+ 1, 0);
63 catch(std::out_of_range
& fail
) {
72 str06
.append(str01
, csz01
+ 1, 0);
75 catch(std::out_of_range
& fail
) {
83 str05
.append(str01
, 0, std::wstring::npos
);
84 VERIFY( str05
== L
"corpus, point bolivar, texas" );
85 VERIFY( str05
!= str02
);
88 str06
.append(str01
, 15, std::wstring::npos
);
89 VERIFY( str06
== L
"corpus, texas" );
90 VERIFY( str02
!= str06
);
93 // wstring& append(const wchar_t* s)
97 VERIFY( str05
== str03
);
99 str05
.append(str_lit01
);
100 VERIFY( str05
== str01
);
103 str06
.append(L
"corpus, ");
104 VERIFY( str06
== L
"corpus, corpus, " );
107 // wstring& append(const wchar_t* s, size_type n)
110 str05
.append(L
"", 0);
111 VERIFY( str05
.size() == 0 );
112 VERIFY( str05
== str03
);
114 str05
.append(str_lit01
, sizeof(str_lit01
) / sizeof(wchar_t) - 1);
115 VERIFY( str05
== str01
);
118 str06
.append(L
"corpus, ", 6);
119 VERIFY( str06
== L
"corpus, corpus" );
122 str06
.append(L
"corpus, ", 12);
123 VERIFY( str06
!= L
"corpus, corpus, " );
126 // wstring& append(size_type n, char c)
129 str05
.append(0, L
'a');
130 VERIFY( str05
== str03
);
131 str06
.append(8, L
'.');
132 VERIFY( str06
== L
"........" );
135 // template<typename InputIter>
136 // wstring& append(InputIter first, InputIter last)
139 str05
.append(str03
.begin(), str03
.end());
140 VERIFY( str05
== str03
);
143 str06
.append(str01
.begin(), str01
.begin() + str01
.find(L
'r'));
144 VERIFY( str06
== L
"corpus, point boliva" );
145 VERIFY( str06
!= str01
);
146 VERIFY( str06
!= str02
);
149 str05
.append(str05
.begin(), str05
.begin() + str05
.find(L
'r'));
150 VERIFY( str05
== L
"point bolivar, texaspoint boliva" );
151 VERIFY( str05
!= str01
);