]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do run { target c++14 } } |
83ac9249 | 2 | |
83ffe9cd | 3 | // Copyright (C) 2013-2023 Free Software Foundation, Inc. |
83ac9249 ESR |
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 | ||
7db54ccd | 20 | // C++14 27.7.6 - Quoted manipulators [quoted.manip] |
83ac9249 ESR |
21 | |
22 | #include <string> | |
23 | #include <sstream> | |
24 | #include <iomanip> | |
25 | #include <testsuite_hooks.h> | |
26 | ||
27 | void | |
28 | test01() | |
29 | { | |
30 | // Basic test from paper. | |
83ac9249 ESR |
31 | std::wstringstream ss; |
32 | std::wstring original = L"foolish me"; | |
33 | std::wstring round_trip; | |
34 | ss << std::quoted(original); | |
35 | ss >> std::quoted(round_trip); | |
36 | VERIFY( original == round_trip ); | |
37 | } | |
38 | ||
39 | void | |
40 | test02() | |
41 | { | |
42 | // Test skipws correctness. | |
83ac9249 ESR |
43 | std::wstringstream ss; |
44 | ss << std::quoted(L"Hello Goodbye") << L' ' << 1 << L' ' << 2; | |
45 | std::wstring song; | |
46 | int thing1, thing2; | |
47 | ss >> std::quoted(song) >> thing1 >> thing2; | |
48 | VERIFY( song == L"Hello Goodbye" ); | |
49 | VERIFY( thing1 == 1 ); | |
50 | VERIFY( thing2 == 2 ); | |
51 | } | |
52 | ||
53 | void | |
54 | test03() | |
55 | { | |
56 | // Test read of unquoted string. | |
83ac9249 ESR |
57 | std::wstringstream ss; |
58 | ss << L"Alpha Omega"; | |
59 | std::wstring testit; | |
60 | ss >> std::quoted(testit); | |
61 | VERIFY( testit == L"Alpha" ); | |
62 | } | |
63 | ||
64 | auto | |
65 | test04(const std::wstring& message) | |
66 | { | |
67 | // Test 'const basic_string&' | |
83ac9249 ESR |
68 | std::wstringstream ss; |
69 | ss << L"** Error: " << std::quoted(message) << L" **"; | |
70 | return ss.str(); | |
71 | } | |
72 | ||
73 | int | |
74 | main() | |
75 | { | |
76 | test01(); | |
77 | test02(); | |
78 | test03(); | |
79 | auto ss = test04(L"My biscuits are burnin'!"); | |
80 | VERIFY( ss == L"** Error: \"My biscuits are burnin'!\" **" ); | |
81 | ||
82 | return 0; | |
83 | } |