]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/operator_plus.cc
1 // 2019-04-30 Nina Dinka Ranns <dinka.ranns@gmail.com>
2 // Copyright (C) 2019 Free Software Foundation, Inc.
4 // This file is part of the GNU ISO C++ Library. This library is free
5 // software; you can redistribute it and/or modify it under the
6 // terms of the GNU General Public License as published by the
7 // Free Software Foundation; either version 3, or (at your option)
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this library; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
19 // { dg-do run { target c++11 } }
20 // COW strings don't support C++11 allocators:
21 // { dg-require-effective-target cxx11-abi }
24 #include <testsuite_hooks.h>
25 #include <testsuite_allocator.h>
26 #include <ext/throw_allocator.h>
29 using traits
= std::char_traits
<C
>;
31 using __gnu_test::propagating_allocator
;
35 typedef propagating_allocator
<C
, true> alloc_type
;
36 typedef std::basic_string
<C
, traits
, alloc_type
> test_type
;
38 test_type
v1(L
"something",alloc_type(1));
39 test_type
v2(L
"something",alloc_type(2));
41 VERIFY(r1
.get_allocator().get_personality() == 1);
43 auto r2
= v1
+ std::move(v2
);
44 VERIFY(r2
.get_allocator().get_personality() == 2);
46 test_type
v3(L
"something", alloc_type(3));
47 test_type
v4(L
"something", alloc_type(4));
48 auto r3
= std::move(v3
) + v4
;
49 VERIFY(r3
.get_allocator().get_personality() == 3);
51 auto r4
= std::move(v1
) +std::move(v4
);
52 VERIFY(r4
.get_allocator().get_personality() == 1);
54 test_type
v5(L
"something", alloc_type(5));
55 auto r5
= v5
+ L
"str";
56 VERIFY(r5
.get_allocator().get_personality() == 5);
59 VERIFY(r6
.get_allocator().get_personality() == 5);
61 auto r7
= std::move(v5
) + L
"str";
62 VERIFY(r7
.get_allocator().get_personality() == 5);
64 test_type
v6(L
"something", alloc_type(6));
65 auto r8
= std::move(v6
) + L
'c';
66 VERIFY(r8
.get_allocator().get_personality() == 6);
68 test_type
v7(L
"something", alloc_type(7));
69 auto r9
= L
"str" + v7
;
70 VERIFY(r9
.get_allocator().get_personality() == 7);
73 VERIFY(r10
.get_allocator().get_personality() == 7);
75 auto r11
= L
"str" + std::move(v7
);
76 VERIFY(r11
.get_allocator().get_personality() == 7);
78 test_type
v8(L
"something", alloc_type(8));
79 auto r12
= L
'c' + std::move(v8
);
80 VERIFY(r12
.get_allocator().get_personality() == 8);
85 typedef propagating_allocator
<C
, false> alloc_type
;
86 typedef std::basic_string
<C
, traits
, alloc_type
> test_type
;
88 test_type
v1(L
"something",alloc_type(1));
89 test_type
v2(L
"something",alloc_type(2));
91 VERIFY(r1
.get_allocator().get_personality() != 1);
93 auto r2
= v1
+ std::move(v2
);
94 VERIFY(r2
.get_allocator().get_personality() == 2);
96 test_type
v3(L
"something", alloc_type(3));
97 test_type
v4(L
"something", alloc_type(4));
98 auto r3
= std::move(v3
) + v4
;
99 VERIFY(r3
.get_allocator().get_personality() == 3);
101 auto r4
= std::move(v1
) +std::move(v4
);
102 VERIFY(r4
.get_allocator().get_personality() == 1);
104 test_type
v5(L
"something", alloc_type(5));
105 auto r5
= v5
+ L
"str";
106 VERIFY(r5
.get_allocator().get_personality() != 5);
109 VERIFY(r6
.get_allocator().get_personality() != 5);
111 auto r7
= std::move(v5
) + L
"str";
112 VERIFY(r7
.get_allocator().get_personality() == 5);
114 test_type
v6(L
"something", alloc_type(6));
115 auto r8
= std::move(v6
) + L
'c';
116 VERIFY(r8
.get_allocator().get_personality() == 6);
118 test_type
v7(L
"something", alloc_type(7));
119 auto r9
= L
"str" + v7
;
120 VERIFY(r9
.get_allocator().get_personality() != 7);
122 auto r10
= L
'c' + v7
;
123 VERIFY(r10
.get_allocator().get_personality() != 7);
125 auto r11
= L
"str" + std::move(v7
);
126 VERIFY(r11
.get_allocator().get_personality() == 7);
128 test_type
v8(L
"something", alloc_type(8));
129 auto r12
= L
'c' + std::move(v8
);
130 VERIFY(r12
.get_allocator().get_personality() == 8);
134 typedef propagating_allocator
<C
, false> alloc_type
;
135 typedef std::basic_string
<C
, traits
, alloc_type
> test_type
;
137 test_type
v1(L
"s",alloc_type(1));
140 test_type
v2(10000,L
'x',alloc_type(2));
143 auto r
=std::move(v1
)+std::move(v2
);
144 VERIFY(r
.get_allocator().get_personality() == 1);