]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/manipulators/standard/char/quoted.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / manipulators / standard / char / quoted.cc
CommitLineData
b8263652 1// { dg-do run }
15d9538c 2// { dg-options "-std=gnu++14" }
b8263652 3
f1717362 4// Copyright (C) 2013-2016 Free Software Foundation, Inc.
b8263652 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.
11
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.
16
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/>.
20
21// 27.7.6 - Quoted manipulators [quoted.manip]
22
23#include <string>
24#include <sstream>
25#include <iomanip>
26#include <testsuite_hooks.h>
27
28void
29test01()
30{
31 // Basic test from paper.
32 bool test [[gnu::unused]] = true;
33 std::stringstream ss;
34 std::string original = "foolish me";
35 std::string round_trip;
36 ss << std::quoted(original);
37 ss >> std::quoted(round_trip);
38 VERIFY( original == round_trip );
39}
40
41void
42test02()
43{
44 // Test skipws correctness.
45 bool test [[gnu::unused]] = true;
46 std::stringstream ss;
47 ss << std::quoted("Hello Goodbye") << ' ' << 1 << ' ' << 2;
48 std::string song;
49 int thing1, thing2;
50 ss >> std::quoted(song) >> thing1 >> thing2;
51 VERIFY( song == "Hello Goodbye" );
52 VERIFY( thing1 == 1 );
53 VERIFY( thing2 == 2 );
54}
55
56void
57test03()
58{
59 // Test read of unquoted string.
60 bool test [[gnu::unused]] = true;
61 std::stringstream ss;
62 ss << "Alpha Omega";
63 std::string testit;
64 ss >> std::quoted(testit);
65 VERIFY( testit == "Alpha" );
66}
67
68auto
69test04(const std::string& message)
70{
71 // Test 'const basic_string&'
72 bool test [[gnu::unused]] = true;
73 std::stringstream ss;
74 ss << "** Error: " << std::quoted(message) << " **";
75 return ss.str();
76}
77
78int
79main()
80{
81 test01();
82 test02();
83 test03();
84 auto ss = test04("My biscuits are burnin'!");
85 VERIFY( ss == "** Error: \"My biscuits are burnin'!\" **" );
86
87 return 0;
88}