| 1 | // 2010-12-19 Paolo Carlini <[email protected]> |
| 2 | // |
| 3 | // Copyright (C) 2010-2025 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-do run { target c++11 } } |
| 21 | // { dg-require-string-conversions "" } |
| 22 | |
| 23 | #include <string> |
| 24 | #include <testsuite_hooks.h> |
| 25 | |
| 26 | void test01() |
| 27 | { |
| 28 | using std::wstring; |
| 29 | using std::move; |
| 30 | |
| 31 | wstring s01(L"abc"); |
| 32 | s01.reserve(30); |
| 33 | wstring s02(L"def"); |
| 34 | s02.reserve(30); |
| 35 | VERIFY( move(s01) + move(s02) == wstring(L"abcdef") ); |
| 36 | |
| 37 | wstring s03(L"abcdefghijklmnopqrstuvw"); |
| 38 | wstring s04(L"xyz"); |
| 39 | s04.reserve(30); |
| 40 | VERIFY( move(s03) + move(s04) == wstring(L"abcdefghijklmnopqrstuvwxyz") ); |
| 41 | |
| 42 | wstring s05(L"abc"); |
| 43 | s05.reserve(30); |
| 44 | wstring s06(L"defghijklmnopqrstuvwxyz"); |
| 45 | VERIFY( move(s05) + move(s06) == wstring(L"abcdefghijklmnopqrstuvwxyz") ); |
| 46 | |
| 47 | const wstring sc1(L"abc"); |
| 48 | wstring s07(L"def"); |
| 49 | s07.reserve(30); |
| 50 | VERIFY( sc1 + move(s07) == wstring(L"abcdef") ); |
| 51 | |
| 52 | const wstring sc2(L"def"); |
| 53 | wstring s08(L"abc"); |
| 54 | s08.reserve(30); |
| 55 | VERIFY( move(s08) + sc2 == wstring(L"abcdef") ); |
| 56 | |
| 57 | wstring s09(L"abc"); |
| 58 | s09.reserve(30); |
| 59 | VERIFY( move(s09) + L'd' == wstring(L"abcd") ); |
| 60 | |
| 61 | wstring s10(L"abc"); |
| 62 | s10.reserve(30); |
| 63 | VERIFY( move(s10) + L"def" == wstring(L"abcdef") ); |
| 64 | |
| 65 | wstring s11(L"bcd"); |
| 66 | s11.reserve(30); |
| 67 | VERIFY( L'a' + move(s11) == wstring(L"abcd") ); |
| 68 | |
| 69 | wstring s12(L"def"); |
| 70 | s12.reserve(30); |
| 71 | VERIFY( L"abc" + move(s12) == wstring(L"abcdef") ); |
| 72 | } |
| 73 | |
| 74 | int main() |
| 75 | { |
| 76 | test01(); |
| 77 | return 0; |
| 78 | } |