]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/ext/enc_filebuf/char/13598.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / ext / enc_filebuf / char / 13598.cc
CommitLineData
b57c6b13
RO
1// Before Solaris 11, iconv -f ISO-8859-1 -t ISO-8859-1 fails with
2// Not supported ISO-8859-1 to ISO-8859-1
3//
d9f069ab 4// { dg-do run { xfail *-*-solaris2.10 } }
4ffe6e87
BK
5// { dg-require-iconv "ISO-8859-1" }
6
85ec4feb 7// Copyright (C) 2004-2018 Free Software Foundation, Inc.
a5f105b5
BK
8//
9// This file is part of the GNU ISO C++ Library. This library is free
10// software; you can redistribute it and/or modify it under the
11// terms of the GNU General Public License as published by the
748086b7 12// Free Software Foundation; either version 3, or (at your option)
a5f105b5
BK
13// any later version.
14
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19
20// You should have received a copy of the GNU General Public License along
748086b7
JJ
21// with this library; see the file COPYING3. If not see
22// <http://www.gnu.org/licenses/>.
a5f105b5
BK
23
24#include <locale>
25#include <cstring>
7919bb2f 26#include <cstddef>
1ecba09e 27#include <testsuite_hooks.h>
a5f105b5 28#include <ext/enc_filebuf.h>
a5f105b5
BK
29
30int main()
31{
4ffe6e87
BK
32 typedef char char_type;
33 typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
34 typedef filebuf_type::state_type state_type;
a5f105b5 35
1ecba09e 36 const char* str = "Hello, world!\n";
a5f105b5 37 std::locale loc(std::locale::classic(),
4ffe6e87
BK
38 new std::codecvt<char, char, __gnu_cxx::encoding_state>());
39 state_type st("ISO-8859-1", "ISO-8859-1");
40 filebuf_type fb(st);
a5f105b5
BK
41 fb.pubimbue(loc);
42
43 fb.open("tmp_13598", std::ios_base::out);
44 std::streamsize n = fb.sputn(str, std::strlen(str));
45 int s = fb.pubsync();
46 fb.close();
7919bb2f
PC
47
48 VERIFY( std::size_t(n) == std::strlen(str) );
1ecba09e 49 VERIFY( s == 0 );
a5f105b5
BK
50
51 return 0;
52}