]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/manipulators/standard/char/quoted.cc
2 // { dg-options "-std=gnu++1y" }
4 // Copyright (C) 2013-2014 Free Software Foundation, Inc.
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)
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]
26 #include <testsuite_hooks.h>
31 // Basic test from paper.
32 bool test
[[gnu::unused
]] = true;
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
);
44 // Test skipws correctness.
45 bool test
[[gnu::unused
]] = true;
47 ss
<< std::quoted("Hello Goodbye") << ' ' << 1 << ' ' << 2;
50 ss
>> std::quoted(song
) >> thing1
>> thing2
;
51 VERIFY( song
== "Hello Goodbye" );
52 VERIFY( thing1
== 1 );
53 VERIFY( thing2
== 2 );
59 // Test read of unquoted string.
60 bool test
[[gnu::unused
]] = true;
64 ss
>> std::quoted(testit
);
65 VERIFY( testit
== "Alpha" );
69 test04(const std::string
& message
)
71 // Test 'const basic_string&'
72 bool test
[[gnu::unused
]] = true;
74 ss
<< "** Error: " << std::quoted(message
) << " **";
84 auto ss
= test04("My biscuits are burnin'!");
85 VERIFY( ss
== "** Error: \"My biscuits are burnin'!\" **" );