]> 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
5beab936 1// { dg-require-namedlocale "is_IS.UTF-8" }
e590fca1 2
f1717362 3// Copyright (C) 2003-2016 Free Software Foundation, Inc.
82324c10 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
6bc9506f 8// Free Software Foundation; either version 3, or (at your option)
82324c10 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
6bc9506f 17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
82324c10 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;
32 bool test __attribute__((unused)) = true;
33
e590fca1 34 locale loc_is(locale("is_IS.UTF-8"));
82324c10 35
36 {
37 wofstream out("tmp_12868");
38 out << L"<? xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
39 out.imbue(loc_is);
40 VERIFY( out.rdbuf()->getloc() == loc_is );
41 out << L"<greeting>Hall\u00f3 heimur</greeting>\n";
42 }
43
44 {
45 wifstream in("tmp_12868");
46 wstring str;
47 getline(in, str);
48 if (str.find(L"encoding=\"UTF-8\"") != wstring::npos)
49 {
50 in.imbue(loc_is);
51 VERIFY( in.rdbuf()->getloc() == loc_is );
52 }
53 getline(in, str);
54 VERIFY( str == L"<greeting>Hall\u00f3 heimur</greeting>" );
55 }
56}
57
58int main()
59{
60 test01();
61}