aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@unitus.it>2001-12-16 02:02:17 +0100
committerPaolo Carlini <paolo@gcc.gnu.org>2001-12-16 01:02:17 +0000
commitbd1f473825af96053542ff6d3ac518a77c95b4af (patch)
tree712f37fa4aadfa8e07f17a38c0faf08ecd8f3174 /libstdc++-v3/testsuite
parent226ada7a41dba4d02def08367ed1b66199d6e472 (diff)
downloadgcc-bd1f473825af96053542ff6d3ac518a77c95b4af.zip
gcc-bd1f473825af96053542ff6d3ac518a77c95b4af.tar.gz
gcc-bd1f473825af96053542ff6d3ac518a77c95b4af.tar.bz2
2001-12-15 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org> * include/bits/basic_string.h (assign(__str, __pos, __n), assign(__s, __n)): Optimize by avoiding unnecessary temporaries. (assign(__s)): Call assign(__s, __n). * include/bits/basic_string.tcc (_M_replace_safe): Adjust comment. * include/bits/std_string.h: include stl_function.h. * testsuite/21_strings/assign.cc (test02, test03): New tests. Co-Authored-By: Nathan Myers <ncm@cantrip.org> From-SVN: r48053
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/21_strings/assign.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/21_strings/assign.cc b/libstdc++-v3/testsuite/21_strings/assign.cc
index 271ef65..1d7db1c 100644
--- a/libstdc++-v3/testsuite/21_strings/assign.cc
+++ b/libstdc++-v3/testsuite/21_strings/assign.cc
@@ -39,8 +39,71 @@ test01()
VERIFY(aux == "Hawaii");
}
+// assign(const basic_string& __str, size_type __pos, size_type __n)
+void
+test02()
+{
+ bool test = true;
+
+ using namespace std;
+
+ string one = "Selling England by the pound";
+ string two = one;
+ string three = "Brilliant trees";
+
+ one.assign(one, 8, 100);
+ VERIFY( one == "England by the pound" );
+
+ one.assign(one, 8, 0);
+ VERIFY( one == "" );
+
+ one.assign(two, 8, 7);
+ VERIFY( one == "England" );
+
+ one.assign(three, 10, 100);
+ VERIFY( one == "trees" );
+
+ three.assign(one, 0, 3);
+ VERIFY( three == "tre" );
+}
+
+// assign(const _CharT* __s, size_type __n)
+// assign(const _CharT* __s)
+void
+test03()
+{
+ bool test = true;
+
+ using namespace std;
+
+ string one;
+ string two;
+ string three = two;
+ const char * source = "Selling England by the pound";
+
+ one.assign(source);
+ VERIFY( one == "Selling England by the pound" );
+
+ one.assign(source, 28);
+ VERIFY( one == "Selling England by the pound" );
+
+ two.assign(source, 7);
+ VERIFY( two == "Selling" );
+
+ one.assign(one.c_str() + 8, 20);
+ VERIFY( one == "England by the pound" );
+
+ one.assign(one.c_str() + 8, 6);
+ VERIFY( one == "by the" );
+}
+
+
+
int main()
{
test01();
+ test02();
+ test03();
+
return 0;
}