]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/12868.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_filebuf / imbue / wchar_t / 12868.cc
CommitLineData
9c69a458 1// { dg-require-namedlocale "is_IS.UTF-8" }
f63a8495 2
99dee823 3// Copyright (C) 2003-2021 Free Software Foundation, Inc.
29342463
PC
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
748086b7 8// Free Software Foundation; either version 3, or (at your option)
29342463
PC
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
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
29342463
PC
19
20// 27.8.1.4 Overridden virtual functions
21
22#include <ostream>
23#include <fstream>
24#include <locale>
25#include <string>
26#include <testsuite_hooks.h>
27
28// libstdc++/12868
29void test01()
30{
31 using namespace std;
29342463 32
f63a8495 33 locale loc_is(locale("is_IS.UTF-8"));
29342463
PC
34
35 {
36 wofstream out("tmp_12868");
37 out << L"<? xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
38 out.imbue(loc_is);
39 VERIFY( out.rdbuf()->getloc() == loc_is );
40 out << L"<greeting>Hall\u00f3 heimur</greeting>\n";
41 }
42
43 {
44 wifstream in("tmp_12868");
45 wstring str;
46 getline(in, str);
47 if (str.find(L"encoding=\"UTF-8\"") != wstring::npos)
48 {
49 in.imbue(loc_is);
50 VERIFY( in.rdbuf()->getloc() == loc_is );
51 }
52 getline(in, str);
53 VERIFY( str == L"<greeting>Hall\u00f3 heimur</greeting>" );
54 }
55}
56
57int main()
58{
59 test01();
60}