Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / testsuite / 21_strings / basic_string / operators / char / 3.cc
blob6bd573fe31d8b0989abf302668784f5a09b203f5
1 // 2010-12-17 Paolo Carlini <paolo.carlini@oracle.com>
2 //
3 // Copyright (C) 2010 Free Software Foundation, Inc.
4 //
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)
9 // any later version.
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 // { dg-options "-std=gnu++0x" }
21 // { dg-require-string-conversions "" }
23 #include <string>
24 #include <testsuite_hooks.h>
26 void test01()
28 bool test __attribute__((unused)) = true;
29 using std::string;
31 VERIFY( (string("abc") + string("def")
32 == string("abcdef")) );
33 string s1("abc");
34 VERIFY( s1 + string("def") == string("abcdef") );
35 string s2("def");
36 VERIFY( string("abc") + s2 == string("abcdef") );
37 VERIFY( string("abc") + 'd' == string("abcd") );
38 VERIFY( string("abc") + "def" == string("abcdef") );
39 VERIFY( 'a' + string("bcd") == string("abcd") );
40 VERIFY( "abc" + string("def") == string("abcdef") );
42 VERIFY( (string("abcdefghij") + string("klmnopqrst")
43 == string("abcdefghijklmnopqrst")) );
44 string s1l("abcdefghij");
45 VERIFY( (s1l + string("klmnopqrst")
46 == string("abcdefghijklmnopqrst")) );
47 string s2l("klmnopqrst");
48 VERIFY( (string("abcdefghij") + s2l
49 == string("abcdefghijklmnopqrst")) );
50 VERIFY( (string("abcdefghijklmno") + 'p'
51 == string("abcdefghijklmnop")) );
52 VERIFY( (string("abcdefghijklmno") + "pqrst"
53 == string("abcdefghijklmnopqrst")) );
54 VERIFY( ('a' + string("bcdefghijklmnop")
55 == string("abcdefghijklmnop")) );
56 VERIFY( ("abcde" + string("fghijklmnopqrst")
57 == string("abcdefghijklmnopqrst")) );
59 VERIFY( (string("abcdefghijklmnopqrst") + string("uvwxy")
60 == string("abcdefghijklmnopqrstuvwxy")) );
61 VERIFY( (string("abcde") + string("fghijklmnopqrstuvwxy")
62 == string("abcdefghijklmnopqrstuvwxy")) );
63 string s1ll1("abcdefghijklmnopqrst");
64 VERIFY( (s1ll1 + string("uvwxy")
65 == string("abcdefghijklmnopqrstuvwxy")) );
66 string s1ll2("abcde");
67 VERIFY( (s1ll2 + string("fghijklmnopqrstuvwxy")
68 == string("abcdefghijklmnopqrstuvwxy")) );
69 string s2ll1("fghijklmnopqrstuvwxy");
70 VERIFY( (string("abcde") + s2ll1
71 == string("abcdefghijklmnopqrstuvwxy")) );
72 string s2ll2("uvwxy");
73 VERIFY( (string("abcdefghijklmnopqrst") + s2ll2
74 == string("abcdefghijklmnopqrstuvwxy")) );
75 VERIFY( (string("abcdefghijklmnopqrst") + 'u'
76 == string("abcdefghijklmnopqrstu")) );
77 VERIFY( (string("abcdefghijklmnopqrst") + "uvwxy"
78 == string("abcdefghijklmnopqrstuvwxy")) );
79 VERIFY( (string("abcde") + "fghijklmnopqrstuvwxy"
80 == string("abcdefghijklmnopqrstuvwxy")) );
81 VERIFY( ('a' + string("bcdefghijklmnopqrstuvwxy")
82 == string("abcdefghijklmnopqrstuvwxy")) );
83 VERIFY( ("abcde" + string("fghijklmnopqrstuvwxy")
84 == string("abcdefghijklmnopqrstuvwxy")) );
85 VERIFY( ("abcdefghijklmnopqrst" + string("uvwxy")
86 == string("abcdefghijklmnopqrstuvwxy")) );
89 int main()
91 test01();
92 return 0;