]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/21_strings/basic_string/operators/char/3.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 21_strings / basic_string / operators / char / 3.cc
CommitLineData
5596bcf9 1// 2010-12-17 Paolo Carlini <paolo.carlini@oracle.com>
2//
fbd26352 3// Copyright (C) 2010-2019 Free Software Foundation, Inc.
5596bcf9 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.
10//
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.
15//
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/>.
19//
be58e01d 20// { dg-do run { target c++11 } }
5596bcf9 21// { dg-require-string-conversions "" }
22
23#include <string>
24#include <testsuite_hooks.h>
25
26void test01()
27{
5596bcf9 28 using std::string;
29
30 VERIFY( (string("abc") + string("def")
31 == string("abcdef")) );
32 string s1("abc");
33 VERIFY( s1 + string("def") == string("abcdef") );
34 string s2("def");
35 VERIFY( string("abc") + s2 == string("abcdef") );
36 VERIFY( string("abc") + 'd' == string("abcd") );
37 VERIFY( string("abc") + "def" == string("abcdef") );
38 VERIFY( 'a' + string("bcd") == string("abcd") );
39 VERIFY( "abc" + string("def") == string("abcdef") );
40
41 VERIFY( (string("abcdefghij") + string("klmnopqrst")
42 == string("abcdefghijklmnopqrst")) );
43 string s1l("abcdefghij");
44 VERIFY( (s1l + string("klmnopqrst")
45 == string("abcdefghijklmnopqrst")) );
46 string s2l("klmnopqrst");
47 VERIFY( (string("abcdefghij") + s2l
48 == string("abcdefghijklmnopqrst")) );
49 VERIFY( (string("abcdefghijklmno") + 'p'
50 == string("abcdefghijklmnop")) );
51 VERIFY( (string("abcdefghijklmno") + "pqrst"
52 == string("abcdefghijklmnopqrst")) );
53 VERIFY( ('a' + string("bcdefghijklmnop")
54 == string("abcdefghijklmnop")) );
55 VERIFY( ("abcde" + string("fghijklmnopqrst")
56 == string("abcdefghijklmnopqrst")) );
57
58 VERIFY( (string("abcdefghijklmnopqrst") + string("uvwxy")
59 == string("abcdefghijklmnopqrstuvwxy")) );
60 VERIFY( (string("abcde") + string("fghijklmnopqrstuvwxy")
61 == string("abcdefghijklmnopqrstuvwxy")) );
62 string s1ll1("abcdefghijklmnopqrst");
63 VERIFY( (s1ll1 + string("uvwxy")
64 == string("abcdefghijklmnopqrstuvwxy")) );
65 string s1ll2("abcde");
66 VERIFY( (s1ll2 + string("fghijklmnopqrstuvwxy")
67 == string("abcdefghijklmnopqrstuvwxy")) );
68 string s2ll1("fghijklmnopqrstuvwxy");
69 VERIFY( (string("abcde") + s2ll1
70 == string("abcdefghijklmnopqrstuvwxy")) );
71 string s2ll2("uvwxy");
72 VERIFY( (string("abcdefghijklmnopqrst") + s2ll2
73 == string("abcdefghijklmnopqrstuvwxy")) );
74 VERIFY( (string("abcdefghijklmnopqrst") + 'u'
75 == string("abcdefghijklmnopqrstu")) );
76 VERIFY( (string("abcdefghijklmnopqrst") + "uvwxy"
77 == string("abcdefghijklmnopqrstuvwxy")) );
78 VERIFY( (string("abcde") + "fghijklmnopqrstuvwxy"
79 == string("abcdefghijklmnopqrstuvwxy")) );
80 VERIFY( ('a' + string("bcdefghijklmnopqrstuvwxy")
81 == string("abcdefghijklmnopqrstuvwxy")) );
82 VERIFY( ("abcde" + string("fghijklmnopqrstuvwxy")
83 == string("abcdefghijklmnopqrstuvwxy")) );
84 VERIFY( ("abcdefghijklmnopqrst" + string("uvwxy")
85 == string("abcdefghijklmnopqrstuvwxy")) );
86}
87
88int main()
89{
90 test01();
91 return 0;
92}