]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/manipulators/standard/wchar_t/quoted_sv.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / manipulators / standard / wchar_t / quoted_sv.cc
CommitLineData
7db54ccd
JW
1// { dg-do run { target c++17 } }
2
83ffe9cd 3// Copyright (C) 2018-2023 Free Software Foundation, Inc.
7db54ccd
JW
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
20// C++17 30.7.8 - Quoted manipulators [quoted.manip]
21
22#include <string_view>
23#include <sstream>
24#include <iomanip>
25#include <testsuite_hooks.h>
26
27void
28test01()
29{
30 std::wstringstream ss;
31 const std::wstring_view original = LR"(This "string" will be \"quoted\")";
32 std::wstring raw, round_trip;
33 ss << std::quoted(original);
34 raw = ss.str();
35 VERIFY( raw == LR"("This \"string\" will be \\\"quoted\\\"")" );
36 ss >> std::quoted(round_trip);
37 VERIFY( original == round_trip );
38}
39
40void
41test02()
42{
43 std::wstringstream ss;
44 const std::wstring_view original = LR"(This "string" will be \"quoted\")";
45 std::wstring raw, round_trip;
46 ss << std::quoted(original, L'\'', L'!');
47 raw = ss.str();
48 VERIFY( raw == LR"('This "string" will be \"quoted\"')" );
49 ss >> std::quoted(round_trip, L'\'', L'!');
50 VERIFY( original == round_trip );
51}
52
53void
54test03()
55{
56 std::wstringstream ss;
57 const std::wstring_view original = LR"(This 'string' will be !'quoted!')";
58 std::wstring raw, round_trip;
59 ss << std::quoted(original, L'\'', L'!');
60 raw = ss.str();
61 VERIFY( raw == LR"('This !'string!' will be !!!'quoted!!!'')" );
62 ss >> std::quoted(round_trip, L'\'', L'!');
63 VERIFY( original == round_trip );
64}
65
66int
67main()
68{
69 test01();
70 test02();
71 test03();
72}