]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/manipulators/standard/char/quoted_sv.cc
1 // { dg-do run { target c++17 } }
3 // Copyright (C) 2018-2023 Free Software Foundation, Inc.
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)
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.
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/>.
20 // C++17 30.7.8 - Quoted manipulators [quoted.manip]
22 #include <string_view>
25 #include <testsuite_hooks.h>
31 const std::string_view original
= R
"(This "string
" will be \"quoted\")";
32 std::string raw
, round_trip
;
33 ss
<< std::quoted(original
);
35 VERIFY( raw
== R
"("This
\"string
\" will be
\\\"quoted
\\\"")" );
36 ss
>> std::quoted(round_trip
);
37 VERIFY( original
== round_trip
);
44 const std::string_view original
= R
"(This "string
" will be \"quoted\")";
45 std::string raw
, round_trip
;
46 ss
<< std::quoted(original
, '\'', '!');
48 VERIFY( raw
== R
"('This "string
" will be \"quoted\"')" );
49 ss
>> std::quoted(round_trip
, '\'', '!');
50 VERIFY( original
== round_trip
);
57 const std::string_view original
= R
"(This 'string' will be !'quoted!')";
58 std::string raw
, round_trip
;
59 ss
<< std::quoted(original
, '\'', '!');
61 VERIFY( raw
== R
"('This !'string!' will be !!!'quoted!!!'')" );
62 ss
>> std::quoted(round_trip
, '\'', '!');
63 VERIFY( original
== round_trip
);