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