Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 27_io / manipulators / standard / wchar_t / quoted.cc
blobac4e0fb65e06bfe9fea7646c701c2e611bb57290
1 // { dg-do run }
2 // { dg-options "-std=gnu++1y" }
4 // Copyright (C) 2013 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // 27.7.6 - Quoted manipulators [quoted.manip]
23 #include <string>
24 #include <sstream>
25 #include <iomanip>
26 #include <testsuite_hooks.h>
28 void
29 test01()
31 // Basic test from paper.
32 bool test [[gnu::unused]] = true;
33 std::wstringstream ss;
34 std::wstring original = L"foolish me";
35 std::wstring round_trip;
36 ss << std::quoted(original);
37 ss >> std::quoted(round_trip);
38 VERIFY( original == round_trip );
41 void
42 test02()
44 // Test skipws correctness.
45 bool test [[gnu::unused]] = true;
46 std::wstringstream ss;
47 ss << std::quoted(L"Hello Goodbye") << L' ' << 1 << L' ' << 2;
48 std::wstring song;
49 int thing1, thing2;
50 ss >> std::quoted(song) >> thing1 >> thing2;
51 VERIFY( song == L"Hello Goodbye" );
52 VERIFY( thing1 == 1 );
53 VERIFY( thing2 == 2 );
56 void
57 test03()
59 // Test read of unquoted string.
60 bool test [[gnu::unused]] = true;
61 std::wstringstream ss;
62 ss << L"Alpha Omega";
63 std::wstring testit;
64 ss >> std::quoted(testit);
65 VERIFY( testit == L"Alpha" );
68 auto
69 test04(const std::wstring& message)
71 // Test 'const basic_string&'
72 bool test [[gnu::unused]] = true;
73 std::wstringstream ss;
74 ss << L"** Error: " << std::quoted(message) << L" **";
75 return ss.str();
78 int
79 main()
81 test01();
82 test02();
83 test03();
84 auto ss = test04(L"My biscuits are burnin'!");
85 VERIFY( ss == L"** Error: \"My biscuits are burnin'!\" **" );
87 return 0;